mirror of
https://github.com/LukeHagar/arbiter.git
synced 2025-12-10 04:19:26 +00:00
Saving all progress
This commit is contained in:
16
node_modules/@codemirror/autocomplete/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/autocomplete/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
608
node_modules/@codemirror/autocomplete/CHANGELOG.md
generated
vendored
Normal file
608
node_modules/@codemirror/autocomplete/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,608 @@
|
||||
## 6.18.6 (2025-02-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the closing character for double-angle quotation marks and full-width brackets was computed incorrectly.
|
||||
|
||||
## 6.18.5 (2025-02-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where clicking on the scrollbar for the completion list could move focus out of the editor.
|
||||
|
||||
## 6.18.4 (2024-12-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Align the behavior of snippet completions with text completions in that they overwrite the selected text.
|
||||
|
||||
## 6.18.3 (2024-11-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Backspacing to the start of the completed range will no longer close the completion tooltip when it was triggered implicitly by typing the character before that range.
|
||||
|
||||
## 6.18.2 (2024-10-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't immediately show synchronously updated completions when there are some sources that still need to return.
|
||||
|
||||
## 6.18.1 (2024-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `insertCompletionText` would get confused about the length of the inserted text when it contained CRLF line breaks, and create an invalid selection.
|
||||
|
||||
Add Alt-Backtick as additional binding on macOS, where IME can take over Ctrl-Space.
|
||||
|
||||
## 6.18.0 (2024-08-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Style the info element so that newlines are preserved, to make it easier to display multi-line info from a string source.
|
||||
|
||||
### New features
|
||||
|
||||
When registering an `abort` handler for a completion query, you can now use the `onDocChange` option to indicate that your query should be aborted as soon as the document changes while it is running.
|
||||
|
||||
## 6.17.0 (2024-07-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where completions weren't properly reset when starting a new completion through `activateOnCompletion`.
|
||||
|
||||
### New features
|
||||
|
||||
`CompletionContext` objects now have a `view` property that holds the editor view when the query context has a view available.
|
||||
|
||||
## 6.16.3 (2024-06-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid adding an `aria-autocomplete` attribute to the editor when there are no active sources active.
|
||||
|
||||
## 6.16.2 (2024-05-31)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow backslash-escaped closing braces inside snippet field names/content.
|
||||
|
||||
## 6.16.1 (2024-05-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where multiple backslashes before a brace in a snippet were all removed.
|
||||
|
||||
## 6.16.0 (2024-04-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `activateOnCompletion` option allows autocompletion to be configured to chain completion activation for some types of completions.
|
||||
|
||||
## 6.15.0 (2024-03-13)
|
||||
|
||||
### New features
|
||||
|
||||
The new `filterStrict` option can be used to turn off fuzzy matching of completions.
|
||||
|
||||
## 6.14.0 (2024-03-10)
|
||||
|
||||
### New features
|
||||
|
||||
Completion results can now define a `map` method that can be used to adjust position-dependent information for document changes.
|
||||
|
||||
## 6.13.0 (2024-02-29)
|
||||
|
||||
### New features
|
||||
|
||||
Completions may now provide 'commit characters' that, when typed, commit the completion before inserting the character.
|
||||
|
||||
## 6.12.0 (2024-01-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure snippet completions also set `userEvent` to `input.complete`.
|
||||
|
||||
Fix a crash when the editor lost focus during an update and autocompletion was active.
|
||||
|
||||
Fix a crash when using a snippet that has only one field, but multiple instances of that field.
|
||||
|
||||
### New features
|
||||
|
||||
The new `activateOnTypingDelay` option allows control over the debounce time before the completions are queried when the user types.
|
||||
|
||||
## 6.11.1 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused typing over closed brackets after pressing enter to still not work in many situations.
|
||||
|
||||
## 6.11.0 (2023-11-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that would prevent typing over closed brackets after starting a new line with enter.
|
||||
|
||||
### New features
|
||||
|
||||
Additional elements rendered in completion options with `addToOptions` are now given access to the editor view.
|
||||
|
||||
## 6.10.2 (2023-10-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `updateSyncTime` to always delay the initial population of the tooltip.
|
||||
|
||||
## 6.10.1 (2023-10-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where picking a selection with the mouse could use the wrong completion if the completion list was updated after being opened.
|
||||
|
||||
## 6.10.0 (2023-10-11)
|
||||
|
||||
### New features
|
||||
|
||||
The new autocompletion configuration option `updateSyncTime` allows control over how long fast sources are held back waiting for slower completion sources.
|
||||
|
||||
## 6.9.2 (2023-10-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in `completeAnyWord` that could cause it to generate invalid regular expressions and crash.
|
||||
|
||||
## 6.9.1 (2023-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the cursor is scrolled into view after inserting completion text.
|
||||
|
||||
Make sure scrolling completions into view doesn't get confused when the tooltip is scaled.
|
||||
|
||||
## 6.9.0 (2023-07-18)
|
||||
|
||||
### New features
|
||||
|
||||
Completions may now provide a `displayLabel` property that overrides the way they are displayed in the completion list.
|
||||
|
||||
## 6.8.1 (2023-06-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`acceptCompletion` now returns false (allowing other handlers to take effect) when the completion popup is open but disabled.
|
||||
|
||||
## 6.8.0 (2023-06-12)
|
||||
|
||||
### New features
|
||||
|
||||
The result of `Completion.info` may now include a `destroy` method that will be called when the tooltip is removed.
|
||||
|
||||
## 6.7.1 (2023-05-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that cause incorrect ordering of completions when some results covered input text and others didn't.
|
||||
|
||||
## 6.7.0 (2023-05-11)
|
||||
|
||||
### New features
|
||||
|
||||
The new `hasNextSnippetField` and `hasPrevSnippetField` functions can be used to figure out if the snippet-field-motion commands apply to a given state.
|
||||
|
||||
## 6.6.1 (2023-05-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that made the editor use the completion's original position, rather than its current position, when changes happened in the document while a result was active.
|
||||
|
||||
## 6.6.0 (2023-04-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in `insertCompletionText` that caused it to replace the wrong range when a result set's `to` fell after the cursor.
|
||||
|
||||
### New features
|
||||
|
||||
Functions returned by `snippet` can now be called without a completion object.
|
||||
|
||||
## 6.5.1 (2023-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Keep completions open when interaction with an info tooltip moves focus out of the editor.
|
||||
|
||||
## 6.5.0 (2023-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When `closeBrackets` skips a bracket, it now generates a change that overwrites the bracket.
|
||||
|
||||
Replace the entire selected range when picking a completion with a non-cursor selection active.
|
||||
|
||||
### New features
|
||||
|
||||
Completions can now provide a `section` field that is used to group them into sections.
|
||||
|
||||
The new `positionInfo` option can be used to provide custom logic for positioning the info tooltips.
|
||||
|
||||
## 6.4.2 (2023-02-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where the apply method created by `snippet` didn't add a `pickedCompletion` annotation to the transactions it created.
|
||||
|
||||
## 6.4.1 (2023-02-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't consider node names in trees that aren't the same language as the one at the completion position in `ifIn` and `ifNotIn`.
|
||||
|
||||
Make sure completions that exactly match the input get a higher score than those that don't (so that even if the latter has a score boost, it ends up lower in the list).
|
||||
|
||||
## 6.4.0 (2022-12-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the extension would sometimes try to draw a disabled dialog at an outdated position, leading to plugin crashes.
|
||||
|
||||
### New features
|
||||
|
||||
A `tooltipClass` option to autocompletion can now be used to add additional CSS classes to the completion tooltip.
|
||||
|
||||
## 6.3.4 (2022-11-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where completion lists could end up being higher than the tooltip they were in.
|
||||
|
||||
## 6.3.3 (2022-11-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Set an explicit `box-sizing` style on completion icons so CSS resets don't mess them up.
|
||||
|
||||
Allow closing braces in templates to be escaped with a backslash.
|
||||
|
||||
## 6.3.2 (2022-11-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression that could cause the completion dialog to stick around when it should be hidden.
|
||||
|
||||
## 6.3.1 (2022-11-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression where transactions for picking a completion (without custom `apply` method) no longer had the `pickedCompletion` annotation.
|
||||
|
||||
Reduce flickering for completion sources without `validFor` info by temporarily showing a disabled tooltip while the completion updates.
|
||||
|
||||
Make sure completion info tooltips are kept within the space provided by the `tooltipSpace` option.
|
||||
|
||||
## 6.3.0 (2022-09-22)
|
||||
|
||||
### New features
|
||||
|
||||
Close bracket configuration now supports a `stringPrefixes` property that can be used to allow autoclosing of prefixed strings.
|
||||
|
||||
## 6.2.0 (2022-09-13)
|
||||
|
||||
### New features
|
||||
|
||||
Autocompletion now takes an `interactionDelay` option that can be used to control the delay between the time where completion opens and the time where commands like `acceptCompletion` affect it.
|
||||
|
||||
## 6.1.1 (2022-09-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that prevented transactions produced by `deleteBracketPair` from being marked as deletion user events.
|
||||
|
||||
Improve positioning of completion info tooltips so they are less likely to stick out of the screen on small displays.
|
||||
|
||||
## 6.1.0 (2022-07-19)
|
||||
|
||||
### New features
|
||||
|
||||
You can now provide a `compareCompletions` option to autocompletion to influence the way completions with the same match score are sorted.
|
||||
|
||||
The `selectOnOpen` option to autocompletion can be used to require explicitly selecting a completion option before `acceptCompletion` does anything.
|
||||
|
||||
## 6.0.4 (2022-07-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove a leftover `console.log` in bracket closing code.
|
||||
|
||||
## 6.0.3 (2022-07-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `closeBrackets` to not close quotes when at the end of a syntactic construct that starts with a similar quote.
|
||||
|
||||
## 6.0.2 (2022-06-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Declare package dependencies as peer dependencies as an attempt to avoid duplicated package issues.
|
||||
|
||||
## 6.0.1 (2022-06-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Support escaping `${` or `#{` in snippets.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Scroll the cursor into view when inserting a snippet.
|
||||
|
||||
## 0.20.3 (2022-05-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add an aria-label to the completion listbox.
|
||||
|
||||
Fix a regression that caused transactions generated for completion to not have a `userEvent` annotation.
|
||||
|
||||
## 0.20.2 (2022-05-24)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports an `insertCompletionText` helper that implements the default behavior for applying a completion.
|
||||
|
||||
## 0.20.1 (2022-05-16)
|
||||
|
||||
### New features
|
||||
|
||||
The new `closeOnBlur` option determines whether the completion tooltip is closed when the editor loses focus.
|
||||
|
||||
`CompletionResult` objects with `filter: false` may now have a `getMatch` property that determines the matched range in the options.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`CompletionResult.span` has been renamed to `validFor`, and may now hold a function as well as a regular expression.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove code that dropped any options beyond the 300th one when matching and sorting option lists.
|
||||
|
||||
Completion will now apply to all cursors when there are multiple cursors.
|
||||
|
||||
### New features
|
||||
|
||||
`CompletionResult.update` can now be used to implement quick autocompletion updates in a synchronous way.
|
||||
|
||||
The @codemirror/closebrackets package was merged into this one.
|
||||
|
||||
## 0.19.15 (2022-03-23)
|
||||
|
||||
### New features
|
||||
|
||||
The `selectedCompletionIndex` function tells you the position of the currently selected completion.
|
||||
|
||||
The new `setSelectionCompletion` function creates a state effect that moves the selected completion to a given index.
|
||||
|
||||
A completion's `info` method may now return null to indicate that no further info is available.
|
||||
|
||||
## 0.19.14 (2022-03-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make the ARIA attributes added to the editor during autocompletion spec-compliant.
|
||||
|
||||
## 0.19.13 (2022-02-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the completion tooltip stayed open if it was explicitly opened and the user backspaced past its start.
|
||||
|
||||
Stop snippet filling when a change happens across one of the snippet fields' boundaries.
|
||||
|
||||
## 0.19.12 (2022-01-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix completion navigation with PageUp/Down when the completion tooltip isn't part of the view DOM.
|
||||
|
||||
## 0.19.11 (2022-01-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused page up/down to only move the selection by two options in the completion tooltip.
|
||||
|
||||
## 0.19.10 (2022-01-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the info tooltip is hidden when the selected option is scrolled out of view.
|
||||
|
||||
Fix a bug in the completion ranking that would sometimes give options that match the input by word start chars higher scores than appropriate.
|
||||
|
||||
Options are now sorted (ascending) by length when their match score is otherwise identical.
|
||||
|
||||
## 0.19.9 (2021-11-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where info tooltips would be visible in an inappropriate position when there was no room to place them properly.
|
||||
|
||||
## 0.19.8 (2021-11-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give the completion tooltip a minimal width, and show ellipsis when completions overflow the tooltip width.
|
||||
|
||||
### New features
|
||||
|
||||
`autocompletion` now accepts an `aboveCursor` option to make the completion tooltip show up above the cursor.
|
||||
|
||||
## 0.19.7 (2021-11-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make option deduplication less aggressive, so that options with different `type` or `apply` fields don't get merged.
|
||||
|
||||
## 0.19.6 (2021-11-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where parsing a snippet with a field that was labeled only by a number crashed.
|
||||
|
||||
## 0.19.5 (2021-11-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure info tooltips don't stick out of the bottom of the page.
|
||||
|
||||
### New features
|
||||
|
||||
The package exports a new function `selectedCompletion`, which can be used to find out which completion is currently selected.
|
||||
|
||||
Transactions created by picking a completion now have an annotation (`pickedCompletion`) holding the original completion.
|
||||
|
||||
## 0.19.4 (2021-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't rely on the platform's highlight colors for the active completion, since those are inconsistent and may not be appropriate for the theme.
|
||||
|
||||
Fix incorrect match underline for some kinds of matched completions.
|
||||
|
||||
## 0.19.3 (2021-08-31)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve the sorting of completions by using `localeCompare`.
|
||||
|
||||
Fix reading of autocompletions in NVDA screen reader.
|
||||
|
||||
### New features
|
||||
|
||||
The new `icons` option can be used to turn off icons in the completion list.
|
||||
|
||||
The `optionClass` option can now be used to add CSS classes to the options in the completion list.
|
||||
|
||||
It is now possible to inject additional content into rendered completion options with the `addToOptions` configuration option.
|
||||
|
||||
## 0.19.2 (2021-08-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `completeAnyWord` would return results when there was no query and `explicit` was false.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.8 (2021-06-30)
|
||||
|
||||
### New features
|
||||
|
||||
Add an `ifIn` helper function that constrains a completion source to only fire when in a given syntax node. Add support for unfiltered completions
|
||||
|
||||
A completion result can now set a `filter: false` property to disable filtering and sorting of completions, when it already did so itself.
|
||||
|
||||
## 0.18.7 (2021-06-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't treat continued completions when typing after an explicit completion as explicit.
|
||||
|
||||
## 0.18.6 (2021-06-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Adding or reconfiguring completion sources will now cause them to be activated right away if a completion was active.
|
||||
|
||||
### New features
|
||||
|
||||
You can now specify multiple types in `Completion.type` by separating them by spaces. Small doc comment tweak for Completion.type
|
||||
|
||||
## 0.18.5 (2021-04-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression where snippet field selection didn't work with @codemirror/state 0.18.6.
|
||||
|
||||
Fix a bug where snippet fields with different position numbers were inappropriately merged.
|
||||
|
||||
## 0.18.4 (2021-04-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash in Safari when moving the selection during composition.
|
||||
|
||||
## 0.18.3 (2021-03-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Adjust to updated @codemirror/tooltip interface.
|
||||
|
||||
## 0.18.2 (2021-03-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix unintended ES2020 output (the package contains ES6 code again).
|
||||
|
||||
## 0.18.1 (2021-03-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Stop active completion when all sources resolve without producing any matches.
|
||||
|
||||
### New features
|
||||
|
||||
`Completion.info` may now return a promise.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Only preserve selected option across updates when it isn't the first option.
|
||||
|
||||
## 0.17.4 (2021-01-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a styling issue where the selection had become invisible inside snippet fields (when using `drawSelection`).
|
||||
|
||||
### New features
|
||||
|
||||
Snippet fields can now be selected with the pointing device (so that they are usable on touch devices).
|
||||
|
||||
## 0.17.3 (2021-01-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where uppercase completions would be incorrectly matched against the typed input.
|
||||
|
||||
## 0.17.2 (2021-01-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't bind Cmd-Space on macOS, since that already has a system default binding. Use Ctrl-Space for autocompletion.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/autocomplete/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/autocomplete/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
43
node_modules/@codemirror/autocomplete/README.md
generated
vendored
Normal file
43
node_modules/@codemirror/autocomplete/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# @codemirror/autocomplete [](https://www.npmjs.org/package/@codemirror/autocomplete)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#autocomplete) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/autocomplete/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements autocompletion for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/autocomplete/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {EditorView} from "@codemirror/view"
|
||||
import {autocompletion} from "@codemirror/autocomplete"
|
||||
import {jsonLanguage} from "@codemirror/lang-json"
|
||||
|
||||
const view = new EditorView({
|
||||
parent: document.body,
|
||||
extensions: [
|
||||
jsonLanguage,
|
||||
autocompletion(),
|
||||
jsonLanguage.data.of({
|
||||
autocomplete: ["id", "name", "address"]
|
||||
})
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
This configuration will just complete the given words anywhere in JSON
|
||||
context. Most language modules come with more refined autocompletion
|
||||
built-in, but you can also write your own custom autocompletion
|
||||
[sources](https://codemirror.net/docs/ref/#autocomplete.CompletionSource)
|
||||
and associate them with your language this way.
|
||||
2110
node_modules/@codemirror/autocomplete/dist/index.cjs
generated
vendored
Normal file
2110
node_modules/@codemirror/autocomplete/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
639
node_modules/@codemirror/autocomplete/dist/index.d.cts
generated
vendored
Normal file
639
node_modules/@codemirror/autocomplete/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,639 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
|
||||
import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view';
|
||||
import * as _lezer_common from '@lezer/common';
|
||||
|
||||
/**
|
||||
Objects type used to represent individual completions.
|
||||
*/
|
||||
interface Completion {
|
||||
/**
|
||||
The label to show in the completion picker. This is what input
|
||||
is matched against to determine whether a completion matches (and
|
||||
how well it matches).
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
An optional override for the completion's visible label. When
|
||||
using this, matched characters will only be highlighted if you
|
||||
provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch)
|
||||
function.
|
||||
*/
|
||||
displayLabel?: string;
|
||||
/**
|
||||
An optional short piece of information to show (with a different
|
||||
style) after the label.
|
||||
*/
|
||||
detail?: string;
|
||||
/**
|
||||
Additional info to show when the completion is selected. Can be
|
||||
a plain string or a function that'll render the DOM structure to
|
||||
show when invoked.
|
||||
*/
|
||||
info?: string | ((completion: Completion) => CompletionInfo | Promise<CompletionInfo>);
|
||||
/**
|
||||
How to apply the completion. The default is to replace it with
|
||||
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a
|
||||
string, the completion range is replaced by that string. When it
|
||||
is a function, that function is called to perform the
|
||||
completion. If it fires a transaction, it is responsible for
|
||||
adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion)
|
||||
annotation to it.
|
||||
*/
|
||||
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void);
|
||||
/**
|
||||
The type of the completion. This is used to pick an icon to show
|
||||
for the completion. Icons are styled with a CSS class created by
|
||||
appending the type name to `"cm-completionIcon-"`. You can
|
||||
define or restyle icons by defining these selectors. The base
|
||||
library defines simple icons for `class`, `constant`, `enum`,
|
||||
`function`, `interface`, `keyword`, `method`, `namespace`,
|
||||
`property`, `text`, `type`, and `variable`.
|
||||
|
||||
Multiple types can be provided by separating them with spaces.
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
When this option is selected, and one of these characters is
|
||||
typed, insert the completion before typing the character.
|
||||
*/
|
||||
commitCharacters?: readonly string[];
|
||||
/**
|
||||
When given, should be a number from -99 to 99 that adjusts how
|
||||
this completion is ranked compared to other completions that
|
||||
match the input as well as this one. A negative number moves it
|
||||
down the list, a positive number moves it up.
|
||||
*/
|
||||
boost?: number;
|
||||
/**
|
||||
Can be used to divide the completion list into sections.
|
||||
Completions in a given section (matched by name) will be grouped
|
||||
together, with a heading above them. Options without section
|
||||
will appear above all sections. A string value is equivalent to
|
||||
a `{name}` object.
|
||||
*/
|
||||
section?: string | CompletionSection;
|
||||
}
|
||||
/**
|
||||
The type returned from
|
||||
[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM
|
||||
node, null to indicate there is no info, or an object with an
|
||||
optional `destroy` method that cleans up the node.
|
||||
*/
|
||||
type CompletionInfo = Node | null | {
|
||||
dom: Node;
|
||||
destroy?(): void;
|
||||
};
|
||||
/**
|
||||
Object used to describe a completion
|
||||
[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to
|
||||
create a shared object used by all the completions in a given
|
||||
section.
|
||||
*/
|
||||
interface CompletionSection {
|
||||
/**
|
||||
The name of the section. If no `render` method is present, this
|
||||
will be displayed above the options.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
An optional function that renders the section header. Since the
|
||||
headers are shown inside a list, you should make sure the
|
||||
resulting element has a `display: list-item` style.
|
||||
*/
|
||||
header?: (section: CompletionSection) => HTMLElement;
|
||||
/**
|
||||
By default, sections are ordered alphabetically by name. To
|
||||
specify an explicit order, `rank` can be used. Sections with a
|
||||
lower rank will be shown above sections with a higher rank.
|
||||
*/
|
||||
rank?: number;
|
||||
}
|
||||
/**
|
||||
An instance of this is passed to completion source functions.
|
||||
*/
|
||||
declare class CompletionContext {
|
||||
/**
|
||||
The editor state that the completion happens in.
|
||||
*/
|
||||
readonly state: EditorState;
|
||||
/**
|
||||
The position at which the completion is happening.
|
||||
*/
|
||||
readonly pos: number;
|
||||
/**
|
||||
Indicates whether completion was activated explicitly, or
|
||||
implicitly by typing. The usual way to respond to this is to
|
||||
only return completions when either there is part of a
|
||||
completable entity before the cursor, or `explicit` is true.
|
||||
*/
|
||||
readonly explicit: boolean;
|
||||
/**
|
||||
The editor view. May be undefined if the context was created
|
||||
in a situation where there is no such view available, such as
|
||||
in synchronous updates via
|
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code.
|
||||
*/
|
||||
readonly view?: EditorView | undefined;
|
||||
/**
|
||||
Create a new completion context. (Mostly useful for testing
|
||||
completion sources—in the editor, the extension will create
|
||||
these for you.)
|
||||
*/
|
||||
constructor(
|
||||
/**
|
||||
The editor state that the completion happens in.
|
||||
*/
|
||||
state: EditorState,
|
||||
/**
|
||||
The position at which the completion is happening.
|
||||
*/
|
||||
pos: number,
|
||||
/**
|
||||
Indicates whether completion was activated explicitly, or
|
||||
implicitly by typing. The usual way to respond to this is to
|
||||
only return completions when either there is part of a
|
||||
completable entity before the cursor, or `explicit` is true.
|
||||
*/
|
||||
explicit: boolean,
|
||||
/**
|
||||
The editor view. May be undefined if the context was created
|
||||
in a situation where there is no such view available, such as
|
||||
in synchronous updates via
|
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code.
|
||||
*/
|
||||
view?: EditorView | undefined);
|
||||
/**
|
||||
Get the extent, content, and (if there is a token) type of the
|
||||
token before `this.pos`.
|
||||
*/
|
||||
tokenBefore(types: readonly string[]): {
|
||||
from: number;
|
||||
to: number;
|
||||
text: string;
|
||||
type: _lezer_common.NodeType;
|
||||
} | null;
|
||||
/**
|
||||
Get the match of the given expression directly before the
|
||||
cursor.
|
||||
*/
|
||||
matchBefore(expr: RegExp): {
|
||||
from: number;
|
||||
to: number;
|
||||
text: string;
|
||||
} | null;
|
||||
/**
|
||||
Yields true when the query has been aborted. Can be useful in
|
||||
asynchronous queries to avoid doing work that will be ignored.
|
||||
*/
|
||||
get aborted(): boolean;
|
||||
/**
|
||||
Allows you to register abort handlers, which will be called when
|
||||
the query is
|
||||
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
|
||||
|
||||
By default, running queries will not be aborted for regular
|
||||
typing or backspacing, on the assumption that they are likely to
|
||||
return a result with a
|
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
|
||||
allows the result to be used after all. Passing `onDocChange:
|
||||
true` will cause this query to be aborted for any document
|
||||
change.
|
||||
*/
|
||||
addEventListener(type: "abort", listener: () => void, options?: {
|
||||
onDocChange: boolean;
|
||||
}): void;
|
||||
}
|
||||
/**
|
||||
Given a a fixed array of options, return an autocompleter that
|
||||
completes them.
|
||||
*/
|
||||
declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource;
|
||||
/**
|
||||
Wrap the given completion source so that it will only fire when the
|
||||
cursor is in a syntax node with one of the given names.
|
||||
*/
|
||||
declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
||||
/**
|
||||
Wrap the given completion source so that it will not fire when the
|
||||
cursor is in a syntax node with one of the given names.
|
||||
*/
|
||||
declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
||||
/**
|
||||
The function signature for a completion source. Such a function
|
||||
may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult)
|
||||
synchronously or as a promise. Returning null indicates no
|
||||
completions are available.
|
||||
*/
|
||||
type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>;
|
||||
/**
|
||||
Interface for objects returned by completion sources.
|
||||
*/
|
||||
interface CompletionResult {
|
||||
/**
|
||||
The start of the range that is being completed.
|
||||
*/
|
||||
from: number;
|
||||
/**
|
||||
The end of the range that is being completed. Defaults to the
|
||||
main cursor position.
|
||||
*/
|
||||
to?: number;
|
||||
/**
|
||||
The completions returned. These don't have to be compared with
|
||||
the input by the source—the autocompletion system will do its
|
||||
own matching (against the text between `from` and `to`) and
|
||||
sorting.
|
||||
*/
|
||||
options: readonly Completion[];
|
||||
/**
|
||||
When given, further typing or deletion that causes the part of
|
||||
the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from`
|
||||
and `to` to match this regular expression or predicate function
|
||||
will not query the completion source again, but continue with
|
||||
this list of options. This can help a lot with responsiveness,
|
||||
since it allows the completion list to be updated synchronously.
|
||||
*/
|
||||
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean);
|
||||
/**
|
||||
By default, the library filters and scores completions. Set
|
||||
`filter` to `false` to disable this, and cause your completions
|
||||
to all be included, in the order they were given. When there are
|
||||
other sources, unfiltered completions appear at the top of the
|
||||
list of completions. `validFor` must not be given when `filter`
|
||||
is `false`, because it only works when filtering.
|
||||
*/
|
||||
filter?: boolean;
|
||||
/**
|
||||
When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to
|
||||
`false` or a completion has a
|
||||
[`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this
|
||||
may be provided to compute the ranges on the label that match
|
||||
the input. Should return an array of numbers where each pair of
|
||||
adjacent numbers provide the start and end of a range. The
|
||||
second argument, the match found by the library, is only passed
|
||||
when `filter` isn't `false`.
|
||||
*/
|
||||
getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[];
|
||||
/**
|
||||
Synchronously update the completion result after typing or
|
||||
deletion. If given, this should not do any expensive work, since
|
||||
it will be called during editor state updates. The function
|
||||
should make sure (similar to
|
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the
|
||||
completion still applies in the new state.
|
||||
*/
|
||||
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null;
|
||||
/**
|
||||
When results contain position-dependent information in, for
|
||||
example, `apply` methods, you can provide this method to update
|
||||
the result for transactions that happen after the query. It is
|
||||
not necessary to update `from` and `to`—those are tracked
|
||||
automatically.
|
||||
*/
|
||||
map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null;
|
||||
/**
|
||||
Set a default set of [commit
|
||||
characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all
|
||||
options in this result.
|
||||
*/
|
||||
commitCharacters?: readonly string[];
|
||||
}
|
||||
/**
|
||||
This annotation is added to transactions that are produced by
|
||||
picking a completion.
|
||||
*/
|
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>;
|
||||
/**
|
||||
Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec;
|
||||
|
||||
interface CompletionConfig {
|
||||
/**
|
||||
When enabled (defaults to true), autocompletion will start
|
||||
whenever the user types something that can be completed.
|
||||
*/
|
||||
activateOnTyping?: boolean;
|
||||
/**
|
||||
When given, if a completion that matches the predicate is
|
||||
picked, reactivate completion again as if it was typed normally.
|
||||
*/
|
||||
activateOnCompletion?: (completion: Completion) => boolean;
|
||||
/**
|
||||
The amount of time to wait for further typing before querying
|
||||
completion sources via
|
||||
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping).
|
||||
Defaults to 100, which should be fine unless your completion
|
||||
source is very slow and/or doesn't use `validFor`.
|
||||
*/
|
||||
activateOnTypingDelay?: number;
|
||||
/**
|
||||
By default, when completion opens, the first option is selected
|
||||
and can be confirmed with
|
||||
[`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this
|
||||
is set to false, the completion widget starts with no completion
|
||||
selected, and the user has to explicitly move to a completion
|
||||
before you can confirm one.
|
||||
*/
|
||||
selectOnOpen?: boolean;
|
||||
/**
|
||||
Override the completion sources used. By default, they will be
|
||||
taken from the `"autocomplete"` [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold
|
||||
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays
|
||||
of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)).
|
||||
*/
|
||||
override?: readonly CompletionSource[] | null;
|
||||
/**
|
||||
Determines whether the completion tooltip is closed when the
|
||||
editor loses focus. Defaults to true.
|
||||
*/
|
||||
closeOnBlur?: boolean;
|
||||
/**
|
||||
The maximum number of options to render to the DOM.
|
||||
*/
|
||||
maxRenderedOptions?: number;
|
||||
/**
|
||||
Set this to false to disable the [default completion
|
||||
keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to
|
||||
add bindings to control completion yourself. The bindings should
|
||||
probably have a higher precedence than other bindings for the
|
||||
same keys.)
|
||||
*/
|
||||
defaultKeymap?: boolean;
|
||||
/**
|
||||
By default, completions are shown below the cursor when there is
|
||||
space. Setting this to true will make the extension put the
|
||||
completions above the cursor when possible.
|
||||
*/
|
||||
aboveCursor?: boolean;
|
||||
/**
|
||||
When given, this may return an additional CSS class to add to
|
||||
the completion dialog element.
|
||||
*/
|
||||
tooltipClass?: (state: EditorState) => string;
|
||||
/**
|
||||
This can be used to add additional CSS classes to completion
|
||||
options.
|
||||
*/
|
||||
optionClass?: (completion: Completion) => string;
|
||||
/**
|
||||
By default, the library will render icons based on the
|
||||
completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of
|
||||
each option. Set this to false to turn that off.
|
||||
*/
|
||||
icons?: boolean;
|
||||
/**
|
||||
This option can be used to inject additional content into
|
||||
options. The `render` function will be called for each visible
|
||||
completion, and should produce a DOM node to show. `position`
|
||||
determines where in the DOM the result appears, relative to
|
||||
other added widgets and the standard content. The default icons
|
||||
have position 20, the label position 50, and the detail position
|
||||
80.
|
||||
*/
|
||||
addToOptions?: {
|
||||
render: (completion: Completion, state: EditorState, view: EditorView) => Node | null;
|
||||
position: number;
|
||||
}[];
|
||||
/**
|
||||
By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are
|
||||
placed to the side of the selected completion. This option can
|
||||
be used to override that. It will be given rectangles for the
|
||||
list of completions, the selected option, the info element, and
|
||||
the availble [tooltip
|
||||
space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return
|
||||
style and/or class strings for the info element.
|
||||
*/
|
||||
positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => {
|
||||
style?: string;
|
||||
class?: string;
|
||||
};
|
||||
/**
|
||||
The comparison function to use when sorting completions with the same
|
||||
match score. Defaults to using
|
||||
[`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
|
||||
*/
|
||||
compareCompletions?: (a: Completion, b: Completion) => number;
|
||||
/**
|
||||
When set to true (the default is false), turn off fuzzy matching
|
||||
of completions and only show those that start with the text the
|
||||
user typed. Only takes effect for results where
|
||||
[`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false.
|
||||
*/
|
||||
filterStrict?: boolean;
|
||||
/**
|
||||
By default, commands relating to an open completion only take
|
||||
effect 75 milliseconds after the completion opened, so that key
|
||||
presses made before the user is aware of the tooltip don't go to
|
||||
the tooltip. This option can be used to configure that delay.
|
||||
*/
|
||||
interactionDelay?: number;
|
||||
/**
|
||||
When there are multiple asynchronous completion sources, this
|
||||
controls how long the extension waits for a slow source before
|
||||
displaying results from faster sources. Defaults to 100
|
||||
milliseconds.
|
||||
*/
|
||||
updateSyncTime?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a snippet template to a function that can
|
||||
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
|
||||
using syntax like this:
|
||||
|
||||
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
|
||||
|
||||
Each `${}` placeholder (you may also use `#{}`) indicates a field
|
||||
that the user can fill in. Its name, if any, will be the default
|
||||
content for the field.
|
||||
|
||||
When the snippet is activated by calling the returned function,
|
||||
the code is inserted at the given position. Newlines in the
|
||||
template are indented by the indentation of the start line, plus
|
||||
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
|
||||
the newline.
|
||||
|
||||
On activation, (all instances of) the first field are selected.
|
||||
The user can move between fields with Tab and Shift-Tab as long as
|
||||
the fields are active. Moving to the last field or moving the
|
||||
cursor out of the current field deactivates the fields.
|
||||
|
||||
The order of fields defaults to textual order, but you can add
|
||||
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
||||
a custom order.
|
||||
|
||||
To include a literal `{` or `}` in your template, put a backslash
|
||||
in front of it. This will be removed and the brace will not be
|
||||
interpreted as indicating a placeholder.
|
||||
*/
|
||||
declare function snippet(template: string): (editor: {
|
||||
state: EditorState;
|
||||
dispatch: (tr: Transaction) => void;
|
||||
}, completion: Completion | null, from: number, to: number) => void;
|
||||
/**
|
||||
A command that clears the active snippet, if any.
|
||||
*/
|
||||
declare const clearSnippet: StateCommand;
|
||||
/**
|
||||
Move to the next snippet field, if available.
|
||||
*/
|
||||
declare const nextSnippetField: StateCommand;
|
||||
/**
|
||||
Move to the previous snippet field, if available.
|
||||
*/
|
||||
declare const prevSnippetField: StateCommand;
|
||||
/**
|
||||
Check if there is an active snippet with a next field for
|
||||
`nextSnippetField` to move to.
|
||||
*/
|
||||
declare function hasNextSnippetField(state: EditorState): boolean;
|
||||
/**
|
||||
Returns true if there is an active snippet and a previous field
|
||||
for `prevSnippetField` to move to.
|
||||
*/
|
||||
declare function hasPrevSnippetField(state: EditorState): boolean;
|
||||
/**
|
||||
A facet that can be used to configure the key bindings used by
|
||||
snippets. The default binds Tab to
|
||||
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
|
||||
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
|
||||
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
|
||||
*/
|
||||
declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>;
|
||||
/**
|
||||
Create a completion from a snippet. Returns an object with the
|
||||
properties from `completion`, plus an `apply` function that
|
||||
applies the snippet.
|
||||
*/
|
||||
declare function snippetCompletion(template: string, completion: Completion): Completion;
|
||||
|
||||
/**
|
||||
Returns a command that moves the completion selection forward or
|
||||
backward by the given amount.
|
||||
*/
|
||||
declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command;
|
||||
/**
|
||||
Accept the current completion.
|
||||
*/
|
||||
declare const acceptCompletion: Command;
|
||||
/**
|
||||
Explicitly start autocompletion.
|
||||
*/
|
||||
declare const startCompletion: Command;
|
||||
/**
|
||||
Close the currently active completion.
|
||||
*/
|
||||
declare const closeCompletion: Command;
|
||||
|
||||
/**
|
||||
A completion source that will scan the document for words (using a
|
||||
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
|
||||
return those as completions.
|
||||
*/
|
||||
declare const completeAnyWord: CompletionSource;
|
||||
|
||||
/**
|
||||
Configures bracket closing behavior for a syntax (via
|
||||
[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"`
|
||||
identifier.
|
||||
*/
|
||||
interface CloseBracketConfig {
|
||||
/**
|
||||
The opening brackets to close. Defaults to `["(", "[", "{", "'",
|
||||
'"']`. Brackets may be single characters or a triple of quotes
|
||||
(as in `"'''"`).
|
||||
*/
|
||||
brackets?: string[];
|
||||
/**
|
||||
Characters in front of which newly opened brackets are
|
||||
automatically closed. Closing always happens in front of
|
||||
whitespace. Defaults to `")]}:;>"`.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When determining whether a given node may be a string, recognize
|
||||
these prefixes before the opening quote.
|
||||
*/
|
||||
stringPrefixes?: string[];
|
||||
}
|
||||
/**
|
||||
Extension to enable bracket-closing behavior. When a closeable
|
||||
bracket is typed, its closing bracket is immediately inserted
|
||||
after the cursor. When closing a bracket directly in front of a
|
||||
closing bracket inserted by the extension, the cursor moves over
|
||||
that bracket.
|
||||
*/
|
||||
declare function closeBrackets(): Extension;
|
||||
/**
|
||||
Command that implements deleting a pair of matching brackets when
|
||||
the cursor is between them.
|
||||
*/
|
||||
declare const deleteBracketPair: StateCommand;
|
||||
/**
|
||||
Close-brackets related key bindings. Binds Backspace to
|
||||
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
|
||||
*/
|
||||
declare const closeBracketsKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
Implements the extension's behavior on text insertion. If the
|
||||
given string counts as a bracket in the language around the
|
||||
selection, and replacing the selection with it requires custom
|
||||
behavior (inserting a closing version or skipping past a
|
||||
previously-closed bracket), this function returns a transaction
|
||||
representing that custom behavior. (You only need this if you want
|
||||
to programmatically insert brackets—the
|
||||
[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
|
||||
take care of running this for user input.)
|
||||
*/
|
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
|
||||
|
||||
/**
|
||||
Returns an extension that enables autocompletion.
|
||||
*/
|
||||
declare function autocompletion(config?: CompletionConfig): Extension;
|
||||
/**
|
||||
Basic keybindings for autocompletion.
|
||||
|
||||
- Ctrl-Space (and Alt-\` on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
|
||||
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
|
||||
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
|
||||
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
|
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
||||
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
||||
*/
|
||||
declare const completionKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
Get the current completion status. When completions are available,
|
||||
this will return `"active"`. When completions are pending (in the
|
||||
process of being queried), this returns `"pending"`. Otherwise, it
|
||||
returns `null`.
|
||||
*/
|
||||
declare function completionStatus(state: EditorState): null | "active" | "pending";
|
||||
/**
|
||||
Returns the available completions as an array.
|
||||
*/
|
||||
declare function currentCompletions(state: EditorState): readonly Completion[];
|
||||
/**
|
||||
Return the currently selected completion, if any.
|
||||
*/
|
||||
declare function selectedCompletion(state: EditorState): Completion | null;
|
||||
/**
|
||||
Returns the currently selected position in the active completion
|
||||
list, or null if no completions are active.
|
||||
*/
|
||||
declare function selectedCompletionIndex(state: EditorState): number | null;
|
||||
/**
|
||||
Create an effect that can be attached to a transaction to change
|
||||
the currently selected completion.
|
||||
*/
|
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>;
|
||||
|
||||
export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
639
node_modules/@codemirror/autocomplete/dist/index.d.ts
generated
vendored
Normal file
639
node_modules/@codemirror/autocomplete/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,639 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, ChangeDesc, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
|
||||
import { EditorView, Rect, KeyBinding, Command } from '@codemirror/view';
|
||||
import * as _lezer_common from '@lezer/common';
|
||||
|
||||
/**
|
||||
Objects type used to represent individual completions.
|
||||
*/
|
||||
interface Completion {
|
||||
/**
|
||||
The label to show in the completion picker. This is what input
|
||||
is matched against to determine whether a completion matches (and
|
||||
how well it matches).
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
An optional override for the completion's visible label. When
|
||||
using this, matched characters will only be highlighted if you
|
||||
provide a [`getMatch`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.getMatch)
|
||||
function.
|
||||
*/
|
||||
displayLabel?: string;
|
||||
/**
|
||||
An optional short piece of information to show (with a different
|
||||
style) after the label.
|
||||
*/
|
||||
detail?: string;
|
||||
/**
|
||||
Additional info to show when the completion is selected. Can be
|
||||
a plain string or a function that'll render the DOM structure to
|
||||
show when invoked.
|
||||
*/
|
||||
info?: string | ((completion: Completion) => CompletionInfo | Promise<CompletionInfo>);
|
||||
/**
|
||||
How to apply the completion. The default is to replace it with
|
||||
its [label](https://codemirror.net/6/docs/ref/#autocomplete.Completion.label). When this holds a
|
||||
string, the completion range is replaced by that string. When it
|
||||
is a function, that function is called to perform the
|
||||
completion. If it fires a transaction, it is responsible for
|
||||
adding the [`pickedCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.pickedCompletion)
|
||||
annotation to it.
|
||||
*/
|
||||
apply?: string | ((view: EditorView, completion: Completion, from: number, to: number) => void);
|
||||
/**
|
||||
The type of the completion. This is used to pick an icon to show
|
||||
for the completion. Icons are styled with a CSS class created by
|
||||
appending the type name to `"cm-completionIcon-"`. You can
|
||||
define or restyle icons by defining these selectors. The base
|
||||
library defines simple icons for `class`, `constant`, `enum`,
|
||||
`function`, `interface`, `keyword`, `method`, `namespace`,
|
||||
`property`, `text`, `type`, and `variable`.
|
||||
|
||||
Multiple types can be provided by separating them with spaces.
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
When this option is selected, and one of these characters is
|
||||
typed, insert the completion before typing the character.
|
||||
*/
|
||||
commitCharacters?: readonly string[];
|
||||
/**
|
||||
When given, should be a number from -99 to 99 that adjusts how
|
||||
this completion is ranked compared to other completions that
|
||||
match the input as well as this one. A negative number moves it
|
||||
down the list, a positive number moves it up.
|
||||
*/
|
||||
boost?: number;
|
||||
/**
|
||||
Can be used to divide the completion list into sections.
|
||||
Completions in a given section (matched by name) will be grouped
|
||||
together, with a heading above them. Options without section
|
||||
will appear above all sections. A string value is equivalent to
|
||||
a `{name}` object.
|
||||
*/
|
||||
section?: string | CompletionSection;
|
||||
}
|
||||
/**
|
||||
The type returned from
|
||||
[`Completion.info`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info). May be a DOM
|
||||
node, null to indicate there is no info, or an object with an
|
||||
optional `destroy` method that cleans up the node.
|
||||
*/
|
||||
type CompletionInfo = Node | null | {
|
||||
dom: Node;
|
||||
destroy?(): void;
|
||||
};
|
||||
/**
|
||||
Object used to describe a completion
|
||||
[section](https://codemirror.net/6/docs/ref/#autocomplete.Completion.section). It is recommended to
|
||||
create a shared object used by all the completions in a given
|
||||
section.
|
||||
*/
|
||||
interface CompletionSection {
|
||||
/**
|
||||
The name of the section. If no `render` method is present, this
|
||||
will be displayed above the options.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
An optional function that renders the section header. Since the
|
||||
headers are shown inside a list, you should make sure the
|
||||
resulting element has a `display: list-item` style.
|
||||
*/
|
||||
header?: (section: CompletionSection) => HTMLElement;
|
||||
/**
|
||||
By default, sections are ordered alphabetically by name. To
|
||||
specify an explicit order, `rank` can be used. Sections with a
|
||||
lower rank will be shown above sections with a higher rank.
|
||||
*/
|
||||
rank?: number;
|
||||
}
|
||||
/**
|
||||
An instance of this is passed to completion source functions.
|
||||
*/
|
||||
declare class CompletionContext {
|
||||
/**
|
||||
The editor state that the completion happens in.
|
||||
*/
|
||||
readonly state: EditorState;
|
||||
/**
|
||||
The position at which the completion is happening.
|
||||
*/
|
||||
readonly pos: number;
|
||||
/**
|
||||
Indicates whether completion was activated explicitly, or
|
||||
implicitly by typing. The usual way to respond to this is to
|
||||
only return completions when either there is part of a
|
||||
completable entity before the cursor, or `explicit` is true.
|
||||
*/
|
||||
readonly explicit: boolean;
|
||||
/**
|
||||
The editor view. May be undefined if the context was created
|
||||
in a situation where there is no such view available, such as
|
||||
in synchronous updates via
|
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code.
|
||||
*/
|
||||
readonly view?: EditorView | undefined;
|
||||
/**
|
||||
Create a new completion context. (Mostly useful for testing
|
||||
completion sources—in the editor, the extension will create
|
||||
these for you.)
|
||||
*/
|
||||
constructor(
|
||||
/**
|
||||
The editor state that the completion happens in.
|
||||
*/
|
||||
state: EditorState,
|
||||
/**
|
||||
The position at which the completion is happening.
|
||||
*/
|
||||
pos: number,
|
||||
/**
|
||||
Indicates whether completion was activated explicitly, or
|
||||
implicitly by typing. The usual way to respond to this is to
|
||||
only return completions when either there is part of a
|
||||
completable entity before the cursor, or `explicit` is true.
|
||||
*/
|
||||
explicit: boolean,
|
||||
/**
|
||||
The editor view. May be undefined if the context was created
|
||||
in a situation where there is no such view available, such as
|
||||
in synchronous updates via
|
||||
[`CompletionResult.update`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.update)
|
||||
or when called by test code.
|
||||
*/
|
||||
view?: EditorView | undefined);
|
||||
/**
|
||||
Get the extent, content, and (if there is a token) type of the
|
||||
token before `this.pos`.
|
||||
*/
|
||||
tokenBefore(types: readonly string[]): {
|
||||
from: number;
|
||||
to: number;
|
||||
text: string;
|
||||
type: _lezer_common.NodeType;
|
||||
} | null;
|
||||
/**
|
||||
Get the match of the given expression directly before the
|
||||
cursor.
|
||||
*/
|
||||
matchBefore(expr: RegExp): {
|
||||
from: number;
|
||||
to: number;
|
||||
text: string;
|
||||
} | null;
|
||||
/**
|
||||
Yields true when the query has been aborted. Can be useful in
|
||||
asynchronous queries to avoid doing work that will be ignored.
|
||||
*/
|
||||
get aborted(): boolean;
|
||||
/**
|
||||
Allows you to register abort handlers, which will be called when
|
||||
the query is
|
||||
[aborted](https://codemirror.net/6/docs/ref/#autocomplete.CompletionContext.aborted).
|
||||
|
||||
By default, running queries will not be aborted for regular
|
||||
typing or backspacing, on the assumption that they are likely to
|
||||
return a result with a
|
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor) field that
|
||||
allows the result to be used after all. Passing `onDocChange:
|
||||
true` will cause this query to be aborted for any document
|
||||
change.
|
||||
*/
|
||||
addEventListener(type: "abort", listener: () => void, options?: {
|
||||
onDocChange: boolean;
|
||||
}): void;
|
||||
}
|
||||
/**
|
||||
Given a a fixed array of options, return an autocompleter that
|
||||
completes them.
|
||||
*/
|
||||
declare function completeFromList(list: readonly (string | Completion)[]): CompletionSource;
|
||||
/**
|
||||
Wrap the given completion source so that it will only fire when the
|
||||
cursor is in a syntax node with one of the given names.
|
||||
*/
|
||||
declare function ifIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
||||
/**
|
||||
Wrap the given completion source so that it will not fire when the
|
||||
cursor is in a syntax node with one of the given names.
|
||||
*/
|
||||
declare function ifNotIn(nodes: readonly string[], source: CompletionSource): CompletionSource;
|
||||
/**
|
||||
The function signature for a completion source. Such a function
|
||||
may return its [result](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult)
|
||||
synchronously or as a promise. Returning null indicates no
|
||||
completions are available.
|
||||
*/
|
||||
type CompletionSource = (context: CompletionContext) => CompletionResult | null | Promise<CompletionResult | null>;
|
||||
/**
|
||||
Interface for objects returned by completion sources.
|
||||
*/
|
||||
interface CompletionResult {
|
||||
/**
|
||||
The start of the range that is being completed.
|
||||
*/
|
||||
from: number;
|
||||
/**
|
||||
The end of the range that is being completed. Defaults to the
|
||||
main cursor position.
|
||||
*/
|
||||
to?: number;
|
||||
/**
|
||||
The completions returned. These don't have to be compared with
|
||||
the input by the source—the autocompletion system will do its
|
||||
own matching (against the text between `from` and `to`) and
|
||||
sorting.
|
||||
*/
|
||||
options: readonly Completion[];
|
||||
/**
|
||||
When given, further typing or deletion that causes the part of
|
||||
the document between ([mapped](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) `from`
|
||||
and `to` to match this regular expression or predicate function
|
||||
will not query the completion source again, but continue with
|
||||
this list of options. This can help a lot with responsiveness,
|
||||
since it allows the completion list to be updated synchronously.
|
||||
*/
|
||||
validFor?: RegExp | ((text: string, from: number, to: number, state: EditorState) => boolean);
|
||||
/**
|
||||
By default, the library filters and scores completions. Set
|
||||
`filter` to `false` to disable this, and cause your completions
|
||||
to all be included, in the order they were given. When there are
|
||||
other sources, unfiltered completions appear at the top of the
|
||||
list of completions. `validFor` must not be given when `filter`
|
||||
is `false`, because it only works when filtering.
|
||||
*/
|
||||
filter?: boolean;
|
||||
/**
|
||||
When [`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) is set to
|
||||
`false` or a completion has a
|
||||
[`displayLabel`](https://codemirror.net/6/docs/ref/#autocomplete.Completion.displayLabel), this
|
||||
may be provided to compute the ranges on the label that match
|
||||
the input. Should return an array of numbers where each pair of
|
||||
adjacent numbers provide the start and end of a range. The
|
||||
second argument, the match found by the library, is only passed
|
||||
when `filter` isn't `false`.
|
||||
*/
|
||||
getMatch?: (completion: Completion, matched?: readonly number[]) => readonly number[];
|
||||
/**
|
||||
Synchronously update the completion result after typing or
|
||||
deletion. If given, this should not do any expensive work, since
|
||||
it will be called during editor state updates. The function
|
||||
should make sure (similar to
|
||||
[`validFor`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.validFor)) that the
|
||||
completion still applies in the new state.
|
||||
*/
|
||||
update?: (current: CompletionResult, from: number, to: number, context: CompletionContext) => CompletionResult | null;
|
||||
/**
|
||||
When results contain position-dependent information in, for
|
||||
example, `apply` methods, you can provide this method to update
|
||||
the result for transactions that happen after the query. It is
|
||||
not necessary to update `from` and `to`—those are tracked
|
||||
automatically.
|
||||
*/
|
||||
map?: (current: CompletionResult, changes: ChangeDesc) => CompletionResult | null;
|
||||
/**
|
||||
Set a default set of [commit
|
||||
characters](https://codemirror.net/6/docs/ref/#autocomplete.Completion.commitCharacters) for all
|
||||
options in this result.
|
||||
*/
|
||||
commitCharacters?: readonly string[];
|
||||
}
|
||||
/**
|
||||
This annotation is added to transactions that are produced by
|
||||
picking a completion.
|
||||
*/
|
||||
declare const pickedCompletion: _codemirror_state.AnnotationType<Completion>;
|
||||
/**
|
||||
Helper function that returns a transaction spec which inserts a
|
||||
completion's text in the main selection range, and any other
|
||||
selection range that has the same text in front of it.
|
||||
*/
|
||||
declare function insertCompletionText(state: EditorState, text: string, from: number, to: number): TransactionSpec;
|
||||
|
||||
interface CompletionConfig {
|
||||
/**
|
||||
When enabled (defaults to true), autocompletion will start
|
||||
whenever the user types something that can be completed.
|
||||
*/
|
||||
activateOnTyping?: boolean;
|
||||
/**
|
||||
When given, if a completion that matches the predicate is
|
||||
picked, reactivate completion again as if it was typed normally.
|
||||
*/
|
||||
activateOnCompletion?: (completion: Completion) => boolean;
|
||||
/**
|
||||
The amount of time to wait for further typing before querying
|
||||
completion sources via
|
||||
[`activateOnTyping`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.activateOnTyping).
|
||||
Defaults to 100, which should be fine unless your completion
|
||||
source is very slow and/or doesn't use `validFor`.
|
||||
*/
|
||||
activateOnTypingDelay?: number;
|
||||
/**
|
||||
By default, when completion opens, the first option is selected
|
||||
and can be confirmed with
|
||||
[`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion). When this
|
||||
is set to false, the completion widget starts with no completion
|
||||
selected, and the user has to explicitly move to a completion
|
||||
before you can confirm one.
|
||||
*/
|
||||
selectOnOpen?: boolean;
|
||||
/**
|
||||
Override the completion sources used. By default, they will be
|
||||
taken from the `"autocomplete"` [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) (which should hold
|
||||
[completion sources](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) or arrays
|
||||
of [completions](https://codemirror.net/6/docs/ref/#autocomplete.Completion)).
|
||||
*/
|
||||
override?: readonly CompletionSource[] | null;
|
||||
/**
|
||||
Determines whether the completion tooltip is closed when the
|
||||
editor loses focus. Defaults to true.
|
||||
*/
|
||||
closeOnBlur?: boolean;
|
||||
/**
|
||||
The maximum number of options to render to the DOM.
|
||||
*/
|
||||
maxRenderedOptions?: number;
|
||||
/**
|
||||
Set this to false to disable the [default completion
|
||||
keymap](https://codemirror.net/6/docs/ref/#autocomplete.completionKeymap). (This requires you to
|
||||
add bindings to control completion yourself. The bindings should
|
||||
probably have a higher precedence than other bindings for the
|
||||
same keys.)
|
||||
*/
|
||||
defaultKeymap?: boolean;
|
||||
/**
|
||||
By default, completions are shown below the cursor when there is
|
||||
space. Setting this to true will make the extension put the
|
||||
completions above the cursor when possible.
|
||||
*/
|
||||
aboveCursor?: boolean;
|
||||
/**
|
||||
When given, this may return an additional CSS class to add to
|
||||
the completion dialog element.
|
||||
*/
|
||||
tooltipClass?: (state: EditorState) => string;
|
||||
/**
|
||||
This can be used to add additional CSS classes to completion
|
||||
options.
|
||||
*/
|
||||
optionClass?: (completion: Completion) => string;
|
||||
/**
|
||||
By default, the library will render icons based on the
|
||||
completion's [type](https://codemirror.net/6/docs/ref/#autocomplete.Completion.type) in front of
|
||||
each option. Set this to false to turn that off.
|
||||
*/
|
||||
icons?: boolean;
|
||||
/**
|
||||
This option can be used to inject additional content into
|
||||
options. The `render` function will be called for each visible
|
||||
completion, and should produce a DOM node to show. `position`
|
||||
determines where in the DOM the result appears, relative to
|
||||
other added widgets and the standard content. The default icons
|
||||
have position 20, the label position 50, and the detail position
|
||||
80.
|
||||
*/
|
||||
addToOptions?: {
|
||||
render: (completion: Completion, state: EditorState, view: EditorView) => Node | null;
|
||||
position: number;
|
||||
}[];
|
||||
/**
|
||||
By default, [info](https://codemirror.net/6/docs/ref/#autocomplete.Completion.info) tooltips are
|
||||
placed to the side of the selected completion. This option can
|
||||
be used to override that. It will be given rectangles for the
|
||||
list of completions, the selected option, the info element, and
|
||||
the availble [tooltip
|
||||
space](https://codemirror.net/6/docs/ref/#view.tooltips^config.tooltipSpace), and should return
|
||||
style and/or class strings for the info element.
|
||||
*/
|
||||
positionInfo?: (view: EditorView, list: Rect, option: Rect, info: Rect, space: Rect) => {
|
||||
style?: string;
|
||||
class?: string;
|
||||
};
|
||||
/**
|
||||
The comparison function to use when sorting completions with the same
|
||||
match score. Defaults to using
|
||||
[`localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare).
|
||||
*/
|
||||
compareCompletions?: (a: Completion, b: Completion) => number;
|
||||
/**
|
||||
When set to true (the default is false), turn off fuzzy matching
|
||||
of completions and only show those that start with the text the
|
||||
user typed. Only takes effect for results where
|
||||
[`filter`](https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult.filter) isn't false.
|
||||
*/
|
||||
filterStrict?: boolean;
|
||||
/**
|
||||
By default, commands relating to an open completion only take
|
||||
effect 75 milliseconds after the completion opened, so that key
|
||||
presses made before the user is aware of the tooltip don't go to
|
||||
the tooltip. This option can be used to configure that delay.
|
||||
*/
|
||||
interactionDelay?: number;
|
||||
/**
|
||||
When there are multiple asynchronous completion sources, this
|
||||
controls how long the extension waits for a slow source before
|
||||
displaying results from faster sources. Defaults to 100
|
||||
milliseconds.
|
||||
*/
|
||||
updateSyncTime?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a snippet template to a function that can
|
||||
[apply](https://codemirror.net/6/docs/ref/#autocomplete.Completion.apply) it. Snippets are written
|
||||
using syntax like this:
|
||||
|
||||
"for (let ${index} = 0; ${index} < ${end}; ${index}++) {\n\t${}\n}"
|
||||
|
||||
Each `${}` placeholder (you may also use `#{}`) indicates a field
|
||||
that the user can fill in. Its name, if any, will be the default
|
||||
content for the field.
|
||||
|
||||
When the snippet is activated by calling the returned function,
|
||||
the code is inserted at the given position. Newlines in the
|
||||
template are indented by the indentation of the start line, plus
|
||||
one [indent unit](https://codemirror.net/6/docs/ref/#language.indentUnit) per tab character after
|
||||
the newline.
|
||||
|
||||
On activation, (all instances of) the first field are selected.
|
||||
The user can move between fields with Tab and Shift-Tab as long as
|
||||
the fields are active. Moving to the last field or moving the
|
||||
cursor out of the current field deactivates the fields.
|
||||
|
||||
The order of fields defaults to textual order, but you can add
|
||||
numbers to placeholders (`${1}` or `${1:defaultText}`) to provide
|
||||
a custom order.
|
||||
|
||||
To include a literal `{` or `}` in your template, put a backslash
|
||||
in front of it. This will be removed and the brace will not be
|
||||
interpreted as indicating a placeholder.
|
||||
*/
|
||||
declare function snippet(template: string): (editor: {
|
||||
state: EditorState;
|
||||
dispatch: (tr: Transaction) => void;
|
||||
}, completion: Completion | null, from: number, to: number) => void;
|
||||
/**
|
||||
A command that clears the active snippet, if any.
|
||||
*/
|
||||
declare const clearSnippet: StateCommand;
|
||||
/**
|
||||
Move to the next snippet field, if available.
|
||||
*/
|
||||
declare const nextSnippetField: StateCommand;
|
||||
/**
|
||||
Move to the previous snippet field, if available.
|
||||
*/
|
||||
declare const prevSnippetField: StateCommand;
|
||||
/**
|
||||
Check if there is an active snippet with a next field for
|
||||
`nextSnippetField` to move to.
|
||||
*/
|
||||
declare function hasNextSnippetField(state: EditorState): boolean;
|
||||
/**
|
||||
Returns true if there is an active snippet and a previous field
|
||||
for `prevSnippetField` to move to.
|
||||
*/
|
||||
declare function hasPrevSnippetField(state: EditorState): boolean;
|
||||
/**
|
||||
A facet that can be used to configure the key bindings used by
|
||||
snippets. The default binds Tab to
|
||||
[`nextSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.nextSnippetField), Shift-Tab to
|
||||
[`prevSnippetField`](https://codemirror.net/6/docs/ref/#autocomplete.prevSnippetField), and Escape
|
||||
to [`clearSnippet`](https://codemirror.net/6/docs/ref/#autocomplete.clearSnippet).
|
||||
*/
|
||||
declare const snippetKeymap: Facet<readonly KeyBinding[], readonly KeyBinding[]>;
|
||||
/**
|
||||
Create a completion from a snippet. Returns an object with the
|
||||
properties from `completion`, plus an `apply` function that
|
||||
applies the snippet.
|
||||
*/
|
||||
declare function snippetCompletion(template: string, completion: Completion): Completion;
|
||||
|
||||
/**
|
||||
Returns a command that moves the completion selection forward or
|
||||
backward by the given amount.
|
||||
*/
|
||||
declare function moveCompletionSelection(forward: boolean, by?: "option" | "page"): Command;
|
||||
/**
|
||||
Accept the current completion.
|
||||
*/
|
||||
declare const acceptCompletion: Command;
|
||||
/**
|
||||
Explicitly start autocompletion.
|
||||
*/
|
||||
declare const startCompletion: Command;
|
||||
/**
|
||||
Close the currently active completion.
|
||||
*/
|
||||
declare const closeCompletion: Command;
|
||||
|
||||
/**
|
||||
A completion source that will scan the document for words (using a
|
||||
[character categorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer)), and
|
||||
return those as completions.
|
||||
*/
|
||||
declare const completeAnyWord: CompletionSource;
|
||||
|
||||
/**
|
||||
Configures bracket closing behavior for a syntax (via
|
||||
[language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt)) using the `"closeBrackets"`
|
||||
identifier.
|
||||
*/
|
||||
interface CloseBracketConfig {
|
||||
/**
|
||||
The opening brackets to close. Defaults to `["(", "[", "{", "'",
|
||||
'"']`. Brackets may be single characters or a triple of quotes
|
||||
(as in `"'''"`).
|
||||
*/
|
||||
brackets?: string[];
|
||||
/**
|
||||
Characters in front of which newly opened brackets are
|
||||
automatically closed. Closing always happens in front of
|
||||
whitespace. Defaults to `")]}:;>"`.
|
||||
*/
|
||||
before?: string;
|
||||
/**
|
||||
When determining whether a given node may be a string, recognize
|
||||
these prefixes before the opening quote.
|
||||
*/
|
||||
stringPrefixes?: string[];
|
||||
}
|
||||
/**
|
||||
Extension to enable bracket-closing behavior. When a closeable
|
||||
bracket is typed, its closing bracket is immediately inserted
|
||||
after the cursor. When closing a bracket directly in front of a
|
||||
closing bracket inserted by the extension, the cursor moves over
|
||||
that bracket.
|
||||
*/
|
||||
declare function closeBrackets(): Extension;
|
||||
/**
|
||||
Command that implements deleting a pair of matching brackets when
|
||||
the cursor is between them.
|
||||
*/
|
||||
declare const deleteBracketPair: StateCommand;
|
||||
/**
|
||||
Close-brackets related key bindings. Binds Backspace to
|
||||
[`deleteBracketPair`](https://codemirror.net/6/docs/ref/#autocomplete.deleteBracketPair).
|
||||
*/
|
||||
declare const closeBracketsKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
Implements the extension's behavior on text insertion. If the
|
||||
given string counts as a bracket in the language around the
|
||||
selection, and replacing the selection with it requires custom
|
||||
behavior (inserting a closing version or skipping past a
|
||||
previously-closed bracket), this function returns a transaction
|
||||
representing that custom behavior. (You only need this if you want
|
||||
to programmatically insert brackets—the
|
||||
[`closeBrackets`](https://codemirror.net/6/docs/ref/#autocomplete.closeBrackets) extension will
|
||||
take care of running this for user input.)
|
||||
*/
|
||||
declare function insertBracket(state: EditorState, bracket: string): Transaction | null;
|
||||
|
||||
/**
|
||||
Returns an extension that enables autocompletion.
|
||||
*/
|
||||
declare function autocompletion(config?: CompletionConfig): Extension;
|
||||
/**
|
||||
Basic keybindings for autocompletion.
|
||||
|
||||
- Ctrl-Space (and Alt-\` on macOS): [`startCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.startCompletion)
|
||||
- Escape: [`closeCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.closeCompletion)
|
||||
- ArrowDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true)`
|
||||
- ArrowUp: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(false)`
|
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
||||
- PageDown: [`moveCompletionSelection`](https://codemirror.net/6/docs/ref/#autocomplete.moveCompletionSelection)`(true, "page")`
|
||||
- Enter: [`acceptCompletion`](https://codemirror.net/6/docs/ref/#autocomplete.acceptCompletion)
|
||||
*/
|
||||
declare const completionKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
Get the current completion status. When completions are available,
|
||||
this will return `"active"`. When completions are pending (in the
|
||||
process of being queried), this returns `"pending"`. Otherwise, it
|
||||
returns `null`.
|
||||
*/
|
||||
declare function completionStatus(state: EditorState): null | "active" | "pending";
|
||||
/**
|
||||
Returns the available completions as an array.
|
||||
*/
|
||||
declare function currentCompletions(state: EditorState): readonly Completion[];
|
||||
/**
|
||||
Return the currently selected completion, if any.
|
||||
*/
|
||||
declare function selectedCompletion(state: EditorState): Completion | null;
|
||||
/**
|
||||
Returns the currently selected position in the active completion
|
||||
list, or null if no completions are active.
|
||||
*/
|
||||
declare function selectedCompletionIndex(state: EditorState): number | null;
|
||||
/**
|
||||
Create an effect that can be attached to a transaction to change
|
||||
the currently selected completion.
|
||||
*/
|
||||
declare function setSelectedCompletion(index: number): StateEffect<unknown>;
|
||||
|
||||
export { type CloseBracketConfig, type Completion, CompletionContext, type CompletionInfo, type CompletionResult, type CompletionSection, type CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, hasNextSnippetField, hasPrevSnippetField, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
||||
2079
node_modules/@codemirror/autocomplete/dist/index.js
generated
vendored
Normal file
2079
node_modules/@codemirror/autocomplete/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
41
node_modules/@codemirror/autocomplete/package.json
generated
vendored
Normal file
41
node_modules/@codemirror/autocomplete/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "@codemirror/autocomplete",
|
||||
"version": "6.18.6",
|
||||
"description": "Autocompletion for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/autocomplete.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/commands/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/commands/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
346
node_modules/@codemirror/commands/CHANGELOG.md
generated
vendored
Normal file
346
node_modules/@codemirror/commands/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,346 @@
|
||||
## 6.8.0 (2025-01-08)
|
||||
|
||||
### New features
|
||||
|
||||
The new `cursorGroupForwardWin` and `selectGroupForwardWin` commands implement Windows-style forward motion by group.
|
||||
|
||||
## 6.7.1 (2024-10-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Change `toggleBlockCommentByLine` to not affect lines with the selection end right at their start.
|
||||
|
||||
## 6.7.0 (2024-10-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Bind Shift-Enter to the same command as Enter in the default keymap, so that it doesn't do nothing when on an EditContext-supporting browser.
|
||||
|
||||
### New features
|
||||
|
||||
Add commands for by-string-index cursor motion that ignores text direction.
|
||||
|
||||
## 6.6.2 (2024-09-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue causing `selectParentSyntax` to not select syntax that is a direct child of the top node.
|
||||
|
||||
Make `selectParentSyntax` return false when it doesn't change the selection.
|
||||
|
||||
## 6.6.1 (2024-08-31)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in the undo history that would cause it to incorrectly track inverted effects when adding multiple edits to a single history event.
|
||||
|
||||
## 6.6.0 (2024-06-04)
|
||||
|
||||
### New features
|
||||
|
||||
The new `toggleTabFocusMode` and `temporarilySetTabFocusMode` commands provide control over the view's tab-focus mode.
|
||||
|
||||
The default keymap now binds Ctrl-m (Shift-Alt-m on macOS) to `toggleTabFocusMode`.
|
||||
|
||||
## 6.5.0 (2024-04-19)
|
||||
|
||||
### New features
|
||||
|
||||
The `insertNewlineKeepIndent` command inserts a newline along with the same indentation as the line before.
|
||||
|
||||
## 6.4.0 (2024-04-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `deleteLine` sometimes leaves the cursor on the wrong line.
|
||||
|
||||
### New features
|
||||
|
||||
The new `deleteCharBackwardStrict` command just deletes a character, without further smart behavior around indentation.
|
||||
|
||||
## 6.3.3 (2023-12-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue causing cursor motion commands to not dispatch a transaction when the change only affects cursor associativity.
|
||||
|
||||
## 6.3.2 (2023-11-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression that caused `deleteCharBackward` to sometimes delete a large chunk of text.
|
||||
|
||||
## 6.3.1 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When undoing, store the selection after the undone change with the redo event, so that redoing restores it.
|
||||
|
||||
`deleteCharBackward` will no longer delete variant selector characters as separate characters.
|
||||
|
||||
## 6.3.0 (2023-09-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make it possible for `selectParentSyntax` to jump out of or into a syntax tree overlay.
|
||||
|
||||
Make Cmd-Backspace and Cmd-Delete on macOS delete to the next line wrap point, not the start/end of the line.
|
||||
|
||||
### New features
|
||||
|
||||
The new `deleteLineBoundaryForward` and `deleteLineBoundaryBackward` commands delete to the start/end of the line or the next line wrapping point.
|
||||
|
||||
## 6.2.5 (2023-08-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `insertNewlineAndIndent` properly count indentation for tabs when copying over the previous line's indentation.
|
||||
|
||||
The various sub-word motion commands will now use `Intl.Segmenter`, when available, to stop at CJK language word boundaries.
|
||||
|
||||
Fix a bug in `insertNewlineAndIndent` that would delete text between brackets if it had no corresponding AST node.
|
||||
|
||||
## 6.2.4 (2023-05-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The by-subword motion commands now properly treat dashes, underscores, and similar as subword separators.
|
||||
|
||||
## 6.2.3 (2023-04-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Block commenting the selection no longer includes indentation on the first line.
|
||||
|
||||
## 6.2.2 (2023-03-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where line commenting got confused when commenting a range that crossed language boundaries.
|
||||
|
||||
## 6.2.1 (2023-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Keep cursor position stable in `cursorPageUp`/`cursorPageDown` when there are panels or other scroll margins active.
|
||||
|
||||
Make sure `toggleComment` doesn't get thrown off by local language nesting, by fetching the language data for the start of the selection line.
|
||||
|
||||
## 6.2.0 (2023-01-18)
|
||||
|
||||
### New features
|
||||
|
||||
The new `joinToEvent` history configuration option allows you to provide custom logic that determines whether a new transaction is added to an existing history event.
|
||||
|
||||
## 6.1.3 (2022-12-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Preserve selection bidi level when extending the selection, to prevent shift-selection from getting stuck in some kinds of bidirectional text.
|
||||
|
||||
## 6.1.2 (2022-10-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused deletion commands on non-empty ranges to incorrectly return false and do nothing, causing the editor to fall back to native behavior.
|
||||
|
||||
## 6.1.1 (2022-09-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the selection endpoints are moved out of atomic ranges when applying a deletion command to a non-empty selection.
|
||||
|
||||
## 6.1.0 (2022-08-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Prevent native behavior on Ctrl/Cmd-ArrowLeft/ArrowRight bindings, so that browsers with odd bidi behavior won't do the wrong thing at start/end of line.
|
||||
|
||||
Cmd-ArrowLeft/Right on macOS now moves the cursor in the direction of the arrow even in right-to-left content.
|
||||
|
||||
### New features
|
||||
|
||||
The new `cursorLineBoundaryLeft`/`Right` and `selectLineBoundaryLeft`/`Right` commands allow directional motion to line boundaries.
|
||||
|
||||
## 6.0.1 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Announce to the screen reader when the selection is deleted.
|
||||
|
||||
Also bind Ctrl-Shift-z to redo on Linux.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where by-page selection commands sometimes moved one line too far.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
There is no longer a separate `commentKeymap`. Those bindings are now part of `defaultKeymap`.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `cursorPageUp` and `cursorPageDown` move by window height when the editor is higher than the window.
|
||||
|
||||
Make sure the default behavior of Home/End is prevented, since it could produce unexpected results on macOS.
|
||||
|
||||
### New features
|
||||
|
||||
The exports from @codemirror/comment are now available in this package.
|
||||
|
||||
The exports from the @codemirror/history package are now available from this package.
|
||||
|
||||
## 0.19.8 (2022-01-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`deleteCharBackward` now removes extending characters one at a time, rather than deleting the entire glyph at once.
|
||||
|
||||
Alt-v is no longer bound in `emacsStyleKeymap` and macOS's `standardKeymap`, because macOS doesn't bind it by default and it conflicts with some keyboard layouts.
|
||||
|
||||
## 0.19.7 (2022-01-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't bind Alt-\< and Alt-> on macOS by default, since those interfere with some keyboard layouts. Make cursorPageUp/Down scroll the view to keep the cursor in place
|
||||
|
||||
`cursorPageUp` and `cursorPageDown` now scroll the view by the amount that the cursor moved.
|
||||
|
||||
## 0.19.6 (2021-12-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The standard keymap no longer overrides Shift-Delete, in order to allow the native behavior of that key to happen on platforms that support it.
|
||||
|
||||
## 0.19.5 (2021-09-21)
|
||||
|
||||
### New features
|
||||
|
||||
Adds an `insertBlankLine` command which creates an empty line below the selection, and binds it to Mod-Enter in the default keymap.
|
||||
|
||||
## 0.19.4 (2021-09-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make commands that affect the editor's content check `state.readOnly` and return false when that is true.
|
||||
|
||||
## 0.19.3 (2021-09-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make by-line cursor motion commands move the cursor to the start/end of the document when they hit the first/last line.
|
||||
|
||||
Fix a bug where `deleteCharForward`/`Backward` behaved incorrectly when deleting directly before or after an atomic range.
|
||||
|
||||
## 0.19.2 (2021-08-24)
|
||||
|
||||
### New features
|
||||
|
||||
New commands `cursorSubwordForward`, `cursorSubwordBackward`, `selectSubwordForward`, and `selectSubwordBackward` which implement motion by camel case subword.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Change default binding for backspace to `deleteCharBackward`, drop `deleteCodePointBackward`/`Forward` from the library.
|
||||
|
||||
`defaultTabBinding` was removed.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Drop Alt-d, Alt-f, and Alt-b bindings from `emacsStyleKeymap` (and thus from the default macOS bindings).
|
||||
|
||||
`deleteCharBackward` and `deleteCharForward` now take atomic ranges into account.
|
||||
|
||||
### New features
|
||||
|
||||
Attach more granular user event strings to transactions.
|
||||
|
||||
The module exports a new binding `indentWithTab` that binds tab and shift-tab to `indentMore` and `indentLess`.
|
||||
|
||||
## 0.18.3 (2021-06-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`moveLineDown` will no longer incorrectly grow the selection.
|
||||
|
||||
Line-based commands will no longer include lines where a range selection ends right at the start of the line.
|
||||
|
||||
## 0.18.2 (2021-05-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use Ctrl-l, not Alt-l, to bind `selectLine` on macOS, to avoid conflicting with special-character-insertion bindings.
|
||||
|
||||
Make the macOS Command-ArrowLeft/Right commands behave more like their native versions.
|
||||
|
||||
## 0.18.1 (2021-04-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Also bind Shift-Backspace and Shift-Delete in the default keymap (to do the same thing as the Shift-less binding).
|
||||
|
||||
### New features
|
||||
|
||||
Adds a `deleteToLineStart` command.
|
||||
|
||||
Adds bindings for Cmd-Delete and Cmd-Backspace on macOS.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
## 0.17.5 (2021-02-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use Alt-l for the default `selectLine` binding, because Mod-l already has an important meaning in the browser.
|
||||
|
||||
Make `deleteGroupBackward`/`deleteGroupForward` delete groups of whitespace when bigger than a single space.
|
||||
|
||||
Don't change lines that have the end of a range selection directly at their start in `indentLess`, `indentMore`, and `indentSelection`.
|
||||
|
||||
## 0.17.4 (2021-02-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `deleteToLineEnd` would delete the rest of the document when at the end of a line.
|
||||
|
||||
## 0.17.3 (2021-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `insertNewlineAndIndent` behaved strangely with the cursor between brackets that sat on different lines.
|
||||
|
||||
## 0.17.2 (2021-01-22)
|
||||
|
||||
### New features
|
||||
|
||||
The new `insertTab` command inserts a tab when nothing is selected, and defers to `indentMore` otherwise.
|
||||
|
||||
The package now exports a `defaultTabBinding` object that provides a recommended binding for tab (if you must bind tab).
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/commands/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/commands/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
35
node_modules/@codemirror/commands/README.md
generated
vendored
Normal file
35
node_modules/@codemirror/commands/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# @codemirror/commands [](https://www.npmjs.org/package/@codemirror/commands)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/commands/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements a collection of editing commands for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/commands/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {EditorView, keymap} from "@codemirror/view"
|
||||
import {standardKeymap, selectLine} from "@codemirror/commands"
|
||||
|
||||
const view = new EditorView({
|
||||
parent: document.body,
|
||||
extensions: [
|
||||
keymap.of([
|
||||
...standardKeymap,
|
||||
{key: "Alt-l", mac: "Ctrl-l", run: selectLine}
|
||||
])
|
||||
]
|
||||
})
|
||||
```
|
||||
1852
node_modules/@codemirror/commands/dist/index.cjs
generated
vendored
Normal file
1852
node_modules/@codemirror/commands/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
632
node_modules/@codemirror/commands/dist/index.d.cts
generated
vendored
Normal file
632
node_modules/@codemirror/commands/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,632 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state';
|
||||
import { KeyBinding, Command } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
An object of this type can be provided as [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"`
|
||||
property to configure comment syntax for a language.
|
||||
*/
|
||||
interface CommentTokens {
|
||||
/**
|
||||
The block comment syntax, if any. For example, for HTML
|
||||
you'd provide `{open: "<!--", close: "-->"}`.
|
||||
*/
|
||||
block?: {
|
||||
open: string;
|
||||
close: string;
|
||||
};
|
||||
/**
|
||||
The line comment syntax. For example `"//"`.
|
||||
*/
|
||||
line?: string;
|
||||
}
|
||||
/**
|
||||
Comment or uncomment the current selection. Will use line comments
|
||||
if available, otherwise falling back to block comments.
|
||||
*/
|
||||
declare const toggleComment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the current selection using line comments.
|
||||
The line comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
declare const toggleLineComment: StateCommand;
|
||||
/**
|
||||
Comment the current selection using line comments.
|
||||
*/
|
||||
declare const lineComment: StateCommand;
|
||||
/**
|
||||
Uncomment the current selection using line comments.
|
||||
*/
|
||||
declare const lineUncomment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the current selection using block comments.
|
||||
The block comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
declare const toggleBlockComment: StateCommand;
|
||||
/**
|
||||
Comment the current selection using block comments.
|
||||
*/
|
||||
declare const blockComment: StateCommand;
|
||||
/**
|
||||
Uncomment the current selection using block comments.
|
||||
*/
|
||||
declare const blockUncomment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the lines around the current selection using
|
||||
block comments.
|
||||
*/
|
||||
declare const toggleBlockCommentByLine: StateCommand;
|
||||
|
||||
/**
|
||||
Transaction annotation that will prevent that transaction from
|
||||
being combined with other transactions in the undo history. Given
|
||||
`"before"`, it'll prevent merging with previous transactions. With
|
||||
`"after"`, subsequent transactions won't be combined with this
|
||||
one. With `"full"`, the transaction is isolated on both sides.
|
||||
*/
|
||||
declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">;
|
||||
/**
|
||||
This facet provides a way to register functions that, given a
|
||||
transaction, provide a set of effects that the history should
|
||||
store when inverting the transaction. This can be used to
|
||||
integrate some kinds of effects in the history, so that they can
|
||||
be undone (and redone again).
|
||||
*/
|
||||
declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect<any>[], readonly ((tr: Transaction) => readonly StateEffect<any>[])[]>;
|
||||
interface HistoryConfig {
|
||||
/**
|
||||
The minimum depth (amount of events) to store. Defaults to 100.
|
||||
*/
|
||||
minDepth?: number;
|
||||
/**
|
||||
The maximum time (in milliseconds) that adjacent events can be
|
||||
apart and still be grouped together. Defaults to 500.
|
||||
*/
|
||||
newGroupDelay?: number;
|
||||
/**
|
||||
By default, when close enough together in time, changes are
|
||||
joined into an existing undo event if they touch any of the
|
||||
changed ranges from that event. You can pass a custom predicate
|
||||
here to influence that logic.
|
||||
*/
|
||||
joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean;
|
||||
}
|
||||
/**
|
||||
Create a history extension with the given configuration.
|
||||
*/
|
||||
declare function history(config?: HistoryConfig): Extension;
|
||||
/**
|
||||
The state field used to store the history data. Should probably
|
||||
only be used when you want to
|
||||
[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or
|
||||
[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way
|
||||
that preserves history.
|
||||
*/
|
||||
declare const historyField: StateField<unknown>;
|
||||
/**
|
||||
Undo a single group of history events. Returns false if no group
|
||||
was available.
|
||||
*/
|
||||
declare const undo: StateCommand;
|
||||
/**
|
||||
Redo a group of history events. Returns false if no group was
|
||||
available.
|
||||
*/
|
||||
declare const redo: StateCommand;
|
||||
/**
|
||||
Undo a change or selection change.
|
||||
*/
|
||||
declare const undoSelection: StateCommand;
|
||||
/**
|
||||
Redo a change or selection change.
|
||||
*/
|
||||
declare const redoSelection: StateCommand;
|
||||
/**
|
||||
The amount of undoable change events available in a given state.
|
||||
*/
|
||||
declare const undoDepth: (state: EditorState) => number;
|
||||
/**
|
||||
The amount of redoable change events available in a given state.
|
||||
*/
|
||||
declare const redoDepth: (state: EditorState) => number;
|
||||
/**
|
||||
Default key bindings for the undo history.
|
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/
|
||||
declare const historyKeymap: readonly KeyBinding[];
|
||||
|
||||
/**
|
||||
Move the selection one character to the left (which is backward in
|
||||
left-to-right text, forward in right-to-left text).
|
||||
*/
|
||||
declare const cursorCharLeft: Command;
|
||||
/**
|
||||
Move the selection one character to the right.
|
||||
*/
|
||||
declare const cursorCharRight: Command;
|
||||
/**
|
||||
Move the selection one character forward.
|
||||
*/
|
||||
declare const cursorCharForward: Command;
|
||||
/**
|
||||
Move the selection one character backward.
|
||||
*/
|
||||
declare const cursorCharBackward: Command;
|
||||
/**
|
||||
Move the selection one character forward, in logical
|
||||
(non-text-direction-aware) string index order.
|
||||
*/
|
||||
declare const cursorCharForwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection one character backward, in logical string index
|
||||
order.
|
||||
*/
|
||||
declare const cursorCharBackwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection to the left across one group of word or
|
||||
non-word (but also non-space) characters.
|
||||
*/
|
||||
declare const cursorGroupLeft: Command;
|
||||
/**
|
||||
Move the selection one group to the right.
|
||||
*/
|
||||
declare const cursorGroupRight: Command;
|
||||
/**
|
||||
Move the selection one group forward.
|
||||
*/
|
||||
declare const cursorGroupForward: Command;
|
||||
/**
|
||||
Move the selection one group backward.
|
||||
*/
|
||||
declare const cursorGroupBackward: Command;
|
||||
/**
|
||||
Move the cursor one group forward in the default Windows style,
|
||||
where it moves to the start of the next group.
|
||||
*/
|
||||
declare const cursorGroupForwardWin: Command;
|
||||
/**
|
||||
Move the selection one group or camel-case subword forward.
|
||||
*/
|
||||
declare const cursorSubwordForward: Command;
|
||||
/**
|
||||
Move the selection one group or camel-case subword backward.
|
||||
*/
|
||||
declare const cursorSubwordBackward: Command;
|
||||
/**
|
||||
Move the cursor over the next syntactic element to the left.
|
||||
*/
|
||||
declare const cursorSyntaxLeft: Command;
|
||||
/**
|
||||
Move the cursor over the next syntactic element to the right.
|
||||
*/
|
||||
declare const cursorSyntaxRight: Command;
|
||||
/**
|
||||
Move the selection one line up.
|
||||
*/
|
||||
declare const cursorLineUp: Command;
|
||||
/**
|
||||
Move the selection one line down.
|
||||
*/
|
||||
declare const cursorLineDown: Command;
|
||||
/**
|
||||
Move the selection one page up.
|
||||
*/
|
||||
declare const cursorPageUp: Command;
|
||||
/**
|
||||
Move the selection one page down.
|
||||
*/
|
||||
declare const cursorPageDown: Command;
|
||||
/**
|
||||
Move the selection to the next line wrap point, or to the end of
|
||||
the line if there isn't one left on this line.
|
||||
*/
|
||||
declare const cursorLineBoundaryForward: Command;
|
||||
/**
|
||||
Move the selection to previous line wrap point, or failing that to
|
||||
the start of the line. If the line is indented, and the cursor
|
||||
isn't already at the end of the indentation, this will move to the
|
||||
end of the indentation instead of the start of the line.
|
||||
*/
|
||||
declare const cursorLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the left.
|
||||
*/
|
||||
declare const cursorLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the right.
|
||||
*/
|
||||
declare const cursorLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection to the start of the line.
|
||||
*/
|
||||
declare const cursorLineStart: Command;
|
||||
/**
|
||||
Move the selection to the end of the line.
|
||||
*/
|
||||
declare const cursorLineEnd: Command;
|
||||
/**
|
||||
Move the selection to the bracket matching the one it is currently
|
||||
on, if any.
|
||||
*/
|
||||
declare const cursorMatchingBracket: StateCommand;
|
||||
/**
|
||||
Extend the selection to the bracket matching the one the selection
|
||||
head is currently on, if any.
|
||||
*/
|
||||
declare const selectMatchingBracket: StateCommand;
|
||||
/**
|
||||
Move the selection head one character to the left, while leaving
|
||||
the anchor in place.
|
||||
*/
|
||||
declare const selectCharLeft: Command;
|
||||
/**
|
||||
Move the selection head one character to the right.
|
||||
*/
|
||||
declare const selectCharRight: Command;
|
||||
/**
|
||||
Move the selection head one character forward.
|
||||
*/
|
||||
declare const selectCharForward: Command;
|
||||
/**
|
||||
Move the selection head one character backward.
|
||||
*/
|
||||
declare const selectCharBackward: Command;
|
||||
/**
|
||||
Move the selection head one character forward by logical
|
||||
(non-direction aware) string index order.
|
||||
*/
|
||||
declare const selectCharForwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection head one character backward by logical string
|
||||
index order.
|
||||
*/
|
||||
declare const selectCharBackwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
|
||||
the left.
|
||||
*/
|
||||
declare const selectGroupLeft: Command;
|
||||
/**
|
||||
Move the selection head one group to the right.
|
||||
*/
|
||||
declare const selectGroupRight: Command;
|
||||
/**
|
||||
Move the selection head one group forward.
|
||||
*/
|
||||
declare const selectGroupForward: Command;
|
||||
/**
|
||||
Move the selection head one group backward.
|
||||
*/
|
||||
declare const selectGroupBackward: Command;
|
||||
/**
|
||||
Move the selection head one group forward in the default Windows
|
||||
style, skipping to the start of the next group.
|
||||
*/
|
||||
declare const selectGroupForwardWin: Command;
|
||||
/**
|
||||
Move the selection head one group or camel-case subword forward.
|
||||
*/
|
||||
declare const selectSubwordForward: Command;
|
||||
/**
|
||||
Move the selection head one group or subword backward.
|
||||
*/
|
||||
declare const selectSubwordBackward: Command;
|
||||
/**
|
||||
Move the selection head over the next syntactic element to the left.
|
||||
*/
|
||||
declare const selectSyntaxLeft: Command;
|
||||
/**
|
||||
Move the selection head over the next syntactic element to the right.
|
||||
*/
|
||||
declare const selectSyntaxRight: Command;
|
||||
/**
|
||||
Move the selection head one line up.
|
||||
*/
|
||||
declare const selectLineUp: Command;
|
||||
/**
|
||||
Move the selection head one line down.
|
||||
*/
|
||||
declare const selectLineDown: Command;
|
||||
/**
|
||||
Move the selection head one page up.
|
||||
*/
|
||||
declare const selectPageUp: Command;
|
||||
/**
|
||||
Move the selection head one page down.
|
||||
*/
|
||||
declare const selectPageDown: Command;
|
||||
/**
|
||||
Move the selection head to the next line boundary.
|
||||
*/
|
||||
declare const selectLineBoundaryForward: Command;
|
||||
/**
|
||||
Move the selection head to the previous line boundary.
|
||||
*/
|
||||
declare const selectLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the left.
|
||||
*/
|
||||
declare const selectLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the right.
|
||||
*/
|
||||
declare const selectLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection head to the start of the line.
|
||||
*/
|
||||
declare const selectLineStart: Command;
|
||||
/**
|
||||
Move the selection head to the end of the line.
|
||||
*/
|
||||
declare const selectLineEnd: Command;
|
||||
/**
|
||||
Move the selection to the start of the document.
|
||||
*/
|
||||
declare const cursorDocStart: StateCommand;
|
||||
/**
|
||||
Move the selection to the end of the document.
|
||||
*/
|
||||
declare const cursorDocEnd: StateCommand;
|
||||
/**
|
||||
Move the selection head to the start of the document.
|
||||
*/
|
||||
declare const selectDocStart: StateCommand;
|
||||
/**
|
||||
Move the selection head to the end of the document.
|
||||
*/
|
||||
declare const selectDocEnd: StateCommand;
|
||||
/**
|
||||
Select the entire document.
|
||||
*/
|
||||
declare const selectAll: StateCommand;
|
||||
/**
|
||||
Expand the selection to cover entire lines.
|
||||
*/
|
||||
declare const selectLine: StateCommand;
|
||||
/**
|
||||
Select the next syntactic construct that is larger than the
|
||||
selection. Note that this will only work insofar as the language
|
||||
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
|
||||
syntax tree.
|
||||
*/
|
||||
declare const selectParentSyntax: StateCommand;
|
||||
/**
|
||||
Simplify the current selection. When multiple ranges are selected,
|
||||
reduce it to its main range. Otherwise, if the selection is
|
||||
non-empty, convert it to a cursor selection.
|
||||
*/
|
||||
declare const simplifySelection: StateCommand;
|
||||
/**
|
||||
Delete the selection, or, for cursor selections, the character or
|
||||
indentation unit before the cursor.
|
||||
*/
|
||||
declare const deleteCharBackward: Command;
|
||||
/**
|
||||
Delete the selection or the character before the cursor. Does not
|
||||
implement any extended behavior like deleting whole indentation
|
||||
units in one go.
|
||||
*/
|
||||
declare const deleteCharBackwardStrict: Command;
|
||||
/**
|
||||
Delete the selection or the character after the cursor.
|
||||
*/
|
||||
declare const deleteCharForward: Command;
|
||||
/**
|
||||
Delete the selection or backward until the end of the next
|
||||
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
|
||||
whitespace when they consist of a single space.
|
||||
*/
|
||||
declare const deleteGroupBackward: StateCommand;
|
||||
/**
|
||||
Delete the selection or forward until the end of the next group.
|
||||
*/
|
||||
declare const deleteGroupForward: StateCommand;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the end of the line. If the cursor is directly at the end of the
|
||||
line, delete the line break after it.
|
||||
*/
|
||||
declare const deleteToLineEnd: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the start of the line. If the cursor is directly at the start of the
|
||||
line, delete the line break before it.
|
||||
*/
|
||||
declare const deleteToLineStart: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the start of the line or the next line wrap before the cursor.
|
||||
*/
|
||||
declare const deleteLineBoundaryBackward: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the end of the line or the next line wrap after the cursor.
|
||||
*/
|
||||
declare const deleteLineBoundaryForward: Command;
|
||||
/**
|
||||
Delete all whitespace directly before a line end from the
|
||||
document.
|
||||
*/
|
||||
declare const deleteTrailingWhitespace: StateCommand;
|
||||
/**
|
||||
Replace each selection range with a line break, leaving the cursor
|
||||
on the line before the break.
|
||||
*/
|
||||
declare const splitLine: StateCommand;
|
||||
/**
|
||||
Flip the characters before and after the cursor(s).
|
||||
*/
|
||||
declare const transposeChars: StateCommand;
|
||||
/**
|
||||
Move the selected lines up one line.
|
||||
*/
|
||||
declare const moveLineUp: StateCommand;
|
||||
/**
|
||||
Move the selected lines down one line.
|
||||
*/
|
||||
declare const moveLineDown: StateCommand;
|
||||
/**
|
||||
Create a copy of the selected lines. Keep the selection in the top copy.
|
||||
*/
|
||||
declare const copyLineUp: StateCommand;
|
||||
/**
|
||||
Create a copy of the selected lines. Keep the selection in the bottom copy.
|
||||
*/
|
||||
declare const copyLineDown: StateCommand;
|
||||
/**
|
||||
Delete selected lines.
|
||||
*/
|
||||
declare const deleteLine: Command;
|
||||
/**
|
||||
Replace the selection with a newline.
|
||||
*/
|
||||
declare const insertNewline: StateCommand;
|
||||
/**
|
||||
Replace the selection with a newline and the same amount of
|
||||
indentation as the line above.
|
||||
*/
|
||||
declare const insertNewlineKeepIndent: StateCommand;
|
||||
/**
|
||||
Replace the selection with a newline and indent the newly created
|
||||
line(s). If the current line consists only of whitespace, this
|
||||
will also delete that whitespace. When the cursor is between
|
||||
matching brackets, an additional newline will be inserted after
|
||||
the cursor.
|
||||
*/
|
||||
declare const insertNewlineAndIndent: StateCommand;
|
||||
/**
|
||||
Create a blank, indented line below the current line.
|
||||
*/
|
||||
declare const insertBlankLine: StateCommand;
|
||||
/**
|
||||
Auto-indent the selected lines. This uses the [indentation service
|
||||
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
|
||||
information.
|
||||
*/
|
||||
declare const indentSelection: StateCommand;
|
||||
/**
|
||||
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
|
||||
lines.
|
||||
*/
|
||||
declare const indentMore: StateCommand;
|
||||
/**
|
||||
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
|
||||
selected lines.
|
||||
*/
|
||||
declare const indentLess: StateCommand;
|
||||
/**
|
||||
Enables or disables
|
||||
[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this
|
||||
prevents the editor's key bindings from capturing Tab or
|
||||
Shift-Tab, making it possible for the user to move focus out of
|
||||
the editor with the keyboard.
|
||||
*/
|
||||
declare const toggleTabFocusMode: Command;
|
||||
/**
|
||||
Temporarily enables [tab-focus
|
||||
mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until
|
||||
another key is pressed.
|
||||
*/
|
||||
declare const temporarilySetTabFocusMode: Command;
|
||||
/**
|
||||
Insert a tab character at the cursor or, if something is selected,
|
||||
use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire
|
||||
selection.
|
||||
*/
|
||||
declare const insertTab: StateCommand;
|
||||
/**
|
||||
Array of key bindings containing the Emacs-style bindings that are
|
||||
available on macOS by default.
|
||||
|
||||
- Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
|
||||
- Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
|
||||
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
|
||||
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
|
||||
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
|
||||
*/
|
||||
declare const emacsStyleKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
An array of key bindings closely sticking to platform-standard or
|
||||
widely used bindings. (This includes the bindings from
|
||||
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
|
||||
property changed to `mac`.)
|
||||
|
||||
- ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
|
||||
- Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
|
||||
- Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
|
||||
- End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
|
||||
- Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
|
||||
- Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
|
||||
- Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
||||
- Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward).
|
||||
- Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward).
|
||||
*/
|
||||
declare const standardKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
The default keymap. Includes all bindings from
|
||||
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
|
||||
|
||||
- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
|
||||
- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
|
||||
- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
|
||||
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
|
||||
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
|
||||
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
|
||||
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
|
||||
- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
|
||||
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
|
||||
- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
|
||||
- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
|
||||
- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
|
||||
- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
|
||||
- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
|
||||
- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
|
||||
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
|
||||
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
|
||||
- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode).
|
||||
*/
|
||||
declare const defaultKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
||||
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
||||
Please see the [Tab example](../../examples/tab/) before using
|
||||
this.
|
||||
*/
|
||||
declare const indentWithTab: KeyBinding;
|
||||
|
||||
export { type CommentTokens, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection };
|
||||
632
node_modules/@codemirror/commands/dist/index.d.ts
generated
vendored
Normal file
632
node_modules/@codemirror/commands/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,632 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { StateCommand, Facet, Transaction, StateEffect, Extension, StateField, EditorState } from '@codemirror/state';
|
||||
import { KeyBinding, Command } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
An object of this type can be provided as [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) under a `"commentTokens"`
|
||||
property to configure comment syntax for a language.
|
||||
*/
|
||||
interface CommentTokens {
|
||||
/**
|
||||
The block comment syntax, if any. For example, for HTML
|
||||
you'd provide `{open: "<!--", close: "-->"}`.
|
||||
*/
|
||||
block?: {
|
||||
open: string;
|
||||
close: string;
|
||||
};
|
||||
/**
|
||||
The line comment syntax. For example `"//"`.
|
||||
*/
|
||||
line?: string;
|
||||
}
|
||||
/**
|
||||
Comment or uncomment the current selection. Will use line comments
|
||||
if available, otherwise falling back to block comments.
|
||||
*/
|
||||
declare const toggleComment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the current selection using line comments.
|
||||
The line comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
declare const toggleLineComment: StateCommand;
|
||||
/**
|
||||
Comment the current selection using line comments.
|
||||
*/
|
||||
declare const lineComment: StateCommand;
|
||||
/**
|
||||
Uncomment the current selection using line comments.
|
||||
*/
|
||||
declare const lineUncomment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the current selection using block comments.
|
||||
The block comment syntax is taken from the
|
||||
[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language
|
||||
data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).
|
||||
*/
|
||||
declare const toggleBlockComment: StateCommand;
|
||||
/**
|
||||
Comment the current selection using block comments.
|
||||
*/
|
||||
declare const blockComment: StateCommand;
|
||||
/**
|
||||
Uncomment the current selection using block comments.
|
||||
*/
|
||||
declare const blockUncomment: StateCommand;
|
||||
/**
|
||||
Comment or uncomment the lines around the current selection using
|
||||
block comments.
|
||||
*/
|
||||
declare const toggleBlockCommentByLine: StateCommand;
|
||||
|
||||
/**
|
||||
Transaction annotation that will prevent that transaction from
|
||||
being combined with other transactions in the undo history. Given
|
||||
`"before"`, it'll prevent merging with previous transactions. With
|
||||
`"after"`, subsequent transactions won't be combined with this
|
||||
one. With `"full"`, the transaction is isolated on both sides.
|
||||
*/
|
||||
declare const isolateHistory: _codemirror_state.AnnotationType<"after" | "before" | "full">;
|
||||
/**
|
||||
This facet provides a way to register functions that, given a
|
||||
transaction, provide a set of effects that the history should
|
||||
store when inverting the transaction. This can be used to
|
||||
integrate some kinds of effects in the history, so that they can
|
||||
be undone (and redone again).
|
||||
*/
|
||||
declare const invertedEffects: Facet<(tr: Transaction) => readonly StateEffect<any>[], readonly ((tr: Transaction) => readonly StateEffect<any>[])[]>;
|
||||
interface HistoryConfig {
|
||||
/**
|
||||
The minimum depth (amount of events) to store. Defaults to 100.
|
||||
*/
|
||||
minDepth?: number;
|
||||
/**
|
||||
The maximum time (in milliseconds) that adjacent events can be
|
||||
apart and still be grouped together. Defaults to 500.
|
||||
*/
|
||||
newGroupDelay?: number;
|
||||
/**
|
||||
By default, when close enough together in time, changes are
|
||||
joined into an existing undo event if they touch any of the
|
||||
changed ranges from that event. You can pass a custom predicate
|
||||
here to influence that logic.
|
||||
*/
|
||||
joinToEvent?: (tr: Transaction, isAdjacent: boolean) => boolean;
|
||||
}
|
||||
/**
|
||||
Create a history extension with the given configuration.
|
||||
*/
|
||||
declare function history(config?: HistoryConfig): Extension;
|
||||
/**
|
||||
The state field used to store the history data. Should probably
|
||||
only be used when you want to
|
||||
[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or
|
||||
[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way
|
||||
that preserves history.
|
||||
*/
|
||||
declare const historyField: StateField<unknown>;
|
||||
/**
|
||||
Undo a single group of history events. Returns false if no group
|
||||
was available.
|
||||
*/
|
||||
declare const undo: StateCommand;
|
||||
/**
|
||||
Redo a group of history events. Returns false if no group was
|
||||
available.
|
||||
*/
|
||||
declare const redo: StateCommand;
|
||||
/**
|
||||
Undo a change or selection change.
|
||||
*/
|
||||
declare const undoSelection: StateCommand;
|
||||
/**
|
||||
Redo a change or selection change.
|
||||
*/
|
||||
declare const redoSelection: StateCommand;
|
||||
/**
|
||||
The amount of undoable change events available in a given state.
|
||||
*/
|
||||
declare const undoDepth: (state: EditorState) => number;
|
||||
/**
|
||||
The amount of redoable change events available in a given state.
|
||||
*/
|
||||
declare const redoDepth: (state: EditorState) => number;
|
||||
/**
|
||||
Default key bindings for the undo history.
|
||||
|
||||
- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).
|
||||
- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).
|
||||
- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).
|
||||
- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).
|
||||
*/
|
||||
declare const historyKeymap: readonly KeyBinding[];
|
||||
|
||||
/**
|
||||
Move the selection one character to the left (which is backward in
|
||||
left-to-right text, forward in right-to-left text).
|
||||
*/
|
||||
declare const cursorCharLeft: Command;
|
||||
/**
|
||||
Move the selection one character to the right.
|
||||
*/
|
||||
declare const cursorCharRight: Command;
|
||||
/**
|
||||
Move the selection one character forward.
|
||||
*/
|
||||
declare const cursorCharForward: Command;
|
||||
/**
|
||||
Move the selection one character backward.
|
||||
*/
|
||||
declare const cursorCharBackward: Command;
|
||||
/**
|
||||
Move the selection one character forward, in logical
|
||||
(non-text-direction-aware) string index order.
|
||||
*/
|
||||
declare const cursorCharForwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection one character backward, in logical string index
|
||||
order.
|
||||
*/
|
||||
declare const cursorCharBackwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection to the left across one group of word or
|
||||
non-word (but also non-space) characters.
|
||||
*/
|
||||
declare const cursorGroupLeft: Command;
|
||||
/**
|
||||
Move the selection one group to the right.
|
||||
*/
|
||||
declare const cursorGroupRight: Command;
|
||||
/**
|
||||
Move the selection one group forward.
|
||||
*/
|
||||
declare const cursorGroupForward: Command;
|
||||
/**
|
||||
Move the selection one group backward.
|
||||
*/
|
||||
declare const cursorGroupBackward: Command;
|
||||
/**
|
||||
Move the cursor one group forward in the default Windows style,
|
||||
where it moves to the start of the next group.
|
||||
*/
|
||||
declare const cursorGroupForwardWin: Command;
|
||||
/**
|
||||
Move the selection one group or camel-case subword forward.
|
||||
*/
|
||||
declare const cursorSubwordForward: Command;
|
||||
/**
|
||||
Move the selection one group or camel-case subword backward.
|
||||
*/
|
||||
declare const cursorSubwordBackward: Command;
|
||||
/**
|
||||
Move the cursor over the next syntactic element to the left.
|
||||
*/
|
||||
declare const cursorSyntaxLeft: Command;
|
||||
/**
|
||||
Move the cursor over the next syntactic element to the right.
|
||||
*/
|
||||
declare const cursorSyntaxRight: Command;
|
||||
/**
|
||||
Move the selection one line up.
|
||||
*/
|
||||
declare const cursorLineUp: Command;
|
||||
/**
|
||||
Move the selection one line down.
|
||||
*/
|
||||
declare const cursorLineDown: Command;
|
||||
/**
|
||||
Move the selection one page up.
|
||||
*/
|
||||
declare const cursorPageUp: Command;
|
||||
/**
|
||||
Move the selection one page down.
|
||||
*/
|
||||
declare const cursorPageDown: Command;
|
||||
/**
|
||||
Move the selection to the next line wrap point, or to the end of
|
||||
the line if there isn't one left on this line.
|
||||
*/
|
||||
declare const cursorLineBoundaryForward: Command;
|
||||
/**
|
||||
Move the selection to previous line wrap point, or failing that to
|
||||
the start of the line. If the line is indented, and the cursor
|
||||
isn't already at the end of the indentation, this will move to the
|
||||
end of the indentation instead of the start of the line.
|
||||
*/
|
||||
declare const cursorLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the left.
|
||||
*/
|
||||
declare const cursorLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection one line wrap point to the right.
|
||||
*/
|
||||
declare const cursorLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection to the start of the line.
|
||||
*/
|
||||
declare const cursorLineStart: Command;
|
||||
/**
|
||||
Move the selection to the end of the line.
|
||||
*/
|
||||
declare const cursorLineEnd: Command;
|
||||
/**
|
||||
Move the selection to the bracket matching the one it is currently
|
||||
on, if any.
|
||||
*/
|
||||
declare const cursorMatchingBracket: StateCommand;
|
||||
/**
|
||||
Extend the selection to the bracket matching the one the selection
|
||||
head is currently on, if any.
|
||||
*/
|
||||
declare const selectMatchingBracket: StateCommand;
|
||||
/**
|
||||
Move the selection head one character to the left, while leaving
|
||||
the anchor in place.
|
||||
*/
|
||||
declare const selectCharLeft: Command;
|
||||
/**
|
||||
Move the selection head one character to the right.
|
||||
*/
|
||||
declare const selectCharRight: Command;
|
||||
/**
|
||||
Move the selection head one character forward.
|
||||
*/
|
||||
declare const selectCharForward: Command;
|
||||
/**
|
||||
Move the selection head one character backward.
|
||||
*/
|
||||
declare const selectCharBackward: Command;
|
||||
/**
|
||||
Move the selection head one character forward by logical
|
||||
(non-direction aware) string index order.
|
||||
*/
|
||||
declare const selectCharForwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection head one character backward by logical string
|
||||
index order.
|
||||
*/
|
||||
declare const selectCharBackwardLogical: StateCommand;
|
||||
/**
|
||||
Move the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to
|
||||
the left.
|
||||
*/
|
||||
declare const selectGroupLeft: Command;
|
||||
/**
|
||||
Move the selection head one group to the right.
|
||||
*/
|
||||
declare const selectGroupRight: Command;
|
||||
/**
|
||||
Move the selection head one group forward.
|
||||
*/
|
||||
declare const selectGroupForward: Command;
|
||||
/**
|
||||
Move the selection head one group backward.
|
||||
*/
|
||||
declare const selectGroupBackward: Command;
|
||||
/**
|
||||
Move the selection head one group forward in the default Windows
|
||||
style, skipping to the start of the next group.
|
||||
*/
|
||||
declare const selectGroupForwardWin: Command;
|
||||
/**
|
||||
Move the selection head one group or camel-case subword forward.
|
||||
*/
|
||||
declare const selectSubwordForward: Command;
|
||||
/**
|
||||
Move the selection head one group or subword backward.
|
||||
*/
|
||||
declare const selectSubwordBackward: Command;
|
||||
/**
|
||||
Move the selection head over the next syntactic element to the left.
|
||||
*/
|
||||
declare const selectSyntaxLeft: Command;
|
||||
/**
|
||||
Move the selection head over the next syntactic element to the right.
|
||||
*/
|
||||
declare const selectSyntaxRight: Command;
|
||||
/**
|
||||
Move the selection head one line up.
|
||||
*/
|
||||
declare const selectLineUp: Command;
|
||||
/**
|
||||
Move the selection head one line down.
|
||||
*/
|
||||
declare const selectLineDown: Command;
|
||||
/**
|
||||
Move the selection head one page up.
|
||||
*/
|
||||
declare const selectPageUp: Command;
|
||||
/**
|
||||
Move the selection head one page down.
|
||||
*/
|
||||
declare const selectPageDown: Command;
|
||||
/**
|
||||
Move the selection head to the next line boundary.
|
||||
*/
|
||||
declare const selectLineBoundaryForward: Command;
|
||||
/**
|
||||
Move the selection head to the previous line boundary.
|
||||
*/
|
||||
declare const selectLineBoundaryBackward: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the left.
|
||||
*/
|
||||
declare const selectLineBoundaryLeft: Command;
|
||||
/**
|
||||
Move the selection head one line boundary to the right.
|
||||
*/
|
||||
declare const selectLineBoundaryRight: Command;
|
||||
/**
|
||||
Move the selection head to the start of the line.
|
||||
*/
|
||||
declare const selectLineStart: Command;
|
||||
/**
|
||||
Move the selection head to the end of the line.
|
||||
*/
|
||||
declare const selectLineEnd: Command;
|
||||
/**
|
||||
Move the selection to the start of the document.
|
||||
*/
|
||||
declare const cursorDocStart: StateCommand;
|
||||
/**
|
||||
Move the selection to the end of the document.
|
||||
*/
|
||||
declare const cursorDocEnd: StateCommand;
|
||||
/**
|
||||
Move the selection head to the start of the document.
|
||||
*/
|
||||
declare const selectDocStart: StateCommand;
|
||||
/**
|
||||
Move the selection head to the end of the document.
|
||||
*/
|
||||
declare const selectDocEnd: StateCommand;
|
||||
/**
|
||||
Select the entire document.
|
||||
*/
|
||||
declare const selectAll: StateCommand;
|
||||
/**
|
||||
Expand the selection to cover entire lines.
|
||||
*/
|
||||
declare const selectLine: StateCommand;
|
||||
/**
|
||||
Select the next syntactic construct that is larger than the
|
||||
selection. Note that this will only work insofar as the language
|
||||
[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full
|
||||
syntax tree.
|
||||
*/
|
||||
declare const selectParentSyntax: StateCommand;
|
||||
/**
|
||||
Simplify the current selection. When multiple ranges are selected,
|
||||
reduce it to its main range. Otherwise, if the selection is
|
||||
non-empty, convert it to a cursor selection.
|
||||
*/
|
||||
declare const simplifySelection: StateCommand;
|
||||
/**
|
||||
Delete the selection, or, for cursor selections, the character or
|
||||
indentation unit before the cursor.
|
||||
*/
|
||||
declare const deleteCharBackward: Command;
|
||||
/**
|
||||
Delete the selection or the character before the cursor. Does not
|
||||
implement any extended behavior like deleting whole indentation
|
||||
units in one go.
|
||||
*/
|
||||
declare const deleteCharBackwardStrict: Command;
|
||||
/**
|
||||
Delete the selection or the character after the cursor.
|
||||
*/
|
||||
declare const deleteCharForward: Command;
|
||||
/**
|
||||
Delete the selection or backward until the end of the next
|
||||
[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of
|
||||
whitespace when they consist of a single space.
|
||||
*/
|
||||
declare const deleteGroupBackward: StateCommand;
|
||||
/**
|
||||
Delete the selection or forward until the end of the next group.
|
||||
*/
|
||||
declare const deleteGroupForward: StateCommand;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the end of the line. If the cursor is directly at the end of the
|
||||
line, delete the line break after it.
|
||||
*/
|
||||
declare const deleteToLineEnd: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the start of the line. If the cursor is directly at the start of the
|
||||
line, delete the line break before it.
|
||||
*/
|
||||
declare const deleteToLineStart: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the start of the line or the next line wrap before the cursor.
|
||||
*/
|
||||
declare const deleteLineBoundaryBackward: Command;
|
||||
/**
|
||||
Delete the selection, or, if it is a cursor selection, delete to
|
||||
the end of the line or the next line wrap after the cursor.
|
||||
*/
|
||||
declare const deleteLineBoundaryForward: Command;
|
||||
/**
|
||||
Delete all whitespace directly before a line end from the
|
||||
document.
|
||||
*/
|
||||
declare const deleteTrailingWhitespace: StateCommand;
|
||||
/**
|
||||
Replace each selection range with a line break, leaving the cursor
|
||||
on the line before the break.
|
||||
*/
|
||||
declare const splitLine: StateCommand;
|
||||
/**
|
||||
Flip the characters before and after the cursor(s).
|
||||
*/
|
||||
declare const transposeChars: StateCommand;
|
||||
/**
|
||||
Move the selected lines up one line.
|
||||
*/
|
||||
declare const moveLineUp: StateCommand;
|
||||
/**
|
||||
Move the selected lines down one line.
|
||||
*/
|
||||
declare const moveLineDown: StateCommand;
|
||||
/**
|
||||
Create a copy of the selected lines. Keep the selection in the top copy.
|
||||
*/
|
||||
declare const copyLineUp: StateCommand;
|
||||
/**
|
||||
Create a copy of the selected lines. Keep the selection in the bottom copy.
|
||||
*/
|
||||
declare const copyLineDown: StateCommand;
|
||||
/**
|
||||
Delete selected lines.
|
||||
*/
|
||||
declare const deleteLine: Command;
|
||||
/**
|
||||
Replace the selection with a newline.
|
||||
*/
|
||||
declare const insertNewline: StateCommand;
|
||||
/**
|
||||
Replace the selection with a newline and the same amount of
|
||||
indentation as the line above.
|
||||
*/
|
||||
declare const insertNewlineKeepIndent: StateCommand;
|
||||
/**
|
||||
Replace the selection with a newline and indent the newly created
|
||||
line(s). If the current line consists only of whitespace, this
|
||||
will also delete that whitespace. When the cursor is between
|
||||
matching brackets, an additional newline will be inserted after
|
||||
the cursor.
|
||||
*/
|
||||
declare const insertNewlineAndIndent: StateCommand;
|
||||
/**
|
||||
Create a blank, indented line below the current line.
|
||||
*/
|
||||
declare const insertBlankLine: StateCommand;
|
||||
/**
|
||||
Auto-indent the selected lines. This uses the [indentation service
|
||||
facet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent
|
||||
information.
|
||||
*/
|
||||
declare const indentSelection: StateCommand;
|
||||
/**
|
||||
Add a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected
|
||||
lines.
|
||||
*/
|
||||
declare const indentMore: StateCommand;
|
||||
/**
|
||||
Remove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all
|
||||
selected lines.
|
||||
*/
|
||||
declare const indentLess: StateCommand;
|
||||
/**
|
||||
Enables or disables
|
||||
[tab-focus mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode). While on, this
|
||||
prevents the editor's key bindings from capturing Tab or
|
||||
Shift-Tab, making it possible for the user to move focus out of
|
||||
the editor with the keyboard.
|
||||
*/
|
||||
declare const toggleTabFocusMode: Command;
|
||||
/**
|
||||
Temporarily enables [tab-focus
|
||||
mode](https://codemirror.net/6/docs/ref/#view.EditorView.setTabFocusMode) for two seconds or until
|
||||
another key is pressed.
|
||||
*/
|
||||
declare const temporarilySetTabFocusMode: Command;
|
||||
/**
|
||||
Insert a tab character at the cursor or, if something is selected,
|
||||
use [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire
|
||||
selection.
|
||||
*/
|
||||
declare const insertTab: StateCommand;
|
||||
/**
|
||||
Array of key bindings containing the Emacs-style bindings that are
|
||||
available on macOS by default.
|
||||
|
||||
- Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)
|
||||
- Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)
|
||||
- Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)
|
||||
- Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)
|
||||
- Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)
|
||||
*/
|
||||
declare const emacsStyleKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
An array of key bindings closely sticking to platform-standard or
|
||||
widely used bindings. (This includes the bindings from
|
||||
[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`
|
||||
property changed to `mac`.)
|
||||
|
||||
- ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)
|
||||
- ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)
|
||||
- Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)
|
||||
- Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)
|
||||
- Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)
|
||||
- Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)
|
||||
- ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)
|
||||
- ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)
|
||||
- Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)
|
||||
- PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)
|
||||
- Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)
|
||||
- End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)
|
||||
- Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)
|
||||
- Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)
|
||||
- Enter and Shift-Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)
|
||||
- Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)
|
||||
- Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)
|
||||
- Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)
|
||||
- Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)
|
||||
- Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
|
||||
- Cmd-Backspace (macOS): [`deleteLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryBackward).
|
||||
- Cmd-Delete (macOS): [`deleteLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.deleteLineBoundaryForward).
|
||||
*/
|
||||
declare const standardKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
The default keymap. Includes all bindings from
|
||||
[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:
|
||||
|
||||
- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)
|
||||
- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)
|
||||
- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)
|
||||
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
|
||||
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
|
||||
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
|
||||
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
|
||||
- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
|
||||
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
|
||||
- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)
|
||||
- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)
|
||||
- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)
|
||||
- Ctrl-Alt-\\ (Cmd-Alt-\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)
|
||||
- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)
|
||||
- Shift-Ctrl-\\ (Shift-Cmd-\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)
|
||||
- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).
|
||||
- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).
|
||||
- Ctrl-m (Alt-Shift-m on macOS): [`toggleTabFocusMode`](https://codemirror.net/6/docs/ref/#commands.toggleTabFocusMode).
|
||||
*/
|
||||
declare const defaultKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
A binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and
|
||||
Shift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).
|
||||
Please see the [Tab example](../../examples/tab/) before using
|
||||
this.
|
||||
*/
|
||||
declare const indentWithTab: KeyBinding;
|
||||
|
||||
export { type CommentTokens, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection };
|
||||
1741
node_modules/@codemirror/commands/dist/index.js
generated
vendored
Normal file
1741
node_modules/@codemirror/commands/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
node_modules/@codemirror/commands/package.json
generated
vendored
Normal file
42
node_modules/@codemirror/commands/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@codemirror/commands",
|
||||
"version": "6.8.0",
|
||||
"description": "Collection of editing commands for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/commands.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.4.0",
|
||||
"@codemirror/view": "^6.27.0",
|
||||
"@lezer/common": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0",
|
||||
"@codemirror/lang-javascript": "^6.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/commands.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-css/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
106
node_modules/@codemirror/lang-css/CHANGELOG.md
generated
vendored
Normal file
106
node_modules/@codemirror/lang-css/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
## 6.3.1 (2024-11-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When completing a property name, insert a colon and space after the name.
|
||||
|
||||
## 6.3.0 (2024-09-07)
|
||||
|
||||
### New features
|
||||
|
||||
CSS autocompletion now completes `@`-keywords.
|
||||
|
||||
## 6.2.1 (2023-08-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow keyframe blocks to be code-folded.
|
||||
|
||||
## 6.2.0 (2023-04-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Explicitly list @lezer/common as a package dependency.
|
||||
|
||||
### New features
|
||||
|
||||
Export `defineCSSCompletionSource`, which allows one to define a CSS-style completion source for dialects with their own variable syntax.
|
||||
|
||||
## 6.1.1 (2023-03-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Provide better completions when completing directly in a `Styles` top node.
|
||||
|
||||
## 6.1.0 (2023-03-06)
|
||||
|
||||
### New features
|
||||
|
||||
CSS completion can now complete variable names.
|
||||
|
||||
## 6.0.2 (2023-01-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fetch the available CSS property names in a way that works on Chrome.
|
||||
|
||||
## 6.0.1 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
CSS completion now supports a number of additional recent and semi-standardized pseudo-class names.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.20.0
|
||||
|
||||
## 0.19.3 (2021-09-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use more appropriate highlighting tags for attribute names, tag names, and CSS variables.
|
||||
|
||||
## 0.19.2 (2021-09-22)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a completion source function, rather than a prebuilt completion extension.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lang-css/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-css/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
50
node_modules/@codemirror/lang-css/README.md
generated
vendored
Normal file
50
node_modules/@codemirror/lang-css/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-css [](https://www.npmjs.org/package/@codemirror/lang-css)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-css/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements CSS language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-css/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## API Reference
|
||||
|
||||
<dl>
|
||||
<dt id="user-content-css">
|
||||
<code><strong><a href="#user-content-css">css</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>Language support for CSS.</p>
|
||||
</dd>
|
||||
<dt id="user-content-csslanguage">
|
||||
<code><strong><a href="#user-content-csslanguage">cssLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/css">Lezer CSS
|
||||
parser</a>, extended with
|
||||
highlighting and indentation information.</p>
|
||||
</dd>
|
||||
<dt id="user-content-csscompletionsource">
|
||||
<code><strong><a href="#user-content-csscompletionsource">cssCompletionSource</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
|
||||
|
||||
<dd><p>CSS property, variable, and value keyword completion source.</p>
|
||||
</dd>
|
||||
<dt id="user-content-definecsscompletionsource">
|
||||
<code><strong><a href="#user-content-definecsscompletionsource">defineCSSCompletionSource</a></strong>(<a id="user-content-definecsscompletionsource^isvariable" href="#user-content-definecsscompletionsource^isvariable">isVariable</a>: fn(<a id="user-content-definecsscompletionsource^isvariable^node" href="#user-content-definecsscompletionsource^isvariable^node">node</a>: <a href="https://lezer.codemirror.net/docs/ref/#common.SyntaxNodeRef">SyntaxNodeRef</a>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
|
||||
|
||||
<dd><p>Create a completion source for a CSS dialect, providing a
|
||||
predicate for determining what kind of syntax node can act as a
|
||||
completable variable. This is used by language modes like Sass and
|
||||
Less to reuse this package's completion logic.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
269
node_modules/@codemirror/lang-css/dist/index.cjs
generated
vendored
Normal file
269
node_modules/@codemirror/lang-css/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,269 @@
|
||||
'use strict';
|
||||
|
||||
var css$1 = require('@lezer/css');
|
||||
var language = require('@codemirror/language');
|
||||
var common = require('@lezer/common');
|
||||
|
||||
let _properties = null;
|
||||
function properties() {
|
||||
if (!_properties && typeof document == "object" && document.body) {
|
||||
let { style } = document.body, names = [], seen = new Set;
|
||||
for (let prop in style)
|
||||
if (prop != "cssText" && prop != "cssFloat") {
|
||||
if (typeof style[prop] == "string") {
|
||||
if (/[A-Z]/.test(prop))
|
||||
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase());
|
||||
if (!seen.has(prop)) {
|
||||
names.push(prop);
|
||||
seen.add(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " }));
|
||||
}
|
||||
return _properties || [];
|
||||
}
|
||||
const pseudoClasses = [
|
||||
"active", "after", "any-link", "autofill", "backdrop", "before",
|
||||
"checked", "cue", "default", "defined", "disabled", "empty",
|
||||
"enabled", "file-selector-button", "first", "first-child",
|
||||
"first-letter", "first-line", "first-of-type", "focus",
|
||||
"focus-visible", "focus-within", "fullscreen", "has", "host",
|
||||
"host-context", "hover", "in-range", "indeterminate", "invalid",
|
||||
"is", "lang", "last-child", "last-of-type", "left", "link", "marker",
|
||||
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type",
|
||||
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range",
|
||||
"part", "placeholder", "placeholder-shown", "read-only", "read-write",
|
||||
"required", "right", "root", "scope", "selection", "slotted", "target",
|
||||
"target-text", "valid", "visited", "where"
|
||||
].map(name => ({ type: "class", label: name }));
|
||||
const values = [
|
||||
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space",
|
||||
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always",
|
||||
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column",
|
||||
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below",
|
||||
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize",
|
||||
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle",
|
||||
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn",
|
||||
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content",
|
||||
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover",
|
||||
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in",
|
||||
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed",
|
||||
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize",
|
||||
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end",
|
||||
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion",
|
||||
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box",
|
||||
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from",
|
||||
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide",
|
||||
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext",
|
||||
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid",
|
||||
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all",
|
||||
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear",
|
||||
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower",
|
||||
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation",
|
||||
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic",
|
||||
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower",
|
||||
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
|
||||
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize",
|
||||
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside",
|
||||
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused",
|
||||
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait",
|
||||
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio",
|
||||
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat",
|
||||
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round",
|
||||
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation",
|
||||
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position",
|
||||
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show",
|
||||
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps",
|
||||
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out",
|
||||
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start",
|
||||
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks",
|
||||
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell",
|
||||
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row",
|
||||
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin",
|
||||
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top",
|
||||
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent",
|
||||
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin",
|
||||
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill",
|
||||
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe",
|
||||
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small"
|
||||
].map(name => ({ type: "keyword", label: name })).concat([
|
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
||||
"whitesmoke", "yellow", "yellowgreen"
|
||||
].map(name => ({ type: "constant", label: name })));
|
||||
const tags = [
|
||||
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body",
|
||||
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del",
|
||||
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer",
|
||||
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe",
|
||||
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output",
|
||||
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary",
|
||||
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul"
|
||||
].map(name => ({ type: "type", label: name }));
|
||||
const atRules = [
|
||||
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values",
|
||||
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page",
|
||||
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition"
|
||||
].map(label => ({ type: "keyword", label }));
|
||||
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/;
|
||||
function isVarArg(node, doc) {
|
||||
var _a;
|
||||
if (node.name == "(" || node.type.isError)
|
||||
node = node.parent || node;
|
||||
if (node.name != "ArgList")
|
||||
return false;
|
||||
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild;
|
||||
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee")
|
||||
return false;
|
||||
return doc.sliceString(callee.from, callee.to) == "var";
|
||||
}
|
||||
const VariablesByNode = new common.NodeWeakMap();
|
||||
const declSelector = ["Declaration"];
|
||||
function astTop(node) {
|
||||
for (let cur = node;;) {
|
||||
if (cur.type.isTop)
|
||||
return cur;
|
||||
if (!(cur = cur.parent))
|
||||
return node;
|
||||
}
|
||||
}
|
||||
function variableNames(doc, node, isVariable) {
|
||||
if (node.to - node.from > 4096) {
|
||||
let known = VariablesByNode.get(node);
|
||||
if (known)
|
||||
return known;
|
||||
let result = [], seen = new Set, cursor = node.cursor(common.IterMode.IncludeAnonymous);
|
||||
if (cursor.firstChild())
|
||||
do {
|
||||
for (let option of variableNames(doc, cursor.node, isVariable))
|
||||
if (!seen.has(option.label)) {
|
||||
seen.add(option.label);
|
||||
result.push(option);
|
||||
}
|
||||
} while (cursor.nextSibling());
|
||||
VariablesByNode.set(node, result);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
let result = [], seen = new Set;
|
||||
node.cursor().iterate(node => {
|
||||
var _a;
|
||||
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") {
|
||||
let name = doc.sliceString(node.from, node.to);
|
||||
if (!seen.has(name)) {
|
||||
seen.add(name);
|
||||
result.push({ label: name, type: "variable" });
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Create a completion source for a CSS dialect, providing a
|
||||
predicate for determining what kind of syntax node can act as a
|
||||
completable variable. This is used by language modes like Sass and
|
||||
Less to reuse this package's completion logic.
|
||||
*/
|
||||
const defineCSSCompletionSource = (isVariable) => context => {
|
||||
let { state, pos } = context, node = language.syntaxTree(state).resolveInner(pos, -1);
|
||||
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-";
|
||||
if (node.name == "PropertyName" ||
|
||||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name))
|
||||
return { from: node.from, options: properties(), validFor: identifier };
|
||||
if (node.name == "ValueName")
|
||||
return { from: node.from, options: values, validFor: identifier };
|
||||
if (node.name == "PseudoClassName")
|
||||
return { from: node.from, options: pseudoClasses, validFor: identifier };
|
||||
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc))
|
||||
return { from: isVariable(node) || isDash ? node.from : pos,
|
||||
options: variableNames(state.doc, astTop(node), isVariable),
|
||||
validFor: variable };
|
||||
if (node.name == "TagName") {
|
||||
for (let { parent } = node; parent; parent = parent.parent)
|
||||
if (parent.name == "Block")
|
||||
return { from: node.from, options: properties(), validFor: identifier };
|
||||
return { from: node.from, options: tags, validFor: identifier };
|
||||
}
|
||||
if (node.name == "AtKeyword")
|
||||
return { from: node.from, options: atRules, validFor: identifier };
|
||||
if (!context.explicit)
|
||||
return null;
|
||||
let above = node.resolve(pos), before = above.childBefore(pos);
|
||||
if (before && before.name == ":" && above.name == "PseudoClassSelector")
|
||||
return { from: pos, options: pseudoClasses, validFor: identifier };
|
||||
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList")
|
||||
return { from: pos, options: values, validFor: identifier };
|
||||
if (above.name == "Block" || above.name == "Styles")
|
||||
return { from: pos, options: properties(), validFor: identifier };
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
CSS property, variable, and value keyword completion source.
|
||||
*/
|
||||
const cssCompletionSource = defineCSSCompletionSource(n => n.name == "VariableName");
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer CSS
|
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const cssLanguage = language.LRLanguage.define({
|
||||
name: "css",
|
||||
parser: css$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
Declaration: language.continuedIndent()
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
"Block KeyframeList": language.foldInside
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "/*", close: "*/" } },
|
||||
indentOnInput: /^\s*\}$/,
|
||||
wordChars: "-"
|
||||
}
|
||||
});
|
||||
/**
|
||||
Language support for CSS.
|
||||
*/
|
||||
function css() {
|
||||
return new language.LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));
|
||||
}
|
||||
|
||||
exports.css = css;
|
||||
exports.cssCompletionSource = cssCompletionSource;
|
||||
exports.cssLanguage = cssLanguage;
|
||||
exports.defineCSSCompletionSource = defineCSSCompletionSource;
|
||||
28
node_modules/@codemirror/lang-css/dist/index.d.cts
generated
vendored
Normal file
28
node_modules/@codemirror/lang-css/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { CompletionSource } from '@codemirror/autocomplete';
|
||||
import { SyntaxNodeRef } from '@lezer/common';
|
||||
|
||||
/**
|
||||
Create a completion source for a CSS dialect, providing a
|
||||
predicate for determining what kind of syntax node can act as a
|
||||
completable variable. This is used by language modes like Sass and
|
||||
Less to reuse this package's completion logic.
|
||||
*/
|
||||
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource;
|
||||
/**
|
||||
CSS property, variable, and value keyword completion source.
|
||||
*/
|
||||
declare const cssCompletionSource: CompletionSource;
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer CSS
|
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const cssLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for CSS.
|
||||
*/
|
||||
declare function css(): LanguageSupport;
|
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };
|
||||
28
node_modules/@codemirror/lang-css/dist/index.d.ts
generated
vendored
Normal file
28
node_modules/@codemirror/lang-css/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { CompletionSource } from '@codemirror/autocomplete';
|
||||
import { SyntaxNodeRef } from '@lezer/common';
|
||||
|
||||
/**
|
||||
Create a completion source for a CSS dialect, providing a
|
||||
predicate for determining what kind of syntax node can act as a
|
||||
completable variable. This is used by language modes like Sass and
|
||||
Less to reuse this package's completion logic.
|
||||
*/
|
||||
declare const defineCSSCompletionSource: (isVariable: (node: SyntaxNodeRef) => boolean) => CompletionSource;
|
||||
/**
|
||||
CSS property, variable, and value keyword completion source.
|
||||
*/
|
||||
declare const cssCompletionSource: CompletionSource;
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer CSS
|
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const cssLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for CSS.
|
||||
*/
|
||||
declare function css(): LanguageSupport;
|
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };
|
||||
264
node_modules/@codemirror/lang-css/dist/index.js
generated
vendored
Normal file
264
node_modules/@codemirror/lang-css/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
import { parser } from '@lezer/css';
|
||||
import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
|
||||
import { NodeWeakMap, IterMode } from '@lezer/common';
|
||||
|
||||
let _properties = null;
|
||||
function properties() {
|
||||
if (!_properties && typeof document == "object" && document.body) {
|
||||
let { style } = document.body, names = [], seen = new Set;
|
||||
for (let prop in style)
|
||||
if (prop != "cssText" && prop != "cssFloat") {
|
||||
if (typeof style[prop] == "string") {
|
||||
if (/[A-Z]/.test(prop))
|
||||
prop = prop.replace(/[A-Z]/g, ch => "-" + ch.toLowerCase());
|
||||
if (!seen.has(prop)) {
|
||||
names.push(prop);
|
||||
seen.add(prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
_properties = names.sort().map(name => ({ type: "property", label: name, apply: name + ": " }));
|
||||
}
|
||||
return _properties || [];
|
||||
}
|
||||
const pseudoClasses = /*@__PURE__*/[
|
||||
"active", "after", "any-link", "autofill", "backdrop", "before",
|
||||
"checked", "cue", "default", "defined", "disabled", "empty",
|
||||
"enabled", "file-selector-button", "first", "first-child",
|
||||
"first-letter", "first-line", "first-of-type", "focus",
|
||||
"focus-visible", "focus-within", "fullscreen", "has", "host",
|
||||
"host-context", "hover", "in-range", "indeterminate", "invalid",
|
||||
"is", "lang", "last-child", "last-of-type", "left", "link", "marker",
|
||||
"modal", "not", "nth-child", "nth-last-child", "nth-last-of-type",
|
||||
"nth-of-type", "only-child", "only-of-type", "optional", "out-of-range",
|
||||
"part", "placeholder", "placeholder-shown", "read-only", "read-write",
|
||||
"required", "right", "root", "scope", "selection", "slotted", "target",
|
||||
"target-text", "valid", "visited", "where"
|
||||
].map(name => ({ type: "class", label: name }));
|
||||
const values = /*@__PURE__*/[
|
||||
"above", "absolute", "activeborder", "additive", "activecaption", "after-white-space",
|
||||
"ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", "always",
|
||||
"antialiased", "appworkspace", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column",
|
||||
"avoid-page", "avoid-region", "axis-pan", "background", "backwards", "baseline", "below",
|
||||
"bidi-override", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
||||
"both", "bottom", "break", "break-all", "break-word", "bullets", "button", "button-bevel",
|
||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "capitalize",
|
||||
"caps-lock-indicator", "caption", "captiontext", "caret", "cell", "center", "checkbox", "circle",
|
||||
"cjk-decimal", "clear", "clip", "close-quote", "col-resize", "collapse", "color", "color-burn",
|
||||
"color-dodge", "column", "column-reverse", "compact", "condensed", "contain", "content",
|
||||
"contents", "content-box", "context-menu", "continuous", "copy", "counter", "counters", "cover",
|
||||
"crop", "cross", "crosshair", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", "destination-in",
|
||||
"destination-out", "destination-over", "difference", "disc", "discard", "disclosure-closed",
|
||||
"disclosure-open", "document", "dot-dash", "dot-dot-dash", "dotted", "double", "down", "e-resize",
|
||||
"ease", "ease-in", "ease-in-out", "ease-out", "element", "ellipse", "ellipsis", "embed", "end",
|
||||
"ethiopic-abegede-gez", "ethiopic-halehame-aa-er", "ethiopic-halehame-gez", "ew-resize", "exclusion",
|
||||
"expanded", "extends", "extra-condensed", "extra-expanded", "fantasy", "fast", "fill", "fill-box",
|
||||
"fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", "forwards", "from",
|
||||
"geometricPrecision", "graytext", "grid", "groove", "hand", "hard-light", "help", "hidden", "hide",
|
||||
"higher", "highlight", "highlighttext", "horizontal", "hsl", "hsla", "hue", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", "infobackground", "infotext",
|
||||
"inherit", "initial", "inline", "inline-axis", "inline-block", "inline-flex", "inline-grid",
|
||||
"inline-table", "inset", "inside", "intrinsic", "invert", "italic", "justify", "keep-all",
|
||||
"landscape", "large", "larger", "left", "level", "lighter", "lighten", "line-through", "linear",
|
||||
"linear-gradient", "lines", "list-item", "listbox", "listitem", "local", "logical", "loud", "lower",
|
||||
"lower-hexadecimal", "lower-latin", "lower-norwegian", "lowercase", "ltr", "luminosity", "manipulation",
|
||||
"match", "matrix", "matrix3d", "medium", "menu", "menutext", "message-box", "middle", "min-intrinsic",
|
||||
"mix", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "n-resize", "narrower",
|
||||
"ne-resize", "nesw-resize", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none",
|
||||
"normal", "not-allowed", "nowrap", "ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize",
|
||||
"oblique", "opacity", "open-quote", "optimizeLegibility", "optimizeSpeed", "outset", "outside",
|
||||
"outside-shape", "overlay", "overline", "padding", "padding-box", "painted", "page", "paused",
|
||||
"perspective", "pinch-zoom", "plus-darker", "plus-lighter", "pointer", "polygon", "portrait",
|
||||
"pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button", "radial-gradient", "radio",
|
||||
"read-only", "read-write", "read-write-plaintext-only", "rectangle", "region", "relative", "repeat",
|
||||
"repeating-linear-gradient", "repeating-radial-gradient", "repeat-x", "repeat-y", "reset", "reverse",
|
||||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", "rotateZ", "round",
|
||||
"row", "row-resize", "row-reverse", "rtl", "run-in", "running", "s-resize", "sans-serif", "saturation",
|
||||
"scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", "scroll", "scrollbar", "scroll-position",
|
||||
"se-resize", "self-start", "self-end", "semi-condensed", "semi-expanded", "separate", "serif", "show",
|
||||
"single", "skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal",
|
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", "small", "small-caps",
|
||||
"small-caption", "smaller", "soft-light", "solid", "source-atop", "source-in", "source-out",
|
||||
"source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", "start",
|
||||
"static", "status-bar", "stretch", "stroke", "stroke-box", "sub", "subpixel-antialiased", "svg_masks",
|
||||
"super", "sw-resize", "symbolic", "symbols", "system-ui", "table", "table-caption", "table-cell",
|
||||
"table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row",
|
||||
"table-row-group", "text", "text-bottom", "text-top", "textarea", "textfield", "thick", "thin",
|
||||
"threeddarkshadow", "threedface", "threedhighlight", "threedlightshadow", "threedshadow", "to", "top",
|
||||
"transform", "translate", "translate3d", "translateX", "translateY", "translateZ", "transparent",
|
||||
"ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", "upper-latin",
|
||||
"uppercase", "url", "var", "vertical", "vertical-text", "view-box", "visible", "visibleFill",
|
||||
"visiblePainted", "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", "window", "windowframe",
|
||||
"windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", "xx-large", "xx-small"
|
||||
].map(name => ({ type: "keyword", label: name })).concat(/*@__PURE__*/[
|
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
||||
"whitesmoke", "yellow", "yellowgreen"
|
||||
].map(name => ({ type: "constant", label: name })));
|
||||
const tags = /*@__PURE__*/[
|
||||
"a", "abbr", "address", "article", "aside", "b", "bdi", "bdo", "blockquote", "body",
|
||||
"br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "dd", "del",
|
||||
"details", "dfn", "dialog", "div", "dl", "dt", "em", "figcaption", "figure", "footer",
|
||||
"form", "header", "hgroup", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe",
|
||||
"img", "input", "ins", "kbd", "label", "legend", "li", "main", "meter", "nav", "ol", "output",
|
||||
"p", "pre", "ruby", "section", "select", "small", "source", "span", "strong", "sub", "summary",
|
||||
"sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "tr", "u", "ul"
|
||||
].map(name => ({ type: "type", label: name }));
|
||||
const atRules = /*@__PURE__*/[
|
||||
"@charset", "@color-profile", "@container", "@counter-style", "@font-face", "@font-feature-values",
|
||||
"@font-palette-values", "@import", "@keyframes", "@layer", "@media", "@namespace", "@page",
|
||||
"@position-try", "@property", "@scope", "@starting-style", "@supports", "@view-transition"
|
||||
].map(label => ({ type: "keyword", label }));
|
||||
const identifier = /^(\w[\w-]*|-\w[\w-]*|)$/, variable = /^-(-[\w-]*)?$/;
|
||||
function isVarArg(node, doc) {
|
||||
var _a;
|
||||
if (node.name == "(" || node.type.isError)
|
||||
node = node.parent || node;
|
||||
if (node.name != "ArgList")
|
||||
return false;
|
||||
let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild;
|
||||
if ((callee === null || callee === void 0 ? void 0 : callee.name) != "Callee")
|
||||
return false;
|
||||
return doc.sliceString(callee.from, callee.to) == "var";
|
||||
}
|
||||
const VariablesByNode = /*@__PURE__*/new NodeWeakMap();
|
||||
const declSelector = ["Declaration"];
|
||||
function astTop(node) {
|
||||
for (let cur = node;;) {
|
||||
if (cur.type.isTop)
|
||||
return cur;
|
||||
if (!(cur = cur.parent))
|
||||
return node;
|
||||
}
|
||||
}
|
||||
function variableNames(doc, node, isVariable) {
|
||||
if (node.to - node.from > 4096) {
|
||||
let known = VariablesByNode.get(node);
|
||||
if (known)
|
||||
return known;
|
||||
let result = [], seen = new Set, cursor = node.cursor(IterMode.IncludeAnonymous);
|
||||
if (cursor.firstChild())
|
||||
do {
|
||||
for (let option of variableNames(doc, cursor.node, isVariable))
|
||||
if (!seen.has(option.label)) {
|
||||
seen.add(option.label);
|
||||
result.push(option);
|
||||
}
|
||||
} while (cursor.nextSibling());
|
||||
VariablesByNode.set(node, result);
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
let result = [], seen = new Set;
|
||||
node.cursor().iterate(node => {
|
||||
var _a;
|
||||
if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == ":") {
|
||||
let name = doc.sliceString(node.from, node.to);
|
||||
if (!seen.has(name)) {
|
||||
seen.add(name);
|
||||
result.push({ label: name, type: "variable" });
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Create a completion source for a CSS dialect, providing a
|
||||
predicate for determining what kind of syntax node can act as a
|
||||
completable variable. This is used by language modes like Sass and
|
||||
Less to reuse this package's completion logic.
|
||||
*/
|
||||
const defineCSSCompletionSource = (isVariable) => context => {
|
||||
let { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1);
|
||||
let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == "-";
|
||||
if (node.name == "PropertyName" ||
|
||||
(isDash || node.name == "TagName") && /^(Block|Styles)$/.test(node.resolve(node.to).name))
|
||||
return { from: node.from, options: properties(), validFor: identifier };
|
||||
if (node.name == "ValueName")
|
||||
return { from: node.from, options: values, validFor: identifier };
|
||||
if (node.name == "PseudoClassName")
|
||||
return { from: node.from, options: pseudoClasses, validFor: identifier };
|
||||
if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc))
|
||||
return { from: isVariable(node) || isDash ? node.from : pos,
|
||||
options: variableNames(state.doc, astTop(node), isVariable),
|
||||
validFor: variable };
|
||||
if (node.name == "TagName") {
|
||||
for (let { parent } = node; parent; parent = parent.parent)
|
||||
if (parent.name == "Block")
|
||||
return { from: node.from, options: properties(), validFor: identifier };
|
||||
return { from: node.from, options: tags, validFor: identifier };
|
||||
}
|
||||
if (node.name == "AtKeyword")
|
||||
return { from: node.from, options: atRules, validFor: identifier };
|
||||
if (!context.explicit)
|
||||
return null;
|
||||
let above = node.resolve(pos), before = above.childBefore(pos);
|
||||
if (before && before.name == ":" && above.name == "PseudoClassSelector")
|
||||
return { from: pos, options: pseudoClasses, validFor: identifier };
|
||||
if (before && before.name == ":" && above.name == "Declaration" || above.name == "ArgList")
|
||||
return { from: pos, options: values, validFor: identifier };
|
||||
if (above.name == "Block" || above.name == "Styles")
|
||||
return { from: pos, options: properties(), validFor: identifier };
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
CSS property, variable, and value keyword completion source.
|
||||
*/
|
||||
const cssCompletionSource = /*@__PURE__*/defineCSSCompletionSource(n => n.name == "VariableName");
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer CSS
|
||||
parser](https://github.com/lezer-parser/css), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const cssLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "css",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
Declaration: /*@__PURE__*/continuedIndent()
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
"Block KeyframeList": foldInside
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "/*", close: "*/" } },
|
||||
indentOnInput: /^\s*\}$/,
|
||||
wordChars: "-"
|
||||
}
|
||||
});
|
||||
/**
|
||||
Language support for CSS.
|
||||
*/
|
||||
function css() {
|
||||
return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));
|
||||
}
|
||||
|
||||
export { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };
|
||||
42
node_modules/@codemirror/lang-css/package.json
generated
vendored
Normal file
42
node_modules/@codemirror/lang-css/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@codemirror/lang-css",
|
||||
"version": "6.3.1",
|
||||
"description": "CSS language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/css.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@lezer/common": "^1.0.2",
|
||||
"@lezer/css": "^1.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lang-css.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-html/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
198
node_modules/@codemirror/lang-html/CHANGELOG.md
generated
vendored
Normal file
198
node_modules/@codemirror/lang-html/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
## 6.4.9 (2024-04-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in `autoCloseTags` that made tags not close when typing > after an attribute.
|
||||
|
||||
## 6.4.8 (2024-01-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Complete attribute names after whitespace in a tag even when completion isn't explicitly triggered.
|
||||
|
||||
## 6.4.7 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Parse `script` tags with `application/json` type as JSON syntax.
|
||||
|
||||
## 6.4.6 (2023-08-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`autoCloseTags` now generates two separate transactions, so that the completion can be undone separately.
|
||||
|
||||
Add highlighting for the content of `<script>` tags with a type of `importmap` or `speculationrules`.
|
||||
|
||||
## 6.4.5 (2023-06-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where HTML autocompletion didn't work when the cursor was at the end of a bit of HTML code inside a mixed-language document.
|
||||
|
||||
## 6.4.4 (2023-06-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where the completed tag names didn't take into account the parent node's declared children in the schema in some circumstances.
|
||||
|
||||
## 6.4.3 (2023-03-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that could cause some nested language regions to be parsed multiple times.
|
||||
|
||||
## 6.4.2 (2023-02-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `autoCloseTags` would close self-closing tags when typed directly in front of a word.
|
||||
|
||||
## 6.4.1 (2023-01-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use only the tag name for matching of opening and closing tags.
|
||||
|
||||
## 6.4.0 (2022-11-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Directly depend on @lang/css 1.1.0, since we're using a new top rule name introduced in that.
|
||||
|
||||
### New features
|
||||
|
||||
Add a `globalAttrs` property to (completion) `TagSpec` objects that controls whether global attributes are completed in that tag.
|
||||
|
||||
## 6.3.1 (2022-11-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove incorrect pure annotation that broke the code after tree-shaking.
|
||||
|
||||
## 6.3.0 (2022-11-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Parse type=text/babel script tags as JSX.
|
||||
|
||||
### New features
|
||||
|
||||
The new `nestedLanguages` option can be used to configure how the content of script, style, and textarea tags is parsed.
|
||||
|
||||
The content of style attributes will now be parsed as CSS, and the content of on[event] attributes as JavaScript. The new `nestedAttributes` option can be used to configure the parsing of other attribute values.
|
||||
|
||||
## 6.2.0 (2022-11-16)
|
||||
|
||||
### New features
|
||||
|
||||
Add a `selfClosingTags` option to `html` that enables `/>` syntax.
|
||||
|
||||
## 6.1.4 (2022-11-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Parse the content of text/javascript or lang=ts script tags as TypeScript, use JS for text/jsx, and TSX for text/typescript-jsx.
|
||||
|
||||
## 6.1.3 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove deprecated HTML tags from the completions.
|
||||
|
||||
## 6.1.2 (2022-09-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make tag auto-closing consume `>` characters after the cursor.
|
||||
|
||||
## 6.1.1 (2022-09-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Properly list the dependency on @codemirror/view in package.json.
|
||||
|
||||
## 6.1.0 (2022-06-22)
|
||||
|
||||
### New features
|
||||
|
||||
It is now possible to pass in options to extend the set of tags and attributes provided by autocompletion.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### New features
|
||||
|
||||
Autocompletion now suggests the `<template>` and `<slot>` elements.
|
||||
|
||||
## 0.19.4 (2021-11-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where autoclosing a tag directly in front of alphanumeric text would include nonsense text in the completed tag name.
|
||||
|
||||
## 0.19.3 (2021-09-23)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a completion source function, rather than a prebuilt completion extension.
|
||||
|
||||
Use more specific highlighting tags for attribute names and values.
|
||||
|
||||
## 0.19.2 (2021-09-21)
|
||||
|
||||
### New features
|
||||
|
||||
The new `autoCloseTags` extension (included by default in `html()`) finishes closing tags when you type a `>` or `/` character.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve autocompletion in/after unclosed opening tags.
|
||||
|
||||
### New features
|
||||
|
||||
`html()` now takes a `matchClosingTags` option to turn off closing tag matching.
|
||||
|
||||
## 0.18.1 (2021-05-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the completer would sometimes try to complete an opening tag to its own close tag.
|
||||
|
||||
Fix a bug that would sometimes produce the wrong indentation in HTML elements.
|
||||
|
||||
Fix a bug that broke tag-specific attribute completion in tags like `<input>` or `<script>`.
|
||||
|
||||
Move a new version of lezer-html which solves some issues with autocompletion.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improves indentation at end of implicitly closed elements.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lang-html/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-html/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
128
node_modules/@codemirror/lang-html/README.md
generated
vendored
Normal file
128
node_modules/@codemirror/lang-html/README.md
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-html [](https://www.npmjs.org/package/@codemirror/lang-html)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-html/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements HTML language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-html/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## API Reference
|
||||
|
||||
<dl>
|
||||
<dt id="user-content-html">
|
||||
<code><strong><a href="#user-content-html">html</a></strong>(<a id="user-content-html^config" href="#user-content-html^config">config</a>⁠?: {selfClosingTags⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>} = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>Language support for HTML, including
|
||||
<a href="#user-content-htmlcompletion"><code>htmlCompletion</code></a> and JavaScript and
|
||||
CSS support extensions.</p>
|
||||
<dl><dt id="user-content-html^config">
|
||||
<code><strong><a href="#user-content-html^config">config</a></strong></code></dt>
|
||||
|
||||
<dd><dl><dt id="user-content-html^config.matchclosingtags">
|
||||
<code><strong><a href="#user-content-html^config.matchclosingtags">matchClosingTags</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>By default, the syntax tree will highlight mismatched closing
|
||||
tags. Set this to <code>false</code> to turn that off (for example when you
|
||||
expect to only be parsing a fragment of HTML text, not a full
|
||||
document).</p>
|
||||
</dd><dt id="user-content-html^config.autoclosetags">
|
||||
<code><strong><a href="#user-content-html^config.autoclosetags">autoCloseTags</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>Determines whether <a href="#user-content-autoclosetags"><code>autoCloseTags</code></a>
|
||||
is included in the support extensions. Defaults to true.</p>
|
||||
</dd><dt id="user-content-html^config.extratags">
|
||||
<code><strong><a href="#user-content-html^config.extratags">extraTags</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeystype">Record</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#user-content-tagspec">TagSpec</a>></code></dt>
|
||||
|
||||
<dd><p>Add additional tags that can be completed.</p>
|
||||
</dd><dt id="user-content-html^config.extraglobalattributes">
|
||||
<code><strong><a href="#user-content-html^config.extraglobalattributes">extraGlobalAttributes</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeystype">Record</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[] | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a>></code></dt>
|
||||
|
||||
<dd><p>Add additional completable attributes to all tags.</p>
|
||||
</dd><dt id="user-content-html^config.nestedlanguages">
|
||||
<code><strong><a href="#user-content-html^config.nestedlanguages">nestedLanguages</a></strong>⁠?: {tag: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, attrs⁠?: fn(<a id="user-content-html^config.nestedlanguages.attrs^attrs" href="#user-content-html^config.nestedlanguages.attrs^attrs">attrs</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>) → <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, parser: <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a>}[]</code></dt>
|
||||
|
||||
<dd><p>Register additional languages to parse the content of specific
|
||||
tags. If given, <code>attrs</code> should be a function that, given an
|
||||
object representing the tag's attributes, returns <code>true</code> if this
|
||||
language applies.</p>
|
||||
</dd><dt id="user-content-html^config.nestedattributes">
|
||||
<code><strong><a href="#user-content-html^config.nestedattributes">nestedAttributes</a></strong>⁠?: {name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, tagName⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, parser: <a href="https://lezer.codemirror.net/docs/ref/#common.Parser">Parser</a>}[]</code></dt>
|
||||
|
||||
<dd><p>Register additional languages to parse attribute values with.</p>
|
||||
</dd></dl></dd></dl></dd>
|
||||
<dt id="user-content-htmllanguage">
|
||||
<code><strong><a href="#user-content-htmllanguage">htmlLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/html">Lezer HTML
|
||||
parser</a>, extended with the
|
||||
JavaScript and CSS parsers to parse the content of <code><script></code> and
|
||||
<code><style></code> tags.</p>
|
||||
</dd>
|
||||
<dt id="user-content-htmlcompletionsource">
|
||||
<code><strong><a href="#user-content-htmlcompletionsource">htmlCompletionSource</a></strong>(<a id="user-content-htmlcompletionsource^context" href="#user-content-htmlcompletionsource^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionResult">CompletionResult</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
|
||||
|
||||
<dd><p>HTML tag completion. Opens and closes tags and attributes in a
|
||||
context-aware way.</p>
|
||||
</dd>
|
||||
<dt id="user-content-tagspec">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-tagspec">TagSpec</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Type used to specify tags to complete.</p>
|
||||
<dl><dt id="user-content-tagspec.attrs">
|
||||
<code><strong><a href="#user-content-tagspec.attrs">attrs</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeystype">Record</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[] | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a>></code></dt>
|
||||
|
||||
<dd><p>Define tag-specific attributes. Property names are attribute
|
||||
names, and property values can be null to indicate free-form
|
||||
attributes, or a list of strings for suggested attribute values.</p>
|
||||
</dd><dt id="user-content-tagspec.globalattrs">
|
||||
<code><strong><a href="#user-content-tagspec.globalattrs">globalAttrs</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>When set to false, don't complete global attributes on this tag.</p>
|
||||
</dd><dt id="user-content-tagspec.children">
|
||||
<code><strong><a href="#user-content-tagspec.children">children</a></strong>⁠?: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[]</code></dt>
|
||||
|
||||
<dd><p>Can be used to specify a list of child tags that are valid
|
||||
inside this tag. The default is to allow any tag.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
<dt id="user-content-htmlcompletionsourcewith">
|
||||
<code><strong><a href="#user-content-htmlcompletionsourcewith">htmlCompletionSourceWith</a></strong>(<a id="user-content-htmlcompletionsourcewith^config" href="#user-content-htmlcompletionsourcewith^config">config</a>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>) → fn(<a id="user-content-htmlcompletionsourcewith^returns^context" href="#user-content-htmlcompletionsourcewith^returns^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionResult">CompletionResult</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
|
||||
|
||||
<dd><p>Create a completion source for HTML extended with additional tags
|
||||
or attributes.</p>
|
||||
<dl><dt id="user-content-htmlcompletionsourcewith^config">
|
||||
<code><strong><a href="#user-content-htmlcompletionsourcewith^config">config</a></strong></code></dt>
|
||||
|
||||
<dd><dl><dt id="user-content-htmlcompletionsourcewith^config.extratags">
|
||||
<code><strong><a href="#user-content-htmlcompletionsourcewith^config.extratags">extraTags</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeystype">Record</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, <a href="#user-content-tagspec">TagSpec</a>></code></dt>
|
||||
|
||||
<dd><p>Define extra tag names to complete.</p>
|
||||
</dd><dt id="user-content-htmlcompletionsourcewith^config.extraglobalattributes">
|
||||
<code><strong><a href="#user-content-htmlcompletionsourcewith^config.extraglobalattributes">extraGlobalAttributes</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeystype">Record</a><<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[] | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a>></code></dt>
|
||||
|
||||
<dd><p>Add global attributes that are available on all tags.</p>
|
||||
</dd></dl></dd></dl></dd>
|
||||
<dt id="user-content-autoclosetags">
|
||||
<code><strong><a href="#user-content-autoclosetags">autoCloseTags</a></strong>: <a href="https://codemirror.net/docs/ref#state.Extension">Extension</a></code></dt>
|
||||
|
||||
<dd><p>Extension that will automatically insert close tags when a <code>></code> or
|
||||
<code>/</code> is typed.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
674
node_modules/@codemirror/lang-html/dist/index.cjs
generated
vendored
Normal file
674
node_modules/@codemirror/lang-html/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,674 @@
|
||||
'use strict';
|
||||
|
||||
var html$1 = require('@lezer/html');
|
||||
var langCss = require('@codemirror/lang-css');
|
||||
var langJavascript = require('@codemirror/lang-javascript');
|
||||
var view = require('@codemirror/view');
|
||||
var state = require('@codemirror/state');
|
||||
var language = require('@codemirror/language');
|
||||
|
||||
const Targets = ["_blank", "_self", "_top", "_parent"];
|
||||
const Charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
|
||||
const Methods = ["get", "post", "put", "delete"];
|
||||
const Encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
|
||||
const Bool = ["true", "false"];
|
||||
const S = {}; // Empty tag spec
|
||||
const Tags = {
|
||||
a: {
|
||||
attrs: {
|
||||
href: null, ping: null, type: null,
|
||||
media: null,
|
||||
target: Targets,
|
||||
hreflang: null
|
||||
}
|
||||
},
|
||||
abbr: S,
|
||||
address: S,
|
||||
area: {
|
||||
attrs: {
|
||||
alt: null, coords: null, href: null, target: null, ping: null,
|
||||
media: null, hreflang: null, type: null,
|
||||
shape: ["default", "rect", "circle", "poly"]
|
||||
}
|
||||
},
|
||||
article: S,
|
||||
aside: S,
|
||||
audio: {
|
||||
attrs: {
|
||||
src: null, mediagroup: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["none", "metadata", "auto"],
|
||||
autoplay: ["autoplay"],
|
||||
loop: ["loop"],
|
||||
controls: ["controls"]
|
||||
}
|
||||
},
|
||||
b: S,
|
||||
base: { attrs: { href: null, target: Targets } },
|
||||
bdi: S,
|
||||
bdo: S,
|
||||
blockquote: { attrs: { cite: null } },
|
||||
body: S,
|
||||
br: S,
|
||||
button: {
|
||||
attrs: {
|
||||
form: null, formaction: null, name: null, value: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["autofocus"],
|
||||
formenctype: Encs,
|
||||
formmethod: Methods,
|
||||
formnovalidate: ["novalidate"],
|
||||
formtarget: Targets,
|
||||
type: ["submit", "reset", "button"]
|
||||
}
|
||||
},
|
||||
canvas: { attrs: { width: null, height: null } },
|
||||
caption: S,
|
||||
center: S,
|
||||
cite: S,
|
||||
code: S,
|
||||
col: { attrs: { span: null } },
|
||||
colgroup: { attrs: { span: null } },
|
||||
command: {
|
||||
attrs: {
|
||||
type: ["command", "checkbox", "radio"],
|
||||
label: null, icon: null, radiogroup: null, command: null, title: null,
|
||||
disabled: ["disabled"],
|
||||
checked: ["checked"]
|
||||
}
|
||||
},
|
||||
data: { attrs: { value: null } },
|
||||
datagrid: { attrs: { disabled: ["disabled"], multiple: ["multiple"] } },
|
||||
datalist: { attrs: { data: null } },
|
||||
dd: S,
|
||||
del: { attrs: { cite: null, datetime: null } },
|
||||
details: { attrs: { open: ["open"] } },
|
||||
dfn: S,
|
||||
div: S,
|
||||
dl: S,
|
||||
dt: S,
|
||||
em: S,
|
||||
embed: { attrs: { src: null, type: null, width: null, height: null } },
|
||||
eventsource: { attrs: { src: null } },
|
||||
fieldset: { attrs: { disabled: ["disabled"], form: null, name: null } },
|
||||
figcaption: S,
|
||||
figure: S,
|
||||
footer: S,
|
||||
form: {
|
||||
attrs: {
|
||||
action: null, name: null,
|
||||
"accept-charset": Charsets,
|
||||
autocomplete: ["on", "off"],
|
||||
enctype: Encs,
|
||||
method: Methods,
|
||||
novalidate: ["novalidate"],
|
||||
target: Targets
|
||||
}
|
||||
},
|
||||
h1: S, h2: S, h3: S, h4: S, h5: S, h6: S,
|
||||
head: {
|
||||
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
|
||||
},
|
||||
header: S,
|
||||
hgroup: S,
|
||||
hr: S,
|
||||
html: {
|
||||
attrs: { manifest: null }
|
||||
},
|
||||
i: S,
|
||||
iframe: {
|
||||
attrs: {
|
||||
src: null, srcdoc: null, name: null, width: null, height: null,
|
||||
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
|
||||
seamless: ["seamless"]
|
||||
}
|
||||
},
|
||||
img: {
|
||||
attrs: {
|
||||
alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"]
|
||||
}
|
||||
},
|
||||
input: {
|
||||
attrs: {
|
||||
alt: null, dirname: null, form: null, formaction: null,
|
||||
height: null, list: null, max: null, maxlength: null, min: null,
|
||||
name: null, pattern: null, placeholder: null, size: null, src: null,
|
||||
step: null, value: null, width: null,
|
||||
accept: ["audio/*", "video/*", "image/*"],
|
||||
autocomplete: ["on", "off"],
|
||||
autofocus: ["autofocus"],
|
||||
checked: ["checked"],
|
||||
disabled: ["disabled"],
|
||||
formenctype: Encs,
|
||||
formmethod: Methods,
|
||||
formnovalidate: ["novalidate"],
|
||||
formtarget: Targets,
|
||||
multiple: ["multiple"],
|
||||
readonly: ["readonly"],
|
||||
required: ["required"],
|
||||
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
|
||||
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
||||
"file", "submit", "image", "reset", "button"]
|
||||
}
|
||||
},
|
||||
ins: { attrs: { cite: null, datetime: null } },
|
||||
kbd: S,
|
||||
keygen: {
|
||||
attrs: {
|
||||
challenge: null, form: null, name: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
keytype: ["RSA"]
|
||||
}
|
||||
},
|
||||
label: { attrs: { for: null, form: null } },
|
||||
legend: S,
|
||||
li: { attrs: { value: null } },
|
||||
link: {
|
||||
attrs: {
|
||||
href: null, type: null,
|
||||
hreflang: null,
|
||||
media: null,
|
||||
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
|
||||
}
|
||||
},
|
||||
map: { attrs: { name: null } },
|
||||
mark: S,
|
||||
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
|
||||
meta: {
|
||||
attrs: {
|
||||
content: null,
|
||||
charset: Charsets,
|
||||
name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
|
||||
"http-equiv": ["content-language", "content-type", "default-style", "refresh"]
|
||||
}
|
||||
},
|
||||
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
|
||||
nav: S,
|
||||
noscript: S,
|
||||
object: {
|
||||
attrs: {
|
||||
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
|
||||
typemustmatch: ["typemustmatch"]
|
||||
}
|
||||
},
|
||||
ol: { attrs: { reversed: ["reversed"], start: null, type: ["1", "a", "A", "i", "I"] },
|
||||
children: ["li", "script", "template", "ul", "ol"] },
|
||||
optgroup: { attrs: { disabled: ["disabled"], label: null } },
|
||||
option: { attrs: { disabled: ["disabled"], label: null, selected: ["selected"], value: null } },
|
||||
output: { attrs: { for: null, form: null, name: null } },
|
||||
p: S,
|
||||
param: { attrs: { name: null, value: null } },
|
||||
pre: S,
|
||||
progress: { attrs: { value: null, max: null } },
|
||||
q: { attrs: { cite: null } },
|
||||
rp: S,
|
||||
rt: S,
|
||||
ruby: S,
|
||||
samp: S,
|
||||
script: {
|
||||
attrs: {
|
||||
type: ["text/javascript"],
|
||||
src: null,
|
||||
async: ["async"],
|
||||
defer: ["defer"],
|
||||
charset: Charsets
|
||||
}
|
||||
},
|
||||
section: S,
|
||||
select: {
|
||||
attrs: {
|
||||
form: null, name: null, size: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
multiple: ["multiple"]
|
||||
}
|
||||
},
|
||||
slot: { attrs: { name: null } },
|
||||
small: S,
|
||||
source: { attrs: { src: null, type: null, media: null } },
|
||||
span: S,
|
||||
strong: S,
|
||||
style: {
|
||||
attrs: {
|
||||
type: ["text/css"],
|
||||
media: null,
|
||||
scoped: null
|
||||
}
|
||||
},
|
||||
sub: S,
|
||||
summary: S,
|
||||
sup: S,
|
||||
table: S,
|
||||
tbody: S,
|
||||
td: { attrs: { colspan: null, rowspan: null, headers: null } },
|
||||
template: S,
|
||||
textarea: {
|
||||
attrs: {
|
||||
dirname: null, form: null, maxlength: null, name: null, placeholder: null,
|
||||
rows: null, cols: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
readonly: ["readonly"],
|
||||
required: ["required"],
|
||||
wrap: ["soft", "hard"]
|
||||
}
|
||||
},
|
||||
tfoot: S,
|
||||
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
|
||||
thead: S,
|
||||
time: { attrs: { datetime: null } },
|
||||
title: S,
|
||||
tr: S,
|
||||
track: {
|
||||
attrs: {
|
||||
src: null, label: null, default: null,
|
||||
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
|
||||
srclang: null
|
||||
}
|
||||
},
|
||||
ul: { children: ["li", "script", "template", "ul", "ol"] },
|
||||
var: S,
|
||||
video: {
|
||||
attrs: {
|
||||
src: null, poster: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["auto", "metadata", "none"],
|
||||
autoplay: ["autoplay"],
|
||||
mediagroup: ["movie"],
|
||||
muted: ["muted"],
|
||||
controls: ["controls"]
|
||||
}
|
||||
},
|
||||
wbr: S
|
||||
};
|
||||
const GlobalAttrs = {
|
||||
accesskey: null,
|
||||
class: null,
|
||||
contenteditable: Bool,
|
||||
contextmenu: null,
|
||||
dir: ["ltr", "rtl", "auto"],
|
||||
draggable: ["true", "false", "auto"],
|
||||
dropzone: ["copy", "move", "link", "string:", "file:"],
|
||||
hidden: ["hidden"],
|
||||
id: null,
|
||||
inert: ["inert"],
|
||||
itemid: null,
|
||||
itemprop: null,
|
||||
itemref: null,
|
||||
itemscope: ["itemscope"],
|
||||
itemtype: null,
|
||||
lang: ["ar", "bn", "de", "en-GB", "en-US", "es", "fr", "hi", "id", "ja", "pa", "pt", "ru", "tr", "zh"],
|
||||
spellcheck: Bool,
|
||||
autocorrect: Bool,
|
||||
autocapitalize: Bool,
|
||||
style: null,
|
||||
tabindex: null,
|
||||
title: null,
|
||||
translate: ["yes", "no"],
|
||||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"],
|
||||
role: "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),
|
||||
"aria-activedescendant": null,
|
||||
"aria-atomic": Bool,
|
||||
"aria-autocomplete": ["inline", "list", "both", "none"],
|
||||
"aria-busy": Bool,
|
||||
"aria-checked": ["true", "false", "mixed", "undefined"],
|
||||
"aria-controls": null,
|
||||
"aria-describedby": null,
|
||||
"aria-disabled": Bool,
|
||||
"aria-dropeffect": null,
|
||||
"aria-expanded": ["true", "false", "undefined"],
|
||||
"aria-flowto": null,
|
||||
"aria-grabbed": ["true", "false", "undefined"],
|
||||
"aria-haspopup": Bool,
|
||||
"aria-hidden": Bool,
|
||||
"aria-invalid": ["true", "false", "grammar", "spelling"],
|
||||
"aria-label": null,
|
||||
"aria-labelledby": null,
|
||||
"aria-level": null,
|
||||
"aria-live": ["off", "polite", "assertive"],
|
||||
"aria-multiline": Bool,
|
||||
"aria-multiselectable": Bool,
|
||||
"aria-owns": null,
|
||||
"aria-posinset": null,
|
||||
"aria-pressed": ["true", "false", "mixed", "undefined"],
|
||||
"aria-readonly": Bool,
|
||||
"aria-relevant": null,
|
||||
"aria-required": Bool,
|
||||
"aria-selected": ["true", "false", "undefined"],
|
||||
"aria-setsize": null,
|
||||
"aria-sort": ["ascending", "descending", "none", "other"],
|
||||
"aria-valuemax": null,
|
||||
"aria-valuemin": null,
|
||||
"aria-valuenow": null,
|
||||
"aria-valuetext": null
|
||||
};
|
||||
const eventAttributes = ("beforeunload copy cut dragstart dragover dragleave dragenter dragend " +
|
||||
"drag paste focus blur change click load mousedown mouseenter mouseleave " +
|
||||
"mouseup keydown keyup resize scroll unload").split(" ").map(n => "on" + n);
|
||||
for (let a of eventAttributes)
|
||||
GlobalAttrs[a] = null;
|
||||
class Schema {
|
||||
constructor(extraTags, extraAttrs) {
|
||||
this.tags = Object.assign(Object.assign({}, Tags), extraTags);
|
||||
this.globalAttrs = Object.assign(Object.assign({}, GlobalAttrs), extraAttrs);
|
||||
this.allTags = Object.keys(this.tags);
|
||||
this.globalAttrNames = Object.keys(this.globalAttrs);
|
||||
}
|
||||
}
|
||||
Schema.default = new Schema;
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
if (!tree)
|
||||
return "";
|
||||
let tag = tree.firstChild;
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : "";
|
||||
}
|
||||
function findParentElement(tree, skip = false) {
|
||||
for (; tree; tree = tree.parent)
|
||||
if (tree.name == "Element") {
|
||||
if (skip)
|
||||
skip = false;
|
||||
else
|
||||
return tree;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function allowedChildren(doc, tree, schema) {
|
||||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree))];
|
||||
return (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.children) || schema.allTags;
|
||||
}
|
||||
function openTags(doc, tree) {
|
||||
let open = [];
|
||||
for (let parent = findParentElement(tree); parent && !parent.type.isTop; parent = findParentElement(parent.parent)) {
|
||||
let tagName = elementName(doc, parent);
|
||||
if (tagName && parent.lastChild.name == "CloseTag")
|
||||
break;
|
||||
if (tagName && open.indexOf(tagName) < 0 && (tree.name == "EndTag" || tree.from >= parent.firstChild.to))
|
||||
open.push(tagName);
|
||||
}
|
||||
return open;
|
||||
}
|
||||
const identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
|
||||
function completeTag(state, schema, tree, from, to) {
|
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">";
|
||||
let parent = findParentElement(tree, true);
|
||||
return { from, to,
|
||||
options: allowedChildren(state.doc, parent, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end,
|
||||
type: "type", boost: 99 - i }))),
|
||||
validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/ };
|
||||
}
|
||||
function completeCloseTag(state, tree, from, to) {
|
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">";
|
||||
return { from, to,
|
||||
options: openTags(state.doc, tree).map((tag, i) => ({ label: tag, apply: tag + end, type: "type", boost: 99 - i })),
|
||||
validFor: identifier };
|
||||
}
|
||||
function completeStartTag(state, schema, tree, pos) {
|
||||
let options = [], level = 0;
|
||||
for (let tagName of allowedChildren(state.doc, tree, schema))
|
||||
options.push({ label: "<" + tagName, type: "type" });
|
||||
for (let open of openTags(state.doc, tree))
|
||||
options.push({ label: "</" + open + ">", type: "type", boost: 99 - level++ });
|
||||
return { from: pos, to: pos, options, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ };
|
||||
}
|
||||
function completeAttrName(state, schema, tree, from, to) {
|
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null;
|
||||
let localAttrs = info && info.attrs ? Object.keys(info.attrs) : [];
|
||||
let names = info && info.globalAttrs === false ? localAttrs
|
||||
: localAttrs.length ? localAttrs.concat(schema.globalAttrNames) : schema.globalAttrNames;
|
||||
return { from, to,
|
||||
options: names.map(attrName => ({ label: attrName, type: "property" })),
|
||||
validFor: identifier };
|
||||
}
|
||||
function completeAttrValue(state, schema, tree, from, to) {
|
||||
var _a;
|
||||
let nameNode = (_a = tree.parent) === null || _a === void 0 ? void 0 : _a.getChild("AttributeName");
|
||||
let options = [], token = undefined;
|
||||
if (nameNode) {
|
||||
let attrName = state.sliceDoc(nameNode.from, nameNode.to);
|
||||
let attrs = schema.globalAttrs[attrName];
|
||||
if (!attrs) {
|
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null;
|
||||
attrs = (info === null || info === void 0 ? void 0 : info.attrs) && info.attrs[attrName];
|
||||
}
|
||||
if (attrs) {
|
||||
let base = state.sliceDoc(from, to).toLowerCase(), quoteStart = '"', quoteEnd = '"';
|
||||
if (/^['"]/.test(base)) {
|
||||
token = base[0] == '"' ? /^[^"]*$/ : /^[^']*$/;
|
||||
quoteStart = "";
|
||||
quoteEnd = state.sliceDoc(to, to + 1) == base[0] ? "" : base[0];
|
||||
base = base.slice(1);
|
||||
from++;
|
||||
}
|
||||
else {
|
||||
token = /^[^\s<>='"]*$/;
|
||||
}
|
||||
for (let value of attrs)
|
||||
options.push({ label: value, apply: quoteStart + value + quoteEnd, type: "constant" });
|
||||
}
|
||||
}
|
||||
return { from, to, options, validFor: token };
|
||||
}
|
||||
function htmlCompletionFor(schema, context) {
|
||||
let { state, pos } = context, tree = language.syntaxTree(state).resolveInner(pos, -1), around = tree.resolve(pos);
|
||||
for (let scan = pos, before; around == tree && (before = tree.childBefore(scan));) {
|
||||
let last = before.lastChild;
|
||||
if (!last || !last.type.isError || last.from < last.to)
|
||||
break;
|
||||
around = tree = before;
|
||||
scan = last.from;
|
||||
}
|
||||
if (tree.name == "TagName") {
|
||||
return tree.parent && /CloseTag$/.test(tree.parent.name) ? completeCloseTag(state, tree, tree.from, pos)
|
||||
: completeTag(state, schema, tree, tree.from, pos);
|
||||
}
|
||||
else if (tree.name == "StartTag") {
|
||||
return completeTag(state, schema, tree, pos, pos);
|
||||
}
|
||||
else if (tree.name == "StartCloseTag" || tree.name == "IncompleteCloseTag") {
|
||||
return completeCloseTag(state, tree, pos, pos);
|
||||
}
|
||||
else if (tree.name == "OpenTag" || tree.name == "SelfClosingTag" || tree.name == "AttributeName") {
|
||||
return completeAttrName(state, schema, tree, tree.name == "AttributeName" ? tree.from : pos, pos);
|
||||
}
|
||||
else if (tree.name == "Is" || tree.name == "AttributeValue" || tree.name == "UnquotedAttributeValue") {
|
||||
return completeAttrValue(state, schema, tree, tree.name == "Is" ? pos : tree.from, pos);
|
||||
}
|
||||
else if (context.explicit && (around.name == "Element" || around.name == "Text" || around.name == "Document")) {
|
||||
return completeStartTag(state, schema, tree, pos);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
HTML tag completion. Opens and closes tags and attributes in a
|
||||
context-aware way.
|
||||
*/
|
||||
function htmlCompletionSource(context) {
|
||||
return htmlCompletionFor(Schema.default, context);
|
||||
}
|
||||
/**
|
||||
Create a completion source for HTML extended with additional tags
|
||||
or attributes.
|
||||
*/
|
||||
function htmlCompletionSourceWith(config) {
|
||||
let { extraTags, extraGlobalAttributes: extraAttrs } = config;
|
||||
let schema = extraAttrs || extraTags ? new Schema(extraTags, extraAttrs) : Schema.default;
|
||||
return (context) => htmlCompletionFor(schema, context);
|
||||
}
|
||||
|
||||
const jsonParser = langJavascript.javascriptLanguage.parser.configure({ top: "SingleExpression" });
|
||||
const defaultNesting = [
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/typescript" || attrs.lang == "ts",
|
||||
parser: langJavascript.typescriptLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/babel" || attrs.type == "text/jsx",
|
||||
parser: langJavascript.jsxLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/typescript-jsx",
|
||||
parser: langJavascript.tsxLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs(attrs) {
|
||||
return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(attrs.type);
|
||||
},
|
||||
parser: jsonParser },
|
||||
{ tag: "script",
|
||||
attrs(attrs) {
|
||||
return !attrs.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type);
|
||||
},
|
||||
parser: langJavascript.javascriptLanguage.parser },
|
||||
{ tag: "style",
|
||||
attrs(attrs) {
|
||||
return (!attrs.lang || attrs.lang == "css") && (!attrs.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(attrs.type));
|
||||
},
|
||||
parser: langCss.cssLanguage.parser }
|
||||
];
|
||||
const defaultAttrs = [
|
||||
{ name: "style",
|
||||
parser: langCss.cssLanguage.parser.configure({ top: "Styles" }) }
|
||||
].concat(eventAttributes.map(name => ({ name, parser: langJavascript.javascriptLanguage.parser })));
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
const htmlPlain = language.LRLanguage.define({
|
||||
name: "html",
|
||||
parser: html$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
Element(context) {
|
||||
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
||||
if (context.node.to <= context.pos + after[0].length)
|
||||
return context.continue();
|
||||
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
||||
},
|
||||
"OpenTag CloseTag SelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
},
|
||||
Document(context) {
|
||||
if (context.pos + /\s*/.exec(context.textAfter)[0].length < context.node.to)
|
||||
return context.continue();
|
||||
let endElt = null, close;
|
||||
for (let cur = context.node;;) {
|
||||
let last = cur.lastChild;
|
||||
if (!last || last.name != "Element" || last.to != cur.to)
|
||||
break;
|
||||
endElt = cur = last;
|
||||
}
|
||||
if (endElt && !((close = endElt.lastChild) && (close.name == "CloseTag" || close.name == "SelfClosingTag")))
|
||||
return context.lineIndent(endElt.from) + context.unit;
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
Element(node) {
|
||||
let first = node.firstChild, last = node.lastChild;
|
||||
if (!first || first.name != "OpenTag")
|
||||
return null;
|
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : node.to };
|
||||
}
|
||||
}),
|
||||
language.bracketMatchingHandle.add({
|
||||
"OpenTag CloseTag": node => node.getChild("TagName")
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "<!--", close: "-->" } },
|
||||
indentOnInput: /^\s*<\/\w+\W$/,
|
||||
wordChars: "-._"
|
||||
}
|
||||
});
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
const htmlLanguage = htmlPlain.configure({
|
||||
wrap: html$1.configureNesting(defaultNesting, defaultAttrs)
|
||||
});
|
||||
/**
|
||||
Language support for HTML, including
|
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions.
|
||||
*/
|
||||
function html(config = {}) {
|
||||
let dialect = "", wrap;
|
||||
if (config.matchClosingTags === false)
|
||||
dialect = "noMatch";
|
||||
if (config.selfClosingTags === true)
|
||||
dialect = (dialect ? dialect + " " : "") + "selfClosing";
|
||||
if (config.nestedLanguages && config.nestedLanguages.length ||
|
||||
config.nestedAttributes && config.nestedAttributes.length)
|
||||
wrap = html$1.configureNesting((config.nestedLanguages || []).concat(defaultNesting), (config.nestedAttributes || []).concat(defaultAttrs));
|
||||
let lang = wrap ? htmlPlain.configure({ wrap, dialect }) : dialect ? htmlLanguage.configure({ dialect }) : htmlLanguage;
|
||||
return new language.LanguageSupport(lang, [
|
||||
htmlLanguage.data.of({ autocomplete: htmlCompletionSourceWith(config) }),
|
||||
config.autoCloseTags !== false ? autoCloseTags : [],
|
||||
langJavascript.javascript().support,
|
||||
langCss.css().support
|
||||
]);
|
||||
}
|
||||
const selfClosers = new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
|
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") ||
|
||||
!htmlLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = insertTransaction(), { state: state$1 } = base;
|
||||
let closeTags = state$1.changeByRange(range => {
|
||||
var _a, _b, _c;
|
||||
let didType = state$1.doc.sliceString(range.from - 1, range.to) == text;
|
||||
let { head } = range, after = language.syntaxTree(state$1).resolveInner(head, -1), name;
|
||||
if (didType && text == ">" && after.name == "EndTag") {
|
||||
let tag = after.parent;
|
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" &&
|
||||
(name = elementName(state$1.doc, tag.parent, head)) &&
|
||||
!selfClosers.has(name)) {
|
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `</${name}>`;
|
||||
return { range, changes: { from: head, to, insert } };
|
||||
}
|
||||
}
|
||||
else if (didType && text == "/" && after.name == "IncompleteCloseTag") {
|
||||
let tag = after.parent;
|
||||
if (after.from == head - 2 && ((_c = tag.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" &&
|
||||
(name = elementName(state$1.doc, tag, head)) && !selfClosers.has(name)) {
|
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `${name}>`;
|
||||
return {
|
||||
range: state.EditorSelection.cursor(head + insert.length, -1),
|
||||
changes: { from: head, to, insert }
|
||||
};
|
||||
}
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state$1.update(closeTags, {
|
||||
userEvent: "input.complete",
|
||||
scrollIntoView: true
|
||||
})
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
exports.autoCloseTags = autoCloseTags;
|
||||
exports.html = html;
|
||||
exports.htmlCompletionSource = htmlCompletionSource;
|
||||
exports.htmlCompletionSourceWith = htmlCompletionSourceWith;
|
||||
exports.htmlLanguage = htmlLanguage;
|
||||
exports.htmlPlain = htmlPlain;
|
||||
117
node_modules/@codemirror/lang-html/dist/index.d.cts
generated
vendored
Normal file
117
node_modules/@codemirror/lang-html/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Parser } from '@lezer/common';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
||||
|
||||
/**
|
||||
Type used to specify tags to complete.
|
||||
*/
|
||||
interface TagSpec {
|
||||
/**
|
||||
Define tag-specific attributes. Property names are attribute
|
||||
names, and property values can be null to indicate free-form
|
||||
attributes, or a list of strings for suggested attribute values.
|
||||
*/
|
||||
attrs?: Record<string, null | readonly string[]>;
|
||||
/**
|
||||
When set to false, don't complete global attributes on this tag.
|
||||
*/
|
||||
globalAttrs?: boolean;
|
||||
/**
|
||||
Can be used to specify a list of child tags that are valid
|
||||
inside this tag. The default is to allow any tag.
|
||||
*/
|
||||
children?: readonly string[];
|
||||
}
|
||||
/**
|
||||
HTML tag completion. Opens and closes tags and attributes in a
|
||||
context-aware way.
|
||||
*/
|
||||
declare function htmlCompletionSource(context: CompletionContext): CompletionResult | null;
|
||||
/**
|
||||
Create a completion source for HTML extended with additional tags
|
||||
or attributes.
|
||||
*/
|
||||
declare function htmlCompletionSourceWith(config: {
|
||||
/**
|
||||
Define extra tag names to complete.
|
||||
*/
|
||||
extraTags?: Record<string, TagSpec>;
|
||||
/**
|
||||
Add global attributes that are available on all tags.
|
||||
*/
|
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>;
|
||||
}): (context: CompletionContext) => CompletionResult | null;
|
||||
|
||||
type NestedLang = {
|
||||
tag: string;
|
||||
attrs?: (attrs: {
|
||||
[attr: string]: string;
|
||||
}) => boolean;
|
||||
parser: Parser;
|
||||
};
|
||||
type NestedAttr = {
|
||||
name: string;
|
||||
tagName?: string;
|
||||
parser: Parser;
|
||||
};
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
declare const htmlPlain: LRLanguage;
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
declare const htmlLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for HTML, including
|
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions.
|
||||
*/
|
||||
declare function html(config?: {
|
||||
/**
|
||||
By default, the syntax tree will highlight mismatched closing
|
||||
tags. Set this to `false` to turn that off (for example when you
|
||||
expect to only be parsing a fragment of HTML text, not a full
|
||||
document).
|
||||
*/
|
||||
matchClosingTags?: boolean;
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-html.autoCloseTags)
|
||||
is included in the support extensions. Defaults to true.
|
||||
*/
|
||||
autoCloseTags?: boolean;
|
||||
/**
|
||||
Add additional tags that can be completed.
|
||||
*/
|
||||
extraTags?: Record<string, TagSpec>;
|
||||
/**
|
||||
Add additional completable attributes to all tags.
|
||||
*/
|
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>;
|
||||
/**
|
||||
Register additional languages to parse the content of specific
|
||||
tags. If given, `attrs` should be a function that, given an
|
||||
object representing the tag's attributes, returns `true` if this
|
||||
language applies.
|
||||
*/
|
||||
nestedLanguages?: NestedLang[];
|
||||
/**
|
||||
Register additional languages to parse attribute values with.
|
||||
*/
|
||||
nestedAttributes?: NestedAttr[];
|
||||
}): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
export { type TagSpec, autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage, htmlPlain };
|
||||
117
node_modules/@codemirror/lang-html/dist/index.d.ts
generated
vendored
Normal file
117
node_modules/@codemirror/lang-html/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Parser } from '@lezer/common';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
||||
|
||||
/**
|
||||
Type used to specify tags to complete.
|
||||
*/
|
||||
interface TagSpec {
|
||||
/**
|
||||
Define tag-specific attributes. Property names are attribute
|
||||
names, and property values can be null to indicate free-form
|
||||
attributes, or a list of strings for suggested attribute values.
|
||||
*/
|
||||
attrs?: Record<string, null | readonly string[]>;
|
||||
/**
|
||||
When set to false, don't complete global attributes on this tag.
|
||||
*/
|
||||
globalAttrs?: boolean;
|
||||
/**
|
||||
Can be used to specify a list of child tags that are valid
|
||||
inside this tag. The default is to allow any tag.
|
||||
*/
|
||||
children?: readonly string[];
|
||||
}
|
||||
/**
|
||||
HTML tag completion. Opens and closes tags and attributes in a
|
||||
context-aware way.
|
||||
*/
|
||||
declare function htmlCompletionSource(context: CompletionContext): CompletionResult | null;
|
||||
/**
|
||||
Create a completion source for HTML extended with additional tags
|
||||
or attributes.
|
||||
*/
|
||||
declare function htmlCompletionSourceWith(config: {
|
||||
/**
|
||||
Define extra tag names to complete.
|
||||
*/
|
||||
extraTags?: Record<string, TagSpec>;
|
||||
/**
|
||||
Add global attributes that are available on all tags.
|
||||
*/
|
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>;
|
||||
}): (context: CompletionContext) => CompletionResult | null;
|
||||
|
||||
type NestedLang = {
|
||||
tag: string;
|
||||
attrs?: (attrs: {
|
||||
[attr: string]: string;
|
||||
}) => boolean;
|
||||
parser: Parser;
|
||||
};
|
||||
type NestedAttr = {
|
||||
name: string;
|
||||
tagName?: string;
|
||||
parser: Parser;
|
||||
};
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
declare const htmlPlain: LRLanguage;
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
declare const htmlLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for HTML, including
|
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions.
|
||||
*/
|
||||
declare function html(config?: {
|
||||
/**
|
||||
By default, the syntax tree will highlight mismatched closing
|
||||
tags. Set this to `false` to turn that off (for example when you
|
||||
expect to only be parsing a fragment of HTML text, not a full
|
||||
document).
|
||||
*/
|
||||
matchClosingTags?: boolean;
|
||||
selfClosingTags?: boolean;
|
||||
/**
|
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-html.autoCloseTags)
|
||||
is included in the support extensions. Defaults to true.
|
||||
*/
|
||||
autoCloseTags?: boolean;
|
||||
/**
|
||||
Add additional tags that can be completed.
|
||||
*/
|
||||
extraTags?: Record<string, TagSpec>;
|
||||
/**
|
||||
Add additional completable attributes to all tags.
|
||||
*/
|
||||
extraGlobalAttributes?: Record<string, null | readonly string[]>;
|
||||
/**
|
||||
Register additional languages to parse the content of specific
|
||||
tags. If given, `attrs` should be a function that, given an
|
||||
object representing the tag's attributes, returns `true` if this
|
||||
language applies.
|
||||
*/
|
||||
nestedLanguages?: NestedLang[];
|
||||
/**
|
||||
Register additional languages to parse attribute values with.
|
||||
*/
|
||||
nestedAttributes?: NestedAttr[];
|
||||
}): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
export { type TagSpec, autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage, htmlPlain };
|
||||
667
node_modules/@codemirror/lang-html/dist/index.js
generated
vendored
Normal file
667
node_modules/@codemirror/lang-html/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,667 @@
|
||||
import { parser, configureNesting } from '@lezer/html';
|
||||
import { cssLanguage, css } from '@codemirror/lang-css';
|
||||
import { javascriptLanguage, typescriptLanguage, jsxLanguage, tsxLanguage, javascript } from '@codemirror/lang-javascript';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
import { EditorSelection } from '@codemirror/state';
|
||||
import { syntaxTree, LRLanguage, indentNodeProp, foldNodeProp, bracketMatchingHandle, LanguageSupport } from '@codemirror/language';
|
||||
|
||||
const Targets = ["_blank", "_self", "_top", "_parent"];
|
||||
const Charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
|
||||
const Methods = ["get", "post", "put", "delete"];
|
||||
const Encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
|
||||
const Bool = ["true", "false"];
|
||||
const S = {}; // Empty tag spec
|
||||
const Tags = {
|
||||
a: {
|
||||
attrs: {
|
||||
href: null, ping: null, type: null,
|
||||
media: null,
|
||||
target: Targets,
|
||||
hreflang: null
|
||||
}
|
||||
},
|
||||
abbr: S,
|
||||
address: S,
|
||||
area: {
|
||||
attrs: {
|
||||
alt: null, coords: null, href: null, target: null, ping: null,
|
||||
media: null, hreflang: null, type: null,
|
||||
shape: ["default", "rect", "circle", "poly"]
|
||||
}
|
||||
},
|
||||
article: S,
|
||||
aside: S,
|
||||
audio: {
|
||||
attrs: {
|
||||
src: null, mediagroup: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["none", "metadata", "auto"],
|
||||
autoplay: ["autoplay"],
|
||||
loop: ["loop"],
|
||||
controls: ["controls"]
|
||||
}
|
||||
},
|
||||
b: S,
|
||||
base: { attrs: { href: null, target: Targets } },
|
||||
bdi: S,
|
||||
bdo: S,
|
||||
blockquote: { attrs: { cite: null } },
|
||||
body: S,
|
||||
br: S,
|
||||
button: {
|
||||
attrs: {
|
||||
form: null, formaction: null, name: null, value: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["autofocus"],
|
||||
formenctype: Encs,
|
||||
formmethod: Methods,
|
||||
formnovalidate: ["novalidate"],
|
||||
formtarget: Targets,
|
||||
type: ["submit", "reset", "button"]
|
||||
}
|
||||
},
|
||||
canvas: { attrs: { width: null, height: null } },
|
||||
caption: S,
|
||||
center: S,
|
||||
cite: S,
|
||||
code: S,
|
||||
col: { attrs: { span: null } },
|
||||
colgroup: { attrs: { span: null } },
|
||||
command: {
|
||||
attrs: {
|
||||
type: ["command", "checkbox", "radio"],
|
||||
label: null, icon: null, radiogroup: null, command: null, title: null,
|
||||
disabled: ["disabled"],
|
||||
checked: ["checked"]
|
||||
}
|
||||
},
|
||||
data: { attrs: { value: null } },
|
||||
datagrid: { attrs: { disabled: ["disabled"], multiple: ["multiple"] } },
|
||||
datalist: { attrs: { data: null } },
|
||||
dd: S,
|
||||
del: { attrs: { cite: null, datetime: null } },
|
||||
details: { attrs: { open: ["open"] } },
|
||||
dfn: S,
|
||||
div: S,
|
||||
dl: S,
|
||||
dt: S,
|
||||
em: S,
|
||||
embed: { attrs: { src: null, type: null, width: null, height: null } },
|
||||
eventsource: { attrs: { src: null } },
|
||||
fieldset: { attrs: { disabled: ["disabled"], form: null, name: null } },
|
||||
figcaption: S,
|
||||
figure: S,
|
||||
footer: S,
|
||||
form: {
|
||||
attrs: {
|
||||
action: null, name: null,
|
||||
"accept-charset": Charsets,
|
||||
autocomplete: ["on", "off"],
|
||||
enctype: Encs,
|
||||
method: Methods,
|
||||
novalidate: ["novalidate"],
|
||||
target: Targets
|
||||
}
|
||||
},
|
||||
h1: S, h2: S, h3: S, h4: S, h5: S, h6: S,
|
||||
head: {
|
||||
children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
|
||||
},
|
||||
header: S,
|
||||
hgroup: S,
|
||||
hr: S,
|
||||
html: {
|
||||
attrs: { manifest: null }
|
||||
},
|
||||
i: S,
|
||||
iframe: {
|
||||
attrs: {
|
||||
src: null, srcdoc: null, name: null, width: null, height: null,
|
||||
sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
|
||||
seamless: ["seamless"]
|
||||
}
|
||||
},
|
||||
img: {
|
||||
attrs: {
|
||||
alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"]
|
||||
}
|
||||
},
|
||||
input: {
|
||||
attrs: {
|
||||
alt: null, dirname: null, form: null, formaction: null,
|
||||
height: null, list: null, max: null, maxlength: null, min: null,
|
||||
name: null, pattern: null, placeholder: null, size: null, src: null,
|
||||
step: null, value: null, width: null,
|
||||
accept: ["audio/*", "video/*", "image/*"],
|
||||
autocomplete: ["on", "off"],
|
||||
autofocus: ["autofocus"],
|
||||
checked: ["checked"],
|
||||
disabled: ["disabled"],
|
||||
formenctype: Encs,
|
||||
formmethod: Methods,
|
||||
formnovalidate: ["novalidate"],
|
||||
formtarget: Targets,
|
||||
multiple: ["multiple"],
|
||||
readonly: ["readonly"],
|
||||
required: ["required"],
|
||||
type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
|
||||
"week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
||||
"file", "submit", "image", "reset", "button"]
|
||||
}
|
||||
},
|
||||
ins: { attrs: { cite: null, datetime: null } },
|
||||
kbd: S,
|
||||
keygen: {
|
||||
attrs: {
|
||||
challenge: null, form: null, name: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
keytype: ["RSA"]
|
||||
}
|
||||
},
|
||||
label: { attrs: { for: null, form: null } },
|
||||
legend: S,
|
||||
li: { attrs: { value: null } },
|
||||
link: {
|
||||
attrs: {
|
||||
href: null, type: null,
|
||||
hreflang: null,
|
||||
media: null,
|
||||
sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
|
||||
}
|
||||
},
|
||||
map: { attrs: { name: null } },
|
||||
mark: S,
|
||||
menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
|
||||
meta: {
|
||||
attrs: {
|
||||
content: null,
|
||||
charset: Charsets,
|
||||
name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
|
||||
"http-equiv": ["content-language", "content-type", "default-style", "refresh"]
|
||||
}
|
||||
},
|
||||
meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
|
||||
nav: S,
|
||||
noscript: S,
|
||||
object: {
|
||||
attrs: {
|
||||
data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
|
||||
typemustmatch: ["typemustmatch"]
|
||||
}
|
||||
},
|
||||
ol: { attrs: { reversed: ["reversed"], start: null, type: ["1", "a", "A", "i", "I"] },
|
||||
children: ["li", "script", "template", "ul", "ol"] },
|
||||
optgroup: { attrs: { disabled: ["disabled"], label: null } },
|
||||
option: { attrs: { disabled: ["disabled"], label: null, selected: ["selected"], value: null } },
|
||||
output: { attrs: { for: null, form: null, name: null } },
|
||||
p: S,
|
||||
param: { attrs: { name: null, value: null } },
|
||||
pre: S,
|
||||
progress: { attrs: { value: null, max: null } },
|
||||
q: { attrs: { cite: null } },
|
||||
rp: S,
|
||||
rt: S,
|
||||
ruby: S,
|
||||
samp: S,
|
||||
script: {
|
||||
attrs: {
|
||||
type: ["text/javascript"],
|
||||
src: null,
|
||||
async: ["async"],
|
||||
defer: ["defer"],
|
||||
charset: Charsets
|
||||
}
|
||||
},
|
||||
section: S,
|
||||
select: {
|
||||
attrs: {
|
||||
form: null, name: null, size: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
multiple: ["multiple"]
|
||||
}
|
||||
},
|
||||
slot: { attrs: { name: null } },
|
||||
small: S,
|
||||
source: { attrs: { src: null, type: null, media: null } },
|
||||
span: S,
|
||||
strong: S,
|
||||
style: {
|
||||
attrs: {
|
||||
type: ["text/css"],
|
||||
media: null,
|
||||
scoped: null
|
||||
}
|
||||
},
|
||||
sub: S,
|
||||
summary: S,
|
||||
sup: S,
|
||||
table: S,
|
||||
tbody: S,
|
||||
td: { attrs: { colspan: null, rowspan: null, headers: null } },
|
||||
template: S,
|
||||
textarea: {
|
||||
attrs: {
|
||||
dirname: null, form: null, maxlength: null, name: null, placeholder: null,
|
||||
rows: null, cols: null,
|
||||
autofocus: ["autofocus"],
|
||||
disabled: ["disabled"],
|
||||
readonly: ["readonly"],
|
||||
required: ["required"],
|
||||
wrap: ["soft", "hard"]
|
||||
}
|
||||
},
|
||||
tfoot: S,
|
||||
th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
|
||||
thead: S,
|
||||
time: { attrs: { datetime: null } },
|
||||
title: S,
|
||||
tr: S,
|
||||
track: {
|
||||
attrs: {
|
||||
src: null, label: null, default: null,
|
||||
kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
|
||||
srclang: null
|
||||
}
|
||||
},
|
||||
ul: { children: ["li", "script", "template", "ul", "ol"] },
|
||||
var: S,
|
||||
video: {
|
||||
attrs: {
|
||||
src: null, poster: null, width: null, height: null,
|
||||
crossorigin: ["anonymous", "use-credentials"],
|
||||
preload: ["auto", "metadata", "none"],
|
||||
autoplay: ["autoplay"],
|
||||
mediagroup: ["movie"],
|
||||
muted: ["muted"],
|
||||
controls: ["controls"]
|
||||
}
|
||||
},
|
||||
wbr: S
|
||||
};
|
||||
const GlobalAttrs = {
|
||||
accesskey: null,
|
||||
class: null,
|
||||
contenteditable: Bool,
|
||||
contextmenu: null,
|
||||
dir: ["ltr", "rtl", "auto"],
|
||||
draggable: ["true", "false", "auto"],
|
||||
dropzone: ["copy", "move", "link", "string:", "file:"],
|
||||
hidden: ["hidden"],
|
||||
id: null,
|
||||
inert: ["inert"],
|
||||
itemid: null,
|
||||
itemprop: null,
|
||||
itemref: null,
|
||||
itemscope: ["itemscope"],
|
||||
itemtype: null,
|
||||
lang: ["ar", "bn", "de", "en-GB", "en-US", "es", "fr", "hi", "id", "ja", "pa", "pt", "ru", "tr", "zh"],
|
||||
spellcheck: Bool,
|
||||
autocorrect: Bool,
|
||||
autocapitalize: Bool,
|
||||
style: null,
|
||||
tabindex: null,
|
||||
title: null,
|
||||
translate: ["yes", "no"],
|
||||
rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"],
|
||||
role: /*@__PURE__*/"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),
|
||||
"aria-activedescendant": null,
|
||||
"aria-atomic": Bool,
|
||||
"aria-autocomplete": ["inline", "list", "both", "none"],
|
||||
"aria-busy": Bool,
|
||||
"aria-checked": ["true", "false", "mixed", "undefined"],
|
||||
"aria-controls": null,
|
||||
"aria-describedby": null,
|
||||
"aria-disabled": Bool,
|
||||
"aria-dropeffect": null,
|
||||
"aria-expanded": ["true", "false", "undefined"],
|
||||
"aria-flowto": null,
|
||||
"aria-grabbed": ["true", "false", "undefined"],
|
||||
"aria-haspopup": Bool,
|
||||
"aria-hidden": Bool,
|
||||
"aria-invalid": ["true", "false", "grammar", "spelling"],
|
||||
"aria-label": null,
|
||||
"aria-labelledby": null,
|
||||
"aria-level": null,
|
||||
"aria-live": ["off", "polite", "assertive"],
|
||||
"aria-multiline": Bool,
|
||||
"aria-multiselectable": Bool,
|
||||
"aria-owns": null,
|
||||
"aria-posinset": null,
|
||||
"aria-pressed": ["true", "false", "mixed", "undefined"],
|
||||
"aria-readonly": Bool,
|
||||
"aria-relevant": null,
|
||||
"aria-required": Bool,
|
||||
"aria-selected": ["true", "false", "undefined"],
|
||||
"aria-setsize": null,
|
||||
"aria-sort": ["ascending", "descending", "none", "other"],
|
||||
"aria-valuemax": null,
|
||||
"aria-valuemin": null,
|
||||
"aria-valuenow": null,
|
||||
"aria-valuetext": null
|
||||
};
|
||||
const eventAttributes = /*@__PURE__*/("beforeunload copy cut dragstart dragover dragleave dragenter dragend " +
|
||||
"drag paste focus blur change click load mousedown mouseenter mouseleave " +
|
||||
"mouseup keydown keyup resize scroll unload").split(" ").map(n => "on" + n);
|
||||
for (let a of eventAttributes)
|
||||
GlobalAttrs[a] = null;
|
||||
class Schema {
|
||||
constructor(extraTags, extraAttrs) {
|
||||
this.tags = Object.assign(Object.assign({}, Tags), extraTags);
|
||||
this.globalAttrs = Object.assign(Object.assign({}, GlobalAttrs), extraAttrs);
|
||||
this.allTags = Object.keys(this.tags);
|
||||
this.globalAttrNames = Object.keys(this.globalAttrs);
|
||||
}
|
||||
}
|
||||
Schema.default = /*@__PURE__*/new Schema;
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
if (!tree)
|
||||
return "";
|
||||
let tag = tree.firstChild;
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : "";
|
||||
}
|
||||
function findParentElement(tree, skip = false) {
|
||||
for (; tree; tree = tree.parent)
|
||||
if (tree.name == "Element") {
|
||||
if (skip)
|
||||
skip = false;
|
||||
else
|
||||
return tree;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function allowedChildren(doc, tree, schema) {
|
||||
let parentInfo = schema.tags[elementName(doc, findParentElement(tree))];
|
||||
return (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.children) || schema.allTags;
|
||||
}
|
||||
function openTags(doc, tree) {
|
||||
let open = [];
|
||||
for (let parent = findParentElement(tree); parent && !parent.type.isTop; parent = findParentElement(parent.parent)) {
|
||||
let tagName = elementName(doc, parent);
|
||||
if (tagName && parent.lastChild.name == "CloseTag")
|
||||
break;
|
||||
if (tagName && open.indexOf(tagName) < 0 && (tree.name == "EndTag" || tree.from >= parent.firstChild.to))
|
||||
open.push(tagName);
|
||||
}
|
||||
return open;
|
||||
}
|
||||
const identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
|
||||
function completeTag(state, schema, tree, from, to) {
|
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">";
|
||||
let parent = findParentElement(tree, true);
|
||||
return { from, to,
|
||||
options: allowedChildren(state.doc, parent, schema).map(tagName => ({ label: tagName, type: "type" })).concat(openTags(state.doc, tree).map((tag, i) => ({ label: "/" + tag, apply: "/" + tag + end,
|
||||
type: "type", boost: 99 - i }))),
|
||||
validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/ };
|
||||
}
|
||||
function completeCloseTag(state, tree, from, to) {
|
||||
let end = /\s*>/.test(state.sliceDoc(to, to + 5)) ? "" : ">";
|
||||
return { from, to,
|
||||
options: openTags(state.doc, tree).map((tag, i) => ({ label: tag, apply: tag + end, type: "type", boost: 99 - i })),
|
||||
validFor: identifier };
|
||||
}
|
||||
function completeStartTag(state, schema, tree, pos) {
|
||||
let options = [], level = 0;
|
||||
for (let tagName of allowedChildren(state.doc, tree, schema))
|
||||
options.push({ label: "<" + tagName, type: "type" });
|
||||
for (let open of openTags(state.doc, tree))
|
||||
options.push({ label: "</" + open + ">", type: "type", boost: 99 - level++ });
|
||||
return { from: pos, to: pos, options, validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/ };
|
||||
}
|
||||
function completeAttrName(state, schema, tree, from, to) {
|
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null;
|
||||
let localAttrs = info && info.attrs ? Object.keys(info.attrs) : [];
|
||||
let names = info && info.globalAttrs === false ? localAttrs
|
||||
: localAttrs.length ? localAttrs.concat(schema.globalAttrNames) : schema.globalAttrNames;
|
||||
return { from, to,
|
||||
options: names.map(attrName => ({ label: attrName, type: "property" })),
|
||||
validFor: identifier };
|
||||
}
|
||||
function completeAttrValue(state, schema, tree, from, to) {
|
||||
var _a;
|
||||
let nameNode = (_a = tree.parent) === null || _a === void 0 ? void 0 : _a.getChild("AttributeName");
|
||||
let options = [], token = undefined;
|
||||
if (nameNode) {
|
||||
let attrName = state.sliceDoc(nameNode.from, nameNode.to);
|
||||
let attrs = schema.globalAttrs[attrName];
|
||||
if (!attrs) {
|
||||
let elt = findParentElement(tree), info = elt ? schema.tags[elementName(state.doc, elt)] : null;
|
||||
attrs = (info === null || info === void 0 ? void 0 : info.attrs) && info.attrs[attrName];
|
||||
}
|
||||
if (attrs) {
|
||||
let base = state.sliceDoc(from, to).toLowerCase(), quoteStart = '"', quoteEnd = '"';
|
||||
if (/^['"]/.test(base)) {
|
||||
token = base[0] == '"' ? /^[^"]*$/ : /^[^']*$/;
|
||||
quoteStart = "";
|
||||
quoteEnd = state.sliceDoc(to, to + 1) == base[0] ? "" : base[0];
|
||||
base = base.slice(1);
|
||||
from++;
|
||||
}
|
||||
else {
|
||||
token = /^[^\s<>='"]*$/;
|
||||
}
|
||||
for (let value of attrs)
|
||||
options.push({ label: value, apply: quoteStart + value + quoteEnd, type: "constant" });
|
||||
}
|
||||
}
|
||||
return { from, to, options, validFor: token };
|
||||
}
|
||||
function htmlCompletionFor(schema, context) {
|
||||
let { state, pos } = context, tree = syntaxTree(state).resolveInner(pos, -1), around = tree.resolve(pos);
|
||||
for (let scan = pos, before; around == tree && (before = tree.childBefore(scan));) {
|
||||
let last = before.lastChild;
|
||||
if (!last || !last.type.isError || last.from < last.to)
|
||||
break;
|
||||
around = tree = before;
|
||||
scan = last.from;
|
||||
}
|
||||
if (tree.name == "TagName") {
|
||||
return tree.parent && /CloseTag$/.test(tree.parent.name) ? completeCloseTag(state, tree, tree.from, pos)
|
||||
: completeTag(state, schema, tree, tree.from, pos);
|
||||
}
|
||||
else if (tree.name == "StartTag") {
|
||||
return completeTag(state, schema, tree, pos, pos);
|
||||
}
|
||||
else if (tree.name == "StartCloseTag" || tree.name == "IncompleteCloseTag") {
|
||||
return completeCloseTag(state, tree, pos, pos);
|
||||
}
|
||||
else if (tree.name == "OpenTag" || tree.name == "SelfClosingTag" || tree.name == "AttributeName") {
|
||||
return completeAttrName(state, schema, tree, tree.name == "AttributeName" ? tree.from : pos, pos);
|
||||
}
|
||||
else if (tree.name == "Is" || tree.name == "AttributeValue" || tree.name == "UnquotedAttributeValue") {
|
||||
return completeAttrValue(state, schema, tree, tree.name == "Is" ? pos : tree.from, pos);
|
||||
}
|
||||
else if (context.explicit && (around.name == "Element" || around.name == "Text" || around.name == "Document")) {
|
||||
return completeStartTag(state, schema, tree, pos);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
HTML tag completion. Opens and closes tags and attributes in a
|
||||
context-aware way.
|
||||
*/
|
||||
function htmlCompletionSource(context) {
|
||||
return htmlCompletionFor(Schema.default, context);
|
||||
}
|
||||
/**
|
||||
Create a completion source for HTML extended with additional tags
|
||||
or attributes.
|
||||
*/
|
||||
function htmlCompletionSourceWith(config) {
|
||||
let { extraTags, extraGlobalAttributes: extraAttrs } = config;
|
||||
let schema = extraAttrs || extraTags ? new Schema(extraTags, extraAttrs) : Schema.default;
|
||||
return (context) => htmlCompletionFor(schema, context);
|
||||
}
|
||||
|
||||
const jsonParser = /*@__PURE__*/javascriptLanguage.parser.configure({ top: "SingleExpression" });
|
||||
const defaultNesting = [
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/typescript" || attrs.lang == "ts",
|
||||
parser: typescriptLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/babel" || attrs.type == "text/jsx",
|
||||
parser: jsxLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs: attrs => attrs.type == "text/typescript-jsx",
|
||||
parser: tsxLanguage.parser },
|
||||
{ tag: "script",
|
||||
attrs(attrs) {
|
||||
return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(attrs.type);
|
||||
},
|
||||
parser: jsonParser },
|
||||
{ tag: "script",
|
||||
attrs(attrs) {
|
||||
return !attrs.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type);
|
||||
},
|
||||
parser: javascriptLanguage.parser },
|
||||
{ tag: "style",
|
||||
attrs(attrs) {
|
||||
return (!attrs.lang || attrs.lang == "css") && (!attrs.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(attrs.type));
|
||||
},
|
||||
parser: cssLanguage.parser }
|
||||
];
|
||||
const defaultAttrs = /*@__PURE__*/[
|
||||
{ name: "style",
|
||||
parser: /*@__PURE__*/cssLanguage.parser.configure({ top: "Styles" }) }
|
||||
].concat(/*@__PURE__*/eventAttributes.map(name => ({ name, parser: javascriptLanguage.parser })));
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
const htmlPlain = /*@__PURE__*/LRLanguage.define({
|
||||
name: "html",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
Element(context) {
|
||||
let after = /^(\s*)(<\/)?/.exec(context.textAfter);
|
||||
if (context.node.to <= context.pos + after[0].length)
|
||||
return context.continue();
|
||||
return context.lineIndent(context.node.from) + (after[2] ? 0 : context.unit);
|
||||
},
|
||||
"OpenTag CloseTag SelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
},
|
||||
Document(context) {
|
||||
if (context.pos + /\s*/.exec(context.textAfter)[0].length < context.node.to)
|
||||
return context.continue();
|
||||
let endElt = null, close;
|
||||
for (let cur = context.node;;) {
|
||||
let last = cur.lastChild;
|
||||
if (!last || last.name != "Element" || last.to != cur.to)
|
||||
break;
|
||||
endElt = cur = last;
|
||||
}
|
||||
if (endElt && !((close = endElt.lastChild) && (close.name == "CloseTag" || close.name == "SelfClosingTag")))
|
||||
return context.lineIndent(endElt.from) + context.unit;
|
||||
return null;
|
||||
}
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
Element(node) {
|
||||
let first = node.firstChild, last = node.lastChild;
|
||||
if (!first || first.name != "OpenTag")
|
||||
return null;
|
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : node.to };
|
||||
}
|
||||
}),
|
||||
/*@__PURE__*/bracketMatchingHandle.add({
|
||||
"OpenTag CloseTag": node => node.getChild("TagName")
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "<!--", close: "-->" } },
|
||||
indentOnInput: /^\s*<\/\w+\W$/,
|
||||
wordChars: "-._"
|
||||
}
|
||||
});
|
||||
/**
|
||||
A language provider based on the [Lezer HTML
|
||||
parser](https://github.com/lezer-parser/html), extended with the
|
||||
JavaScript and CSS parsers to parse the content of `<script>` and
|
||||
`<style>` tags.
|
||||
*/
|
||||
const htmlLanguage = /*@__PURE__*/htmlPlain.configure({
|
||||
wrap: /*@__PURE__*/configureNesting(defaultNesting, defaultAttrs)
|
||||
});
|
||||
/**
|
||||
Language support for HTML, including
|
||||
[`htmlCompletion`](https://codemirror.net/6/docs/ref/#lang-html.htmlCompletion) and JavaScript and
|
||||
CSS support extensions.
|
||||
*/
|
||||
function html(config = {}) {
|
||||
let dialect = "", wrap;
|
||||
if (config.matchClosingTags === false)
|
||||
dialect = "noMatch";
|
||||
if (config.selfClosingTags === true)
|
||||
dialect = (dialect ? dialect + " " : "") + "selfClosing";
|
||||
if (config.nestedLanguages && config.nestedLanguages.length ||
|
||||
config.nestedAttributes && config.nestedAttributes.length)
|
||||
wrap = configureNesting((config.nestedLanguages || []).concat(defaultNesting), (config.nestedAttributes || []).concat(defaultAttrs));
|
||||
let lang = wrap ? htmlPlain.configure({ wrap, dialect }) : dialect ? htmlLanguage.configure({ dialect }) : htmlLanguage;
|
||||
return new LanguageSupport(lang, [
|
||||
htmlLanguage.data.of({ autocomplete: htmlCompletionSourceWith(config) }),
|
||||
config.autoCloseTags !== false ? autoCloseTags : [],
|
||||
javascript().support,
|
||||
css().support
|
||||
]);
|
||||
}
|
||||
const selfClosers = /*@__PURE__*/new Set(/*@__PURE__*/"area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
|
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") ||
|
||||
!htmlLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = insertTransaction(), { state } = base;
|
||||
let closeTags = state.changeByRange(range => {
|
||||
var _a, _b, _c;
|
||||
let didType = state.doc.sliceString(range.from - 1, range.to) == text;
|
||||
let { head } = range, after = syntaxTree(state).resolveInner(head, -1), name;
|
||||
if (didType && text == ">" && after.name == "EndTag") {
|
||||
let tag = after.parent;
|
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" &&
|
||||
(name = elementName(state.doc, tag.parent, head)) &&
|
||||
!selfClosers.has(name)) {
|
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `</${name}>`;
|
||||
return { range, changes: { from: head, to, insert } };
|
||||
}
|
||||
}
|
||||
else if (didType && text == "/" && after.name == "IncompleteCloseTag") {
|
||||
let tag = after.parent;
|
||||
if (after.from == head - 2 && ((_c = tag.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" &&
|
||||
(name = elementName(state.doc, tag, head)) && !selfClosers.has(name)) {
|
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `${name}>`;
|
||||
return {
|
||||
range: EditorSelection.cursor(head + insert.length, -1),
|
||||
changes: { from: head, to, insert }
|
||||
};
|
||||
}
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state.update(closeTags, {
|
||||
userEvent: "input.complete",
|
||||
scrollIntoView: true
|
||||
})
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
export { autoCloseTags, html, htmlCompletionSource, htmlCompletionSourceWith, htmlLanguage, htmlPlain };
|
||||
46
node_modules/@codemirror/lang-html/package.json
generated
vendored
Normal file
46
node_modules/@codemirror/lang-html/package.json
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "@codemirror/lang-html",
|
||||
"version": "6.4.9",
|
||||
"description": "HTML language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/html.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/lang-css": "^6.0.0",
|
||||
"@codemirror/lang-javascript": "^6.0.0",
|
||||
"@codemirror/language": "^6.4.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/html": "^1.3.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/css": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lang-html.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-javascript/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-javascript/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
190
node_modules/@codemirror/lang-javascript/CHANGELOG.md
generated
vendored
Normal file
190
node_modules/@codemirror/lang-javascript/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
## 6.2.3 (2025-02-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disable JavaScript completions in JSX context.
|
||||
|
||||
## 6.2.2 (2024-02-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would cause self-closing JSX tags to have another closing tag inserted when typing the final '>'.
|
||||
|
||||
## 6.2.1 (2023-08-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`autoCloseTags` now generates two separate transactions, so that the completion can be undone separately.
|
||||
|
||||
## 6.2.0 (2023-08-26)
|
||||
|
||||
### New features
|
||||
|
||||
Export a `typescriptSnippets` array and include TypeScript keyword completions in the default support extension when in TypeScript mode.
|
||||
|
||||
## 6.1.9 (2023-06-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure `scopeCompletionSource` doesn't try to complete property names that aren't simple identifier (such as numeric indices).
|
||||
|
||||
## 6.1.8 (2023-05-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Stop completing keywords after `.` tokens.
|
||||
|
||||
## 6.1.7 (2023-04-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix overeager JSX tag closing inside attribute values and in self-closing tags.
|
||||
|
||||
## 6.1.6 (2023-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that allowed `autoCloseTags` to close JSX tags in JavaScript context.
|
||||
|
||||
## 6.1.5 (2023-04-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make TypeScript object type syntax foldable.
|
||||
|
||||
## 6.1.4 (2023-02-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure code in JSX context can be commented correctly.
|
||||
|
||||
## 6.1.3 (2023-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix auto-closing of JSX fragments.
|
||||
|
||||
## 6.1.2 (2022-12-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Automatic tag closing in JSX now works for namespaced and member-expression tag names.
|
||||
|
||||
## 6.1.1 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `completionPath` handle `?.` syntax.
|
||||
|
||||
## 6.1.0 (2022-09-20)
|
||||
|
||||
### New features
|
||||
|
||||
The `completionPath` helper can now be used to find the object path to complete at a given position.
|
||||
|
||||
`scopeCompletionSource` provides a completion source based on a scope object.
|
||||
|
||||
## 6.0.2 (2022-07-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix the `source` field in ESLint diagnostics to properly hold `"eslint"`.
|
||||
|
||||
Fix (non-)auto indentation in template strings and comments.
|
||||
|
||||
## 6.0.1 (2022-06-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid completing variables/keywords in property or definition positions.
|
||||
|
||||
Fix a bug that broke local variable completion if JavaScript was parsed an overlay in an outer language.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.1 (2022-06-01)
|
||||
|
||||
### New features
|
||||
|
||||
`localCompletionSource` (included in the support extensions returned from `javascript`) now provides a way to complete locally-defined names.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### New features
|
||||
|
||||
The new `autoCloseTags` extension (included by default in the `javascript` language extension when `jsx` is configured) finishes JSX closing tags when you type a `>` or `/` character.
|
||||
|
||||
## 0.19.7 (2022-01-28)
|
||||
|
||||
## 0.19.6 (2022-01-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove accidentally released unfinished changes.
|
||||
|
||||
## 0.19.5 (2022-01-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add the `function` highlight modifier to variables used in tagged template expressions.
|
||||
|
||||
## 0.19.4 (2022-01-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix highlighting of TypeScript private/public/protected keywords.
|
||||
|
||||
## 0.19.3 (2021-11-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add styling for private properties.
|
||||
|
||||
## 0.19.2 (2021-09-23)
|
||||
|
||||
### New features
|
||||
|
||||
Use more specific highlighting tags for JSX attribute names and values.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Extend `indentOnInput` expression to cover closing JSX tags.
|
||||
|
||||
## 0.17.2 (2021-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve highlighting tag specificity of defined function and class names. Add indentation information for JSX constructs
|
||||
|
||||
Support smart indent for JSX syntax.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lang-javascript/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-javascript/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
125
node_modules/@codemirror/lang-javascript/README.md
generated
vendored
Normal file
125
node_modules/@codemirror/lang-javascript/README.md
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-javascript [](https://www.npmjs.org/package/@codemirror/lang-javascript)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-javascript/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements JavaScript language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-javascript/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import {EditorView, basicSetup} from "codemirror"
|
||||
import {javascript} from "@codemirror/lang-javascript"
|
||||
|
||||
const view = new EditorView({
|
||||
parent: document.body,
|
||||
doc: `console.log("Hello world")`,
|
||||
extensions: [basicSetup, javascript()]
|
||||
})
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
<dl>
|
||||
<dt id="user-content-javascript">
|
||||
<code><strong><a href="#user-content-javascript">javascript</a></strong>(<a id="user-content-javascript^config" href="#user-content-javascript^config">config</a>⁠?: {jsx⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>, typescript⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>} = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>JavaScript support. Includes <a href="#user-content-snippets">snippet</a>
|
||||
and local variable completion.</p>
|
||||
</dd>
|
||||
<dt id="user-content-javascriptlanguage">
|
||||
<code><strong><a href="#user-content-javascriptlanguage">javascriptLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/javascript">Lezer JavaScript
|
||||
parser</a>, extended with
|
||||
highlighting and indentation information.</p>
|
||||
</dd>
|
||||
<dt id="user-content-typescriptlanguage">
|
||||
<code><strong><a href="#user-content-typescriptlanguage">typescriptLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider for TypeScript.</p>
|
||||
</dd>
|
||||
<dt id="user-content-jsxlanguage">
|
||||
<code><strong><a href="#user-content-jsxlanguage">jsxLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>Language provider for JSX.</p>
|
||||
</dd>
|
||||
<dt id="user-content-tsxlanguage">
|
||||
<code><strong><a href="#user-content-tsxlanguage">tsxLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>Language provider for JSX + TypeScript.</p>
|
||||
</dd>
|
||||
<dt id="user-content-autoclosetags">
|
||||
<code><strong><a href="#user-content-autoclosetags">autoCloseTags</a></strong>: <a href="https://codemirror.net/docs/ref#state.Extension">Extension</a></code></dt>
|
||||
|
||||
<dd><p>Extension that will automatically insert JSX close tags when a <code>></code> or
|
||||
<code>/</code> is typed.</p>
|
||||
</dd>
|
||||
<dt id="user-content-snippets">
|
||||
<code><strong><a href="#user-content-snippets">snippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
|
||||
|
||||
<dd><p>A collection of JavaScript-related
|
||||
<a href="https://codemirror.net/docs/ref/#autocomplete.snippet">snippets</a>.</p>
|
||||
</dd>
|
||||
<dt id="user-content-typescriptsnippets">
|
||||
<code><strong><a href="#user-content-typescriptsnippets">typescriptSnippets</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
|
||||
|
||||
<dd><p>A collection of snippet completions for TypeScript. Includes the
|
||||
JavaScript <a href="#user-content-snippets">snippets</a>.</p>
|
||||
</dd>
|
||||
<dt id="user-content-localcompletionsource">
|
||||
<code><strong><a href="#user-content-localcompletionsource">localCompletionSource</a></strong>(<a id="user-content-localcompletionsource^context" href="#user-content-localcompletionsource^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionResult">CompletionResult</a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
|
||||
|
||||
<dd><p>Completion source that looks up locally defined names in
|
||||
JavaScript code.</p>
|
||||
</dd>
|
||||
<dt id="user-content-completionpath">
|
||||
<code><strong><a href="#user-content-completionpath">completionPath</a></strong>(<a id="user-content-completionpath^context" href="#user-content-completionpath^context">context</a>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionContext">CompletionContext</a>) → {path: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[], name: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>} | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null">null</a></code></dt>
|
||||
|
||||
<dd><p>Helper function for defining JavaScript completion sources. It
|
||||
returns the completable name and object path for a completion
|
||||
context, or null if no name/property completion should happen at
|
||||
that position. For example, when completing after <code>a.b.c</code> it will
|
||||
return <code>{path: ["a", "b"], name: "c"}</code>. When completing after <code>x</code>
|
||||
it will return <code>{path: [], name: "x"}</code>. When not in a property or
|
||||
name, it will return null if <code>context.explicit</code> is false, and
|
||||
<code>{path: [], name: ""}</code> otherwise.</p>
|
||||
</dd>
|
||||
<dt id="user-content-scopecompletionsource">
|
||||
<code><strong><a href="#user-content-scopecompletionsource">scopeCompletionSource</a></strong>(<a id="user-content-scopecompletionsource^scope" href="#user-content-scopecompletionsource^scope">scope</a>: any) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
|
||||
|
||||
<dd><p>Defines a <a href="https://codemirror.net/docs/ref/#autocomplete.CompletionSource">completion source</a> that
|
||||
completes from the given scope object (for example <code>globalThis</code>).
|
||||
Will enter properties of the object when completing properties on
|
||||
a directly-named path.</p>
|
||||
</dd>
|
||||
<dt id="user-content-eslint">
|
||||
<code><strong><a href="#user-content-eslint">esLint</a></strong>(<a id="user-content-eslint^eslint" href="#user-content-eslint^eslint">eslint</a>: any, <a id="user-content-eslint^config" href="#user-content-eslint^config">config</a>⁠?: any) → fn(<a id="user-content-eslint^returns^view" href="#user-content-eslint^returns^view">view</a>: <a href="https://codemirror.net/docs/ref#view.EditorView">EditorView</a>) → <a href="https://codemirror.net/docs/ref#lint.Diagnostic">Diagnostic</a>[]</code></dt>
|
||||
|
||||
<dd><p>Connects an <a href="https://eslint.org/">ESLint</a> linter to CodeMirror's
|
||||
<a href="https://codemirror.net/docs/ref/#lint">lint</a> integration. <code>eslint</code> should be an instance of the
|
||||
<a href="https://eslint.org/docs/developer-guide/nodejs-api#linter"><code>Linter</code></a>
|
||||
class, and <code>config</code> an optional ESLint configuration. The return
|
||||
value of this function can be passed to <a href="https://codemirror.net/docs/ref/#lint.linter"><code>linter</code></a>
|
||||
to create a JavaScript linting extension.</p>
|
||||
<p>Note that ESLint targets node, and is tricky to run in the
|
||||
browser. The
|
||||
<a href="https://github.com/UziTech/eslint-linter-browserify">eslint-linter-browserify</a>
|
||||
package may help with that (see
|
||||
<a href="https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js">example</a>).</p>
|
||||
</dd>
|
||||
</dl>
|
||||
510
node_modules/@codemirror/lang-javascript/dist/index.cjs
generated
vendored
Normal file
510
node_modules/@codemirror/lang-javascript/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,510 @@
|
||||
'use strict';
|
||||
|
||||
var javascript$1 = require('@lezer/javascript');
|
||||
var language = require('@codemirror/language');
|
||||
var state = require('@codemirror/state');
|
||||
var view = require('@codemirror/view');
|
||||
var autocomplete = require('@codemirror/autocomplete');
|
||||
var common = require('@lezer/common');
|
||||
|
||||
/**
|
||||
A collection of JavaScript-related
|
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/
|
||||
const snippets = [
|
||||
autocomplete.snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
|
||||
label: "function",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
|
||||
label: "for",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
|
||||
label: "for",
|
||||
detail: "of loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("do {\n\t${}\n} while (${})", {
|
||||
label: "do",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("while (${}) {\n\t${}\n}", {
|
||||
label: "while",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
|
||||
label: "try",
|
||||
detail: "/ catch block",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("if (${}) {\n\t${}\n}", {
|
||||
label: "if",
|
||||
detail: "block",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
|
||||
label: "if",
|
||||
detail: "/ else block",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
|
||||
label: "class",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("import {${names}} from \"${module}\"\n${}", {
|
||||
label: "import",
|
||||
detail: "named",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("import ${name} from \"${module}\"\n${}", {
|
||||
label: "import",
|
||||
detail: "default",
|
||||
type: "keyword"
|
||||
})
|
||||
];
|
||||
/**
|
||||
A collection of snippet completions for TypeScript. Includes the
|
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/
|
||||
const typescriptSnippets = snippets.concat([
|
||||
autocomplete.snippetCompletion("interface ${name} {\n\t${}\n}", {
|
||||
label: "interface",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("type ${name} = ${type}", {
|
||||
label: "type",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
autocomplete.snippetCompletion("enum ${name} {\n\t${}\n}", {
|
||||
label: "enum",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
})
|
||||
]);
|
||||
|
||||
const cache = new common.NodeWeakMap();
|
||||
const ScopeNodes = new Set([
|
||||
"Script", "Block",
|
||||
"FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
|
||||
"ForStatement"
|
||||
]);
|
||||
function defID(type) {
|
||||
return (node, def) => {
|
||||
let id = node.node.getChild("VariableDefinition");
|
||||
if (id)
|
||||
def(id, type);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
const functionContext = ["FunctionDeclaration"];
|
||||
const gatherCompletions = {
|
||||
FunctionDeclaration: defID("function"),
|
||||
ClassDeclaration: defID("class"),
|
||||
ClassExpression: () => true,
|
||||
EnumDeclaration: defID("constant"),
|
||||
TypeAliasDeclaration: defID("type"),
|
||||
NamespaceDeclaration: defID("namespace"),
|
||||
VariableDefinition(node, def) { if (!node.matchContext(functionContext))
|
||||
def(node, "variable"); },
|
||||
TypeDefinition(node, def) { def(node, "type"); },
|
||||
__proto__: null
|
||||
};
|
||||
function getScope(doc, node) {
|
||||
let cached = cache.get(node);
|
||||
if (cached)
|
||||
return cached;
|
||||
let completions = [], top = true;
|
||||
function def(node, type) {
|
||||
let name = doc.sliceString(node.from, node.to);
|
||||
completions.push({ label: name, type });
|
||||
}
|
||||
node.cursor(common.IterMode.IncludeAnonymous).iterate(node => {
|
||||
if (top) {
|
||||
top = false;
|
||||
}
|
||||
else if (node.name) {
|
||||
let gather = gatherCompletions[node.name];
|
||||
if (gather && gather(node, def) || ScopeNodes.has(node.name))
|
||||
return false;
|
||||
}
|
||||
else if (node.to - node.from > 8192) {
|
||||
// Allow caching for bigger internal nodes
|
||||
for (let c of getScope(doc, node.node))
|
||||
completions.push(c);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
cache.set(node, completions);
|
||||
return completions;
|
||||
}
|
||||
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
|
||||
const dontComplete = [
|
||||
"TemplateString", "String", "RegExp",
|
||||
"LineComment", "BlockComment",
|
||||
"VariableDefinition", "TypeDefinition", "Label",
|
||||
"PropertyDefinition", "PropertyName",
|
||||
"PrivatePropertyDefinition", "PrivatePropertyName",
|
||||
"JSXText", "JSXAttributeValue", "JSXOpenTag", "JSXCloseTag", "JSXSelfClosingTag",
|
||||
".", "?."
|
||||
];
|
||||
/**
|
||||
Completion source that looks up locally defined names in
|
||||
JavaScript code.
|
||||
*/
|
||||
function localCompletionSource(context) {
|
||||
let inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
|
||||
if (dontComplete.indexOf(inner.name) > -1)
|
||||
return null;
|
||||
let isWord = inner.name == "VariableName" ||
|
||||
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
|
||||
if (!isWord && !context.explicit)
|
||||
return null;
|
||||
let options = [];
|
||||
for (let pos = inner; pos; pos = pos.parent) {
|
||||
if (ScopeNodes.has(pos.name))
|
||||
options = options.concat(getScope(context.state.doc, pos));
|
||||
}
|
||||
return {
|
||||
options,
|
||||
from: isWord ? inner.from : context.pos,
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
function pathFor(read, member, name) {
|
||||
var _a;
|
||||
let path = [];
|
||||
for (;;) {
|
||||
let obj = member.firstChild, prop;
|
||||
if ((obj === null || obj === void 0 ? void 0 : obj.name) == "VariableName") {
|
||||
path.push(read(obj));
|
||||
return { path: path.reverse(), name };
|
||||
}
|
||||
else if ((obj === null || obj === void 0 ? void 0 : obj.name) == "MemberExpression" && ((_a = (prop = obj.lastChild)) === null || _a === void 0 ? void 0 : _a.name) == "PropertyName") {
|
||||
path.push(read(prop));
|
||||
member = obj;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
Helper function for defining JavaScript completion sources. It
|
||||
returns the completable name and object path for a completion
|
||||
context, or null if no name/property completion should happen at
|
||||
that position. For example, when completing after `a.b.c` it will
|
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x`
|
||||
it will return `{path: [], name: "x"}`. When not in a property or
|
||||
name, it will return null if `context.explicit` is false, and
|
||||
`{path: [], name: ""}` otherwise.
|
||||
*/
|
||||
function completionPath(context) {
|
||||
let read = (node) => context.state.doc.sliceString(node.from, node.to);
|
||||
let inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
|
||||
if (inner.name == "PropertyName") {
|
||||
return pathFor(read, inner.parent, read(inner));
|
||||
}
|
||||
else if ((inner.name == "." || inner.name == "?.") && inner.parent.name == "MemberExpression") {
|
||||
return pathFor(read, inner.parent, "");
|
||||
}
|
||||
else if (dontComplete.indexOf(inner.name) > -1) {
|
||||
return null;
|
||||
}
|
||||
else if (inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(read(inner))) {
|
||||
return { path: [], name: read(inner) };
|
||||
}
|
||||
else if (inner.name == "MemberExpression") {
|
||||
return pathFor(read, inner, "");
|
||||
}
|
||||
else {
|
||||
return context.explicit ? { path: [], name: "" } : null;
|
||||
}
|
||||
}
|
||||
function enumeratePropertyCompletions(obj, top) {
|
||||
let options = [], seen = new Set;
|
||||
for (let depth = 0;; depth++) {
|
||||
for (let name of (Object.getOwnPropertyNames || Object.keys)(obj)) {
|
||||
if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) || seen.has(name))
|
||||
continue;
|
||||
seen.add(name);
|
||||
let value;
|
||||
try {
|
||||
value = obj[name];
|
||||
}
|
||||
catch (_) {
|
||||
continue;
|
||||
}
|
||||
options.push({
|
||||
label: name,
|
||||
type: typeof value == "function" ? (/^[A-Z]/.test(name) ? "class" : top ? "function" : "method")
|
||||
: top ? "variable" : "property",
|
||||
boost: -depth
|
||||
});
|
||||
}
|
||||
let next = Object.getPrototypeOf(obj);
|
||||
if (!next)
|
||||
return options;
|
||||
obj = next;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`).
|
||||
Will enter properties of the object when completing properties on
|
||||
a directly-named path.
|
||||
*/
|
||||
function scopeCompletionSource(scope) {
|
||||
let cache = new Map;
|
||||
return (context) => {
|
||||
let path = completionPath(context);
|
||||
if (!path)
|
||||
return null;
|
||||
let target = scope;
|
||||
for (let step of path.path) {
|
||||
target = target[step];
|
||||
if (!target)
|
||||
return null;
|
||||
}
|
||||
let options = cache.get(target);
|
||||
if (!options)
|
||||
cache.set(target, options = enumeratePropertyCompletions(target, !path.path.length));
|
||||
return {
|
||||
from: context.pos - path.name.length,
|
||||
options,
|
||||
validFor: Identifier
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer JavaScript
|
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const javascriptLanguage = language.LRLanguage.define({
|
||||
name: "javascript",
|
||||
parser: javascript$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
IfStatement: language.continuedIndent({ except: /^\s*({|else\b)/ }),
|
||||
TryStatement: language.continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
|
||||
LabeledStatement: language.flatIndent,
|
||||
SwitchBody: context => {
|
||||
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
|
||||
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
|
||||
},
|
||||
Block: language.delimitedIndent({ closing: "}" }),
|
||||
ArrowFunction: cx => cx.baseIndent + cx.unit,
|
||||
"TemplateString BlockComment": () => null,
|
||||
"Statement Property": language.continuedIndent({ except: /^{/ }),
|
||||
JSXElement(context) {
|
||||
let closed = /^\s*<\//.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
JSXEscape(context) {
|
||||
let closed = /\s*\}/.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
"JSXOpenTag JSXSelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
}
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": language.foldInside,
|
||||
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
|
||||
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
||||
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
|
||||
wordChars: "$"
|
||||
}
|
||||
});
|
||||
const jsxSublanguage = {
|
||||
test: node => /^JSX/.test(node.name),
|
||||
facet: language.defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
|
||||
};
|
||||
/**
|
||||
A language provider for TypeScript.
|
||||
*/
|
||||
const typescriptLanguage = javascriptLanguage.configure({ dialect: "ts" }, "typescript");
|
||||
/**
|
||||
Language provider for JSX.
|
||||
*/
|
||||
const jsxLanguage = javascriptLanguage.configure({
|
||||
dialect: "jsx",
|
||||
props: [language.sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
||||
});
|
||||
/**
|
||||
Language provider for JSX + TypeScript.
|
||||
*/
|
||||
const tsxLanguage = javascriptLanguage.configure({
|
||||
dialect: "jsx ts",
|
||||
props: [language.sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
||||
}, "typescript");
|
||||
let kwCompletion = (name) => ({ label: name, type: "keyword" });
|
||||
const keywords = "break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
|
||||
const typescriptKeywords = keywords.concat(["declare", "implements", "private", "protected", "public"].map(kwCompletion));
|
||||
/**
|
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion.
|
||||
*/
|
||||
function javascript(config = {}) {
|
||||
let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
|
||||
: config.typescript ? typescriptLanguage : javascriptLanguage;
|
||||
let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
|
||||
return new language.LanguageSupport(lang, [
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: autocomplete.ifNotIn(dontComplete, autocomplete.completeFromList(completions))
|
||||
}),
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: localCompletionSource
|
||||
}),
|
||||
config.jsx ? autoCloseTags : [],
|
||||
]);
|
||||
}
|
||||
function findOpenTag(node) {
|
||||
for (;;) {
|
||||
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
|
||||
return node;
|
||||
if (node.name == "JSXEscape" || !node.parent)
|
||||
return null;
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
|
||||
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
|
||||
ch.name == "JSXMemberExpression")
|
||||
return doc.sliceString(ch.from, Math.min(ch.to, max));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const android = typeof navigator == "object" && /Android\b/.test(navigator.userAgent);
|
||||
/**
|
||||
Extension that will automatically insert JSX close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
|
||||
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
|
||||
from != to || (text != ">" && text != "/") ||
|
||||
!javascriptLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = defaultInsert(), { state: state$1 } = base;
|
||||
let closeTags = state$1.changeByRange(range => {
|
||||
var _a;
|
||||
let { head } = range, around = language.syntaxTree(state$1).resolveInner(head - 1, -1), name;
|
||||
if (around.name == "JSXStartTag")
|
||||
around = around.parent;
|
||||
if (state$1.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
|
||||
else if (text == ">" && around.name == "JSXFragmentTag") {
|
||||
return { range, changes: { from: head, insert: `</>` } };
|
||||
}
|
||||
else if (text == "/" && around.name == "JSXStartCloseTag") {
|
||||
let empty = around.parent, base = empty.parent;
|
||||
if (base && empty.from == head - 2 &&
|
||||
((name = elementName(state$1.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
|
||||
let insert = `${name}>`;
|
||||
return { range: state.EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
|
||||
}
|
||||
}
|
||||
else if (text == ">") {
|
||||
let openTag = findOpenTag(around);
|
||||
if (openTag && openTag.name == "JSXOpenTag" &&
|
||||
!/^\/?>|^<\//.test(state$1.doc.sliceString(head, head + 2)) &&
|
||||
(name = elementName(state$1.doc, openTag, head)))
|
||||
return { range, changes: { from: head, insert: `</${name}>` } };
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state$1.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return
|
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension.
|
||||
|
||||
Note that ESLint targets node, and is tricky to run in the
|
||||
browser. The
|
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see
|
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/
|
||||
function esLint(eslint, config) {
|
||||
if (!config) {
|
||||
config = {
|
||||
parserOptions: { ecmaVersion: 2019, sourceType: "module" },
|
||||
env: { browser: true, node: true, es6: true, es2015: true, es2017: true, es2020: true },
|
||||
rules: {}
|
||||
};
|
||||
eslint.getRules().forEach((desc, name) => {
|
||||
if (desc.meta.docs.recommended)
|
||||
config.rules[name] = 2;
|
||||
});
|
||||
}
|
||||
return (view) => {
|
||||
let { state } = view, found = [];
|
||||
for (let { from, to } of javascriptLanguage.findRegions(state)) {
|
||||
let fromLine = state.doc.lineAt(from), offset = { line: fromLine.number - 1, col: from - fromLine.from, pos: from };
|
||||
for (let d of eslint.verify(state.sliceDoc(from, to), config))
|
||||
found.push(translateDiagnostic(d, state.doc, offset));
|
||||
}
|
||||
return found;
|
||||
};
|
||||
}
|
||||
function mapPos(line, col, doc, offset) {
|
||||
return doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1);
|
||||
}
|
||||
function translateDiagnostic(input, doc, offset) {
|
||||
let start = mapPos(input.line, input.column, doc, offset);
|
||||
let result = {
|
||||
from: start,
|
||||
to: input.endLine != null && input.endColumn != 1 ? mapPos(input.endLine, input.endColumn, doc, offset) : start,
|
||||
message: input.message,
|
||||
source: input.ruleId ? "eslint:" + input.ruleId : "eslint",
|
||||
severity: input.severity == 1 ? "warning" : "error",
|
||||
};
|
||||
if (input.fix) {
|
||||
let { range, text } = input.fix, from = range[0] + offset.pos - start, to = range[1] + offset.pos - start;
|
||||
result.actions = [{
|
||||
name: "fix",
|
||||
apply(view, start) {
|
||||
view.dispatch({ changes: { from: start + from, to: start + to, insert: text }, scrollIntoView: true });
|
||||
}
|
||||
}];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
exports.autoCloseTags = autoCloseTags;
|
||||
exports.completionPath = completionPath;
|
||||
exports.esLint = esLint;
|
||||
exports.javascript = javascript;
|
||||
exports.javascriptLanguage = javascriptLanguage;
|
||||
exports.jsxLanguage = jsxLanguage;
|
||||
exports.localCompletionSource = localCompletionSource;
|
||||
exports.scopeCompletionSource = scopeCompletionSource;
|
||||
exports.snippets = snippets;
|
||||
exports.tsxLanguage = tsxLanguage;
|
||||
exports.typescriptLanguage = typescriptLanguage;
|
||||
exports.typescriptSnippets = typescriptSnippets;
|
||||
93
node_modules/@codemirror/lang-javascript/dist/index.d.cts
generated
vendored
Normal file
93
node_modules/@codemirror/lang-javascript/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { Completion, CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete';
|
||||
import { Diagnostic } from '@codemirror/lint';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer JavaScript
|
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const javascriptLanguage: LRLanguage;
|
||||
/**
|
||||
A language provider for TypeScript.
|
||||
*/
|
||||
declare const typescriptLanguage: LRLanguage;
|
||||
/**
|
||||
Language provider for JSX.
|
||||
*/
|
||||
declare const jsxLanguage: LRLanguage;
|
||||
/**
|
||||
Language provider for JSX + TypeScript.
|
||||
*/
|
||||
declare const tsxLanguage: LRLanguage;
|
||||
/**
|
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion.
|
||||
*/
|
||||
declare function javascript(config?: {
|
||||
jsx?: boolean;
|
||||
typescript?: boolean;
|
||||
}): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert JSX close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
/**
|
||||
A collection of JavaScript-related
|
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/
|
||||
declare const snippets: readonly Completion[];
|
||||
/**
|
||||
A collection of snippet completions for TypeScript. Includes the
|
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/
|
||||
declare const typescriptSnippets: Completion[];
|
||||
|
||||
/**
|
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return
|
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension.
|
||||
|
||||
Note that ESLint targets node, and is tricky to run in the
|
||||
browser. The
|
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see
|
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/
|
||||
declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[];
|
||||
|
||||
/**
|
||||
Completion source that looks up locally defined names in
|
||||
JavaScript code.
|
||||
*/
|
||||
declare function localCompletionSource(context: CompletionContext): CompletionResult | null;
|
||||
/**
|
||||
Helper function for defining JavaScript completion sources. It
|
||||
returns the completable name and object path for a completion
|
||||
context, or null if no name/property completion should happen at
|
||||
that position. For example, when completing after `a.b.c` it will
|
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x`
|
||||
it will return `{path: [], name: "x"}`. When not in a property or
|
||||
name, it will return null if `context.explicit` is false, and
|
||||
`{path: [], name: ""}` otherwise.
|
||||
*/
|
||||
declare function completionPath(context: CompletionContext): {
|
||||
path: readonly string[];
|
||||
name: string;
|
||||
} | null;
|
||||
/**
|
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`).
|
||||
Will enter properties of the object when completing properties on
|
||||
a directly-named path.
|
||||
*/
|
||||
declare function scopeCompletionSource(scope: any): CompletionSource;
|
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets };
|
||||
93
node_modules/@codemirror/lang-javascript/dist/index.d.ts
generated
vendored
Normal file
93
node_modules/@codemirror/lang-javascript/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { Completion, CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete';
|
||||
import { Diagnostic } from '@codemirror/lint';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer JavaScript
|
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const javascriptLanguage: LRLanguage;
|
||||
/**
|
||||
A language provider for TypeScript.
|
||||
*/
|
||||
declare const typescriptLanguage: LRLanguage;
|
||||
/**
|
||||
Language provider for JSX.
|
||||
*/
|
||||
declare const jsxLanguage: LRLanguage;
|
||||
/**
|
||||
Language provider for JSX + TypeScript.
|
||||
*/
|
||||
declare const tsxLanguage: LRLanguage;
|
||||
/**
|
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion.
|
||||
*/
|
||||
declare function javascript(config?: {
|
||||
jsx?: boolean;
|
||||
typescript?: boolean;
|
||||
}): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert JSX close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
/**
|
||||
A collection of JavaScript-related
|
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/
|
||||
declare const snippets: readonly Completion[];
|
||||
/**
|
||||
A collection of snippet completions for TypeScript. Includes the
|
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/
|
||||
declare const typescriptSnippets: Completion[];
|
||||
|
||||
/**
|
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return
|
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension.
|
||||
|
||||
Note that ESLint targets node, and is tricky to run in the
|
||||
browser. The
|
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see
|
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/
|
||||
declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[];
|
||||
|
||||
/**
|
||||
Completion source that looks up locally defined names in
|
||||
JavaScript code.
|
||||
*/
|
||||
declare function localCompletionSource(context: CompletionContext): CompletionResult | null;
|
||||
/**
|
||||
Helper function for defining JavaScript completion sources. It
|
||||
returns the completable name and object path for a completion
|
||||
context, or null if no name/property completion should happen at
|
||||
that position. For example, when completing after `a.b.c` it will
|
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x`
|
||||
it will return `{path: [], name: "x"}`. When not in a property or
|
||||
name, it will return null if `context.explicit` is false, and
|
||||
`{path: [], name: ""}` otherwise.
|
||||
*/
|
||||
declare function completionPath(context: CompletionContext): {
|
||||
path: readonly string[];
|
||||
name: string;
|
||||
} | null;
|
||||
/**
|
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`).
|
||||
Will enter properties of the object when completing properties on
|
||||
a directly-named path.
|
||||
*/
|
||||
declare function scopeCompletionSource(scope: any): CompletionSource;
|
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets };
|
||||
497
node_modules/@codemirror/lang-javascript/dist/index.js
generated
vendored
Normal file
497
node_modules/@codemirror/lang-javascript/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,497 @@
|
||||
import { parser } from '@lezer/javascript';
|
||||
import { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, flatIndent, delimitedIndent, foldNodeProp, foldInside, defineLanguageFacet, sublanguageProp, LanguageSupport } from '@codemirror/language';
|
||||
import { EditorSelection } from '@codemirror/state';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
import { snippetCompletion, ifNotIn, completeFromList } from '@codemirror/autocomplete';
|
||||
import { NodeWeakMap, IterMode } from '@lezer/common';
|
||||
|
||||
/**
|
||||
A collection of JavaScript-related
|
||||
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
||||
*/
|
||||
const snippets = [
|
||||
/*@__PURE__*/snippetCompletion("function ${name}(${params}) {\n\t${}\n}", {
|
||||
label: "function",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n\t${}\n}", {
|
||||
label: "for",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("for (let ${name} of ${collection}) {\n\t${}\n}", {
|
||||
label: "for",
|
||||
detail: "of loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("do {\n\t${}\n} while (${})", {
|
||||
label: "do",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("while (${}) {\n\t${}\n}", {
|
||||
label: "while",
|
||||
detail: "loop",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("try {\n\t${}\n} catch (${error}) {\n\t${}\n}", {
|
||||
label: "try",
|
||||
detail: "/ catch block",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n}", {
|
||||
label: "if",
|
||||
detail: "block",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("if (${}) {\n\t${}\n} else {\n\t${}\n}", {
|
||||
label: "if",
|
||||
detail: "/ else block",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("class ${name} {\n\tconstructor(${params}) {\n\t\t${}\n\t}\n}", {
|
||||
label: "class",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("import {${names}} from \"${module}\"\n${}", {
|
||||
label: "import",
|
||||
detail: "named",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("import ${name} from \"${module}\"\n${}", {
|
||||
label: "import",
|
||||
detail: "default",
|
||||
type: "keyword"
|
||||
})
|
||||
];
|
||||
/**
|
||||
A collection of snippet completions for TypeScript. Includes the
|
||||
JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets).
|
||||
*/
|
||||
const typescriptSnippets = /*@__PURE__*/snippets.concat([
|
||||
/*@__PURE__*/snippetCompletion("interface ${name} {\n\t${}\n}", {
|
||||
label: "interface",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("type ${name} = ${type}", {
|
||||
label: "type",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
}),
|
||||
/*@__PURE__*/snippetCompletion("enum ${name} {\n\t${}\n}", {
|
||||
label: "enum",
|
||||
detail: "definition",
|
||||
type: "keyword"
|
||||
})
|
||||
]);
|
||||
|
||||
const cache = /*@__PURE__*/new NodeWeakMap();
|
||||
const ScopeNodes = /*@__PURE__*/new Set([
|
||||
"Script", "Block",
|
||||
"FunctionExpression", "FunctionDeclaration", "ArrowFunction", "MethodDeclaration",
|
||||
"ForStatement"
|
||||
]);
|
||||
function defID(type) {
|
||||
return (node, def) => {
|
||||
let id = node.node.getChild("VariableDefinition");
|
||||
if (id)
|
||||
def(id, type);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
const functionContext = ["FunctionDeclaration"];
|
||||
const gatherCompletions = {
|
||||
FunctionDeclaration: /*@__PURE__*/defID("function"),
|
||||
ClassDeclaration: /*@__PURE__*/defID("class"),
|
||||
ClassExpression: () => true,
|
||||
EnumDeclaration: /*@__PURE__*/defID("constant"),
|
||||
TypeAliasDeclaration: /*@__PURE__*/defID("type"),
|
||||
NamespaceDeclaration: /*@__PURE__*/defID("namespace"),
|
||||
VariableDefinition(node, def) { if (!node.matchContext(functionContext))
|
||||
def(node, "variable"); },
|
||||
TypeDefinition(node, def) { def(node, "type"); },
|
||||
__proto__: null
|
||||
};
|
||||
function getScope(doc, node) {
|
||||
let cached = cache.get(node);
|
||||
if (cached)
|
||||
return cached;
|
||||
let completions = [], top = true;
|
||||
function def(node, type) {
|
||||
let name = doc.sliceString(node.from, node.to);
|
||||
completions.push({ label: name, type });
|
||||
}
|
||||
node.cursor(IterMode.IncludeAnonymous).iterate(node => {
|
||||
if (top) {
|
||||
top = false;
|
||||
}
|
||||
else if (node.name) {
|
||||
let gather = gatherCompletions[node.name];
|
||||
if (gather && gather(node, def) || ScopeNodes.has(node.name))
|
||||
return false;
|
||||
}
|
||||
else if (node.to - node.from > 8192) {
|
||||
// Allow caching for bigger internal nodes
|
||||
for (let c of getScope(doc, node.node))
|
||||
completions.push(c);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
cache.set(node, completions);
|
||||
return completions;
|
||||
}
|
||||
const Identifier = /^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/;
|
||||
const dontComplete = [
|
||||
"TemplateString", "String", "RegExp",
|
||||
"LineComment", "BlockComment",
|
||||
"VariableDefinition", "TypeDefinition", "Label",
|
||||
"PropertyDefinition", "PropertyName",
|
||||
"PrivatePropertyDefinition", "PrivatePropertyName",
|
||||
"JSXText", "JSXAttributeValue", "JSXOpenTag", "JSXCloseTag", "JSXSelfClosingTag",
|
||||
".", "?."
|
||||
];
|
||||
/**
|
||||
Completion source that looks up locally defined names in
|
||||
JavaScript code.
|
||||
*/
|
||||
function localCompletionSource(context) {
|
||||
let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
||||
if (dontComplete.indexOf(inner.name) > -1)
|
||||
return null;
|
||||
let isWord = inner.name == "VariableName" ||
|
||||
inner.to - inner.from < 20 && Identifier.test(context.state.sliceDoc(inner.from, inner.to));
|
||||
if (!isWord && !context.explicit)
|
||||
return null;
|
||||
let options = [];
|
||||
for (let pos = inner; pos; pos = pos.parent) {
|
||||
if (ScopeNodes.has(pos.name))
|
||||
options = options.concat(getScope(context.state.doc, pos));
|
||||
}
|
||||
return {
|
||||
options,
|
||||
from: isWord ? inner.from : context.pos,
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
function pathFor(read, member, name) {
|
||||
var _a;
|
||||
let path = [];
|
||||
for (;;) {
|
||||
let obj = member.firstChild, prop;
|
||||
if ((obj === null || obj === void 0 ? void 0 : obj.name) == "VariableName") {
|
||||
path.push(read(obj));
|
||||
return { path: path.reverse(), name };
|
||||
}
|
||||
else if ((obj === null || obj === void 0 ? void 0 : obj.name) == "MemberExpression" && ((_a = (prop = obj.lastChild)) === null || _a === void 0 ? void 0 : _a.name) == "PropertyName") {
|
||||
path.push(read(prop));
|
||||
member = obj;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
Helper function for defining JavaScript completion sources. It
|
||||
returns the completable name and object path for a completion
|
||||
context, or null if no name/property completion should happen at
|
||||
that position. For example, when completing after `a.b.c` it will
|
||||
return `{path: ["a", "b"], name: "c"}`. When completing after `x`
|
||||
it will return `{path: [], name: "x"}`. When not in a property or
|
||||
name, it will return null if `context.explicit` is false, and
|
||||
`{path: [], name: ""}` otherwise.
|
||||
*/
|
||||
function completionPath(context) {
|
||||
let read = (node) => context.state.doc.sliceString(node.from, node.to);
|
||||
let inner = syntaxTree(context.state).resolveInner(context.pos, -1);
|
||||
if (inner.name == "PropertyName") {
|
||||
return pathFor(read, inner.parent, read(inner));
|
||||
}
|
||||
else if ((inner.name == "." || inner.name == "?.") && inner.parent.name == "MemberExpression") {
|
||||
return pathFor(read, inner.parent, "");
|
||||
}
|
||||
else if (dontComplete.indexOf(inner.name) > -1) {
|
||||
return null;
|
||||
}
|
||||
else if (inner.name == "VariableName" || inner.to - inner.from < 20 && Identifier.test(read(inner))) {
|
||||
return { path: [], name: read(inner) };
|
||||
}
|
||||
else if (inner.name == "MemberExpression") {
|
||||
return pathFor(read, inner, "");
|
||||
}
|
||||
else {
|
||||
return context.explicit ? { path: [], name: "" } : null;
|
||||
}
|
||||
}
|
||||
function enumeratePropertyCompletions(obj, top) {
|
||||
let options = [], seen = new Set;
|
||||
for (let depth = 0;; depth++) {
|
||||
for (let name of (Object.getOwnPropertyNames || Object.keys)(obj)) {
|
||||
if (!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(name) || seen.has(name))
|
||||
continue;
|
||||
seen.add(name);
|
||||
let value;
|
||||
try {
|
||||
value = obj[name];
|
||||
}
|
||||
catch (_) {
|
||||
continue;
|
||||
}
|
||||
options.push({
|
||||
label: name,
|
||||
type: typeof value == "function" ? (/^[A-Z]/.test(name) ? "class" : top ? "function" : "method")
|
||||
: top ? "variable" : "property",
|
||||
boost: -depth
|
||||
});
|
||||
}
|
||||
let next = Object.getPrototypeOf(obj);
|
||||
if (!next)
|
||||
return options;
|
||||
obj = next;
|
||||
}
|
||||
}
|
||||
/**
|
||||
Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that
|
||||
completes from the given scope object (for example `globalThis`).
|
||||
Will enter properties of the object when completing properties on
|
||||
a directly-named path.
|
||||
*/
|
||||
function scopeCompletionSource(scope) {
|
||||
let cache = new Map;
|
||||
return (context) => {
|
||||
let path = completionPath(context);
|
||||
if (!path)
|
||||
return null;
|
||||
let target = scope;
|
||||
for (let step of path.path) {
|
||||
target = target[step];
|
||||
if (!target)
|
||||
return null;
|
||||
}
|
||||
let options = cache.get(target);
|
||||
if (!options)
|
||||
cache.set(target, options = enumeratePropertyCompletions(target, !path.path.length));
|
||||
return {
|
||||
from: context.pos - path.name.length,
|
||||
options,
|
||||
validFor: Identifier
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer JavaScript
|
||||
parser](https://github.com/lezer-parser/javascript), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const javascriptLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "javascript",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
IfStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|else\b)/ }),
|
||||
TryStatement: /*@__PURE__*/continuedIndent({ except: /^\s*({|catch\b|finally\b)/ }),
|
||||
LabeledStatement: flatIndent,
|
||||
SwitchBody: context => {
|
||||
let after = context.textAfter, closed = /^\s*\}/.test(after), isCase = /^\s*(case|default)\b/.test(after);
|
||||
return context.baseIndent + (closed ? 0 : isCase ? 1 : 2) * context.unit;
|
||||
},
|
||||
Block: /*@__PURE__*/delimitedIndent({ closing: "}" }),
|
||||
ArrowFunction: cx => cx.baseIndent + cx.unit,
|
||||
"TemplateString BlockComment": () => null,
|
||||
"Statement Property": /*@__PURE__*/continuedIndent({ except: /^{/ }),
|
||||
JSXElement(context) {
|
||||
let closed = /^\s*<\//.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
JSXEscape(context) {
|
||||
let closed = /\s*\}/.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
"JSXOpenTag JSXSelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
}
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType": foldInside,
|
||||
BlockComment(tree) { return { from: tree.from + 2, to: tree.to - 2 }; }
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
|
||||
commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
|
||||
indentOnInput: /^\s*(?:case |default:|\{|\}|<\/)$/,
|
||||
wordChars: "$"
|
||||
}
|
||||
});
|
||||
const jsxSublanguage = {
|
||||
test: node => /^JSX/.test(node.name),
|
||||
facet: /*@__PURE__*/defineLanguageFacet({ commentTokens: { block: { open: "{/*", close: "*/}" } } })
|
||||
};
|
||||
/**
|
||||
A language provider for TypeScript.
|
||||
*/
|
||||
const typescriptLanguage = /*@__PURE__*/javascriptLanguage.configure({ dialect: "ts" }, "typescript");
|
||||
/**
|
||||
Language provider for JSX.
|
||||
*/
|
||||
const jsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
|
||||
dialect: "jsx",
|
||||
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
||||
});
|
||||
/**
|
||||
Language provider for JSX + TypeScript.
|
||||
*/
|
||||
const tsxLanguage = /*@__PURE__*/javascriptLanguage.configure({
|
||||
dialect: "jsx ts",
|
||||
props: [/*@__PURE__*/sublanguageProp.add(n => n.isTop ? [jsxSublanguage] : undefined)]
|
||||
}, "typescript");
|
||||
let kwCompletion = (name) => ({ label: name, type: "keyword" });
|
||||
const keywords = /*@__PURE__*/"break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(kwCompletion);
|
||||
const typescriptKeywords = /*@__PURE__*/keywords.concat(/*@__PURE__*/["declare", "implements", "private", "protected", "public"].map(kwCompletion));
|
||||
/**
|
||||
JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets)
|
||||
and local variable completion.
|
||||
*/
|
||||
function javascript(config = {}) {
|
||||
let lang = config.jsx ? (config.typescript ? tsxLanguage : jsxLanguage)
|
||||
: config.typescript ? typescriptLanguage : javascriptLanguage;
|
||||
let completions = config.typescript ? typescriptSnippets.concat(typescriptKeywords) : snippets.concat(keywords);
|
||||
return new LanguageSupport(lang, [
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: ifNotIn(dontComplete, completeFromList(completions))
|
||||
}),
|
||||
javascriptLanguage.data.of({
|
||||
autocomplete: localCompletionSource
|
||||
}),
|
||||
config.jsx ? autoCloseTags : [],
|
||||
]);
|
||||
}
|
||||
function findOpenTag(node) {
|
||||
for (;;) {
|
||||
if (node.name == "JSXOpenTag" || node.name == "JSXSelfClosingTag" || node.name == "JSXFragmentTag")
|
||||
return node;
|
||||
if (node.name == "JSXEscape" || !node.parent)
|
||||
return null;
|
||||
node = node.parent;
|
||||
}
|
||||
}
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
for (let ch = tree === null || tree === void 0 ? void 0 : tree.firstChild; ch; ch = ch.nextSibling) {
|
||||
if (ch.name == "JSXIdentifier" || ch.name == "JSXBuiltin" || ch.name == "JSXNamespacedName" ||
|
||||
ch.name == "JSXMemberExpression")
|
||||
return doc.sliceString(ch.from, Math.min(ch.to, max));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const android = typeof navigator == "object" && /*@__PURE__*//Android\b/.test(navigator.userAgent);
|
||||
/**
|
||||
Extension that will automatically insert JSX close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, defaultInsert) => {
|
||||
if ((android ? view.composing : view.compositionStarted) || view.state.readOnly ||
|
||||
from != to || (text != ">" && text != "/") ||
|
||||
!javascriptLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = defaultInsert(), { state } = base;
|
||||
let closeTags = state.changeByRange(range => {
|
||||
var _a;
|
||||
let { head } = range, around = syntaxTree(state).resolveInner(head - 1, -1), name;
|
||||
if (around.name == "JSXStartTag")
|
||||
around = around.parent;
|
||||
if (state.doc.sliceString(head - 1, head) != text || around.name == "JSXAttributeValue" && around.to > head) ;
|
||||
else if (text == ">" && around.name == "JSXFragmentTag") {
|
||||
return { range, changes: { from: head, insert: `</>` } };
|
||||
}
|
||||
else if (text == "/" && around.name == "JSXStartCloseTag") {
|
||||
let empty = around.parent, base = empty.parent;
|
||||
if (base && empty.from == head - 2 &&
|
||||
((name = elementName(state.doc, base.firstChild, head)) || ((_a = base.firstChild) === null || _a === void 0 ? void 0 : _a.name) == "JSXFragmentTag")) {
|
||||
let insert = `${name}>`;
|
||||
return { range: EditorSelection.cursor(head + insert.length, -1), changes: { from: head, insert } };
|
||||
}
|
||||
}
|
||||
else if (text == ">") {
|
||||
let openTag = findOpenTag(around);
|
||||
if (openTag && openTag.name == "JSXOpenTag" &&
|
||||
!/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) &&
|
||||
(name = elementName(state.doc, openTag, head)))
|
||||
return { range, changes: { from: head, insert: `</${name}>` } };
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state.update(closeTags, { userEvent: "input.complete", scrollIntoView: true })
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
Connects an [ESLint](https://eslint.org/) linter to CodeMirror's
|
||||
[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the
|
||||
[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter)
|
||||
class, and `config` an optional ESLint configuration. The return
|
||||
value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter)
|
||||
to create a JavaScript linting extension.
|
||||
|
||||
Note that ESLint targets node, and is tricky to run in the
|
||||
browser. The
|
||||
[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify)
|
||||
package may help with that (see
|
||||
[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)).
|
||||
*/
|
||||
function esLint(eslint, config) {
|
||||
if (!config) {
|
||||
config = {
|
||||
parserOptions: { ecmaVersion: 2019, sourceType: "module" },
|
||||
env: { browser: true, node: true, es6: true, es2015: true, es2017: true, es2020: true },
|
||||
rules: {}
|
||||
};
|
||||
eslint.getRules().forEach((desc, name) => {
|
||||
if (desc.meta.docs.recommended)
|
||||
config.rules[name] = 2;
|
||||
});
|
||||
}
|
||||
return (view) => {
|
||||
let { state } = view, found = [];
|
||||
for (let { from, to } of javascriptLanguage.findRegions(state)) {
|
||||
let fromLine = state.doc.lineAt(from), offset = { line: fromLine.number - 1, col: from - fromLine.from, pos: from };
|
||||
for (let d of eslint.verify(state.sliceDoc(from, to), config))
|
||||
found.push(translateDiagnostic(d, state.doc, offset));
|
||||
}
|
||||
return found;
|
||||
};
|
||||
}
|
||||
function mapPos(line, col, doc, offset) {
|
||||
return doc.line(line + offset.line).from + col + (line == 1 ? offset.col - 1 : -1);
|
||||
}
|
||||
function translateDiagnostic(input, doc, offset) {
|
||||
let start = mapPos(input.line, input.column, doc, offset);
|
||||
let result = {
|
||||
from: start,
|
||||
to: input.endLine != null && input.endColumn != 1 ? mapPos(input.endLine, input.endColumn, doc, offset) : start,
|
||||
message: input.message,
|
||||
source: input.ruleId ? "eslint:" + input.ruleId : "eslint",
|
||||
severity: input.severity == 1 ? "warning" : "error",
|
||||
};
|
||||
if (input.fix) {
|
||||
let { range, text } = input.fix, from = range[0] + offset.pos - start, to = range[1] + offset.pos - start;
|
||||
result.actions = [{
|
||||
name: "fix",
|
||||
apply(view, start) {
|
||||
view.dispatch({ changes: { from: start + from, to: start + to, insert: text }, scrollIntoView: true });
|
||||
}
|
||||
}];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets };
|
||||
45
node_modules/@codemirror/lang-javascript/package.json
generated
vendored
Normal file
45
node_modules/@codemirror/lang-javascript/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@codemirror/lang-javascript",
|
||||
"version": "6.2.3",
|
||||
"description": "JavaScript language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
"@codemirror/lint": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/javascript": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lang-javascript.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-json/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-json/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
54
node_modules/@codemirror/lang-json/CHANGELOG.md
generated
vendored
Normal file
54
node_modules/@codemirror/lang-json/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
## 6.0.1 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the language object has a name.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.20.0
|
||||
|
||||
## 0.19.2 (2022-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix highlighting of `null` tokens.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lang-json/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-json/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
43
node_modules/@codemirror/lang-json/README.md
generated
vendored
Normal file
43
node_modules/@codemirror/lang-json/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-json [](https://www.npmjs.org/package/@codemirror/lang-json)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-json/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements JSON language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-json/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## API Reference
|
||||
<dl>
|
||||
<dt id="user-content-json">
|
||||
<code><strong><a href="#user-content-json">json</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>JSON language support.</p>
|
||||
</dd>
|
||||
<dt id="user-content-jsonlanguage">
|
||||
<code><strong><a href="#user-content-jsonlanguage">jsonLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LezerLanguage">LezerLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider that provides JSON parsing.</p>
|
||||
</dd>
|
||||
<dt id="user-content-jsonparselinter">
|
||||
<code><strong><a href="#user-content-jsonparselinter">jsonParseLinter</a></strong>() → fn(<a id="user-content-jsonparselinter^returns^view" href="#user-content-jsonparselinter^returns^view">view</a>: <a href="https://codemirror.net/docs/ref#view.EditorView">EditorView</a>) → <a href="https://codemirror.net/docs/ref#lint.Diagnostic">Diagnostic</a>[]</code></dt>
|
||||
|
||||
<dd><p>Calls
|
||||
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse"><code>JSON.parse</code></a>
|
||||
on the document and, if that throws an error, reports it as a
|
||||
single diagnostic.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
70
node_modules/@codemirror/lang-json/dist/index.cjs
generated
vendored
Normal file
70
node_modules/@codemirror/lang-json/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var json$1 = require('@lezer/json');
|
||||
var language = require('@codemirror/language');
|
||||
|
||||
/**
|
||||
Calls
|
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
|
||||
on the document and, if that throws an error, reports it as a
|
||||
single diagnostic.
|
||||
*/
|
||||
const jsonParseLinter = () => (view) => {
|
||||
try {
|
||||
JSON.parse(view.state.doc.toString());
|
||||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof SyntaxError))
|
||||
throw e;
|
||||
const pos = getErrorPosition(e, view.state.doc);
|
||||
return [{
|
||||
from: pos,
|
||||
message: e.message,
|
||||
severity: 'error',
|
||||
to: pos
|
||||
}];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
function getErrorPosition(error, doc) {
|
||||
let m;
|
||||
if (m = error.message.match(/at position (\d+)/))
|
||||
return Math.min(+m[1], doc.length);
|
||||
if (m = error.message.match(/at line (\d+) column (\d+)/))
|
||||
return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider that provides JSON parsing.
|
||||
*/
|
||||
const jsonLanguage = language.LRLanguage.define({
|
||||
name: "json",
|
||||
parser: json$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
Object: language.continuedIndent({ except: /^\s*\}/ }),
|
||||
Array: language.continuedIndent({ except: /^\s*\]/ })
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
"Object Array": language.foldInside
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
closeBrackets: { brackets: ["[", "{", '"'] },
|
||||
indentOnInput: /^\s*[\}\]]$/
|
||||
}
|
||||
});
|
||||
/**
|
||||
JSON language support.
|
||||
*/
|
||||
function json() {
|
||||
return new language.LanguageSupport(jsonLanguage);
|
||||
}
|
||||
|
||||
exports.json = json;
|
||||
exports.jsonLanguage = jsonLanguage;
|
||||
exports.jsonParseLinter = jsonParseLinter;
|
||||
22
node_modules/@codemirror/lang-json/dist/index.d.ts
generated
vendored
Normal file
22
node_modules/@codemirror/lang-json/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { Diagnostic } from '@codemirror/lint';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
Calls
|
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
|
||||
on the document and, if that throws an error, reports it as a
|
||||
single diagnostic.
|
||||
*/
|
||||
declare const jsonParseLinter: () => (view: EditorView) => Diagnostic[];
|
||||
|
||||
/**
|
||||
A language provider that provides JSON parsing.
|
||||
*/
|
||||
declare const jsonLanguage: LRLanguage;
|
||||
/**
|
||||
JSON language support.
|
||||
*/
|
||||
declare function json(): LanguageSupport;
|
||||
|
||||
export { json, jsonLanguage, jsonParseLinter };
|
||||
64
node_modules/@codemirror/lang-json/dist/index.js
generated
vendored
Normal file
64
node_modules/@codemirror/lang-json/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import { parser } from '@lezer/json';
|
||||
import { LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
|
||||
|
||||
/**
|
||||
Calls
|
||||
[`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
|
||||
on the document and, if that throws an error, reports it as a
|
||||
single diagnostic.
|
||||
*/
|
||||
const jsonParseLinter = () => (view) => {
|
||||
try {
|
||||
JSON.parse(view.state.doc.toString());
|
||||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof SyntaxError))
|
||||
throw e;
|
||||
const pos = getErrorPosition(e, view.state.doc);
|
||||
return [{
|
||||
from: pos,
|
||||
message: e.message,
|
||||
severity: 'error',
|
||||
to: pos
|
||||
}];
|
||||
}
|
||||
return [];
|
||||
};
|
||||
function getErrorPosition(error, doc) {
|
||||
let m;
|
||||
if (m = error.message.match(/at position (\d+)/))
|
||||
return Math.min(+m[1], doc.length);
|
||||
if (m = error.message.match(/at line (\d+) column (\d+)/))
|
||||
return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider that provides JSON parsing.
|
||||
*/
|
||||
const jsonLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "json",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
Object: /*@__PURE__*/continuedIndent({ except: /^\s*\}/ }),
|
||||
Array: /*@__PURE__*/continuedIndent({ except: /^\s*\]/ })
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
"Object Array": foldInside
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
closeBrackets: { brackets: ["[", "{", '"'] },
|
||||
indentOnInput: /^\s*[\}\]]$/
|
||||
}
|
||||
});
|
||||
/**
|
||||
JSON language support.
|
||||
*/
|
||||
function json() {
|
||||
return new LanguageSupport(jsonLanguage);
|
||||
}
|
||||
|
||||
export { json, jsonLanguage, jsonParseLinter };
|
||||
39
node_modules/@codemirror/lang-json/package.json
generated
vendored
Normal file
39
node_modules/@codemirror/lang-json/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@codemirror/lang-json",
|
||||
"version": "6.0.1",
|
||||
"description": "JSON language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/json.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@lezer/json": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lang-json.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-xml/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-xml/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
72
node_modules/@codemirror/lang-xml/CHANGELOG.md
generated
vendored
Normal file
72
node_modules/@codemirror/lang-xml/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
## 6.1.0 (2024-03-06)
|
||||
|
||||
### New features
|
||||
|
||||
Add an `autoCloseTags` extension that closes tags on typing > or /. Enable it by default in the `xml()` language support.
|
||||
|
||||
## 6.0.2 (2023-01-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use only the tag name for matching of opening and closing tags.
|
||||
|
||||
## 6.0.1 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the language object has a name.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.20.0
|
||||
|
||||
## 0.19.2 (2021-09-23)
|
||||
|
||||
### New features
|
||||
|
||||
Use more specific highlighting tags for attribute names and values.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
## 0.17.2 (2021-02-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Export configuration types and `completeFromSchema` function (which were previously accidentally unexported).
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lang-xml/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-xml/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
137
node_modules/@codemirror/lang-xml/README.md
generated
vendored
Normal file
137
node_modules/@codemirror/lang-xml/README.md
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-xml [](https://www.npmjs.org/package/@codemirror/lang-xml)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-xml/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements XML language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-xml/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## API Reference
|
||||
|
||||
<dl>
|
||||
<dt id="user-content-xml">
|
||||
<code><strong><a href="#user-content-xml">xml</a></strong>(<a id="user-content-xml^conf" href="#user-content-xml^conf">conf</a>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a> = {}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>XML language support. Includes schema-based autocompletion when
|
||||
configured.</p>
|
||||
<dl><dt id="user-content-xml^conf">
|
||||
<code><strong><a href="#user-content-xml^conf">conf</a></strong></code></dt>
|
||||
|
||||
<dd><dl><dt id="user-content-xml^conf.elements">
|
||||
<code><strong><a href="#user-content-xml^conf.elements">elements</a></strong>⁠?: readonly <a href="#user-content-elementspec">ElementSpec</a>[]</code></dt>
|
||||
|
||||
<dd><p>Provide a schema to create completions from.</p>
|
||||
</dd><dt id="user-content-xml^conf.attributes">
|
||||
<code><strong><a href="#user-content-xml^conf.attributes">attributes</a></strong>⁠?: readonly <a href="#user-content-attrspec">AttrSpec</a>[]</code></dt>
|
||||
|
||||
<dd><p>Supporting attribute descriptions for the schema specified in
|
||||
<a href="#user-content-xml%5econf.elements"><code>elements</code></a>.</p>
|
||||
</dd><dt id="user-content-xml^conf.autoclosetags">
|
||||
<code><strong><a href="#user-content-xml^conf.autoclosetags">autoCloseTags</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>Determines whether <a href="#user-content-autoclosetags"><code>autoCloseTags</code></a>
|
||||
is included in the support extensions. Defaults to true.</p>
|
||||
</dd></dl></dd></dl></dd>
|
||||
<dt id="user-content-xmllanguage">
|
||||
<code><strong><a href="#user-content-xmllanguage">xmlLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/xml">Lezer XML
|
||||
parser</a>, extended with
|
||||
highlighting and indentation information.</p>
|
||||
</dd>
|
||||
<dt id="user-content-elementspec">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-elementspec">ElementSpec</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Describes an element in your XML document schema.</p>
|
||||
<dl><dt id="user-content-elementspec.name">
|
||||
<code><strong><a href="#user-content-elementspec.name">name</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>The element name.</p>
|
||||
</dd><dt id="user-content-elementspec.children">
|
||||
<code><strong><a href="#user-content-elementspec.children">children</a></strong>⁠?: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[]</code></dt>
|
||||
|
||||
<dd><p>Allowed children in this element. When not given, all elements
|
||||
are allowed inside it.</p>
|
||||
</dd><dt id="user-content-elementspec.textcontent">
|
||||
<code><strong><a href="#user-content-elementspec.textcontent">textContent</a></strong>⁠?: readonly <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>[]</code></dt>
|
||||
|
||||
<dd><p>When given, allows users to complete the given content strings
|
||||
as plain text when at the start of the element.</p>
|
||||
</dd><dt id="user-content-elementspec.top">
|
||||
<code><strong><a href="#user-content-elementspec.top">top</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>Whether this element may appear at the top of the document.</p>
|
||||
</dd><dt id="user-content-elementspec.attributes">
|
||||
<code><strong><a href="#user-content-elementspec.attributes">attributes</a></strong>⁠?: readonly (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="#user-content-attrspec">AttrSpec</a>)[]</code></dt>
|
||||
|
||||
<dd><p>Allowed attributes in this element. Strings refer to attributes
|
||||
specified in <a href="#user-content-xmlconfig.attrs"><code>XMLConfig.attrs</code></a>, but
|
||||
you can also provide one-off <a href="#user-content-attrspec">attribute
|
||||
specs</a>. Attributes marked as
|
||||
<a href="#user-content-attrspec.global"><code>global</code></a> are allowed in every
|
||||
element, and don't have to be mentioned here.</p>
|
||||
</dd><dt id="user-content-elementspec.completion">
|
||||
<code><strong><a href="#user-content-elementspec.completion">completion</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype">Partial</a><<a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>></code></dt>
|
||||
|
||||
<dd><p>Can be provided to add extra fields to the
|
||||
<a href="#user-content-autocompletion.completion">completion</a> object created for this
|
||||
element.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
<dt id="user-content-attrspec">
|
||||
<h4>
|
||||
<code>interface</code>
|
||||
<a href="#user-content-attrspec">AttrSpec</a></h4>
|
||||
</dt>
|
||||
|
||||
<dd><p>Describes an attribute in your XML schema.</p>
|
||||
<dl><dt id="user-content-attrspec.name">
|
||||
<code><strong><a href="#user-content-attrspec.name">name</a></strong>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></dt>
|
||||
|
||||
<dd><p>The attribute name.</p>
|
||||
</dd><dt id="user-content-attrspec.values">
|
||||
<code><strong><a href="#user-content-attrspec.values">values</a></strong>⁠?: readonly (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>)[]</code></dt>
|
||||
|
||||
<dd><p>Pre-defined values to complete for this attribute.</p>
|
||||
</dd><dt id="user-content-attrspec.global">
|
||||
<code><strong><a href="#user-content-attrspec.global">global</a></strong>⁠?: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></dt>
|
||||
|
||||
<dd><p>When <code>true</code>, this attribute can be added to all elements.</p>
|
||||
</dd><dt id="user-content-attrspec.completion">
|
||||
<code><strong><a href="#user-content-attrspec.completion">completion</a></strong>⁠?: <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype">Partial</a><<a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>></code></dt>
|
||||
|
||||
<dd><p>Provides extra fields to the
|
||||
<a href="#user-content-autocompletion.completion">completion</a> object created for this
|
||||
element</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd>
|
||||
<dt id="user-content-completefromschema">
|
||||
<code><strong><a href="#user-content-completefromschema">completeFromSchema</a></strong>(<a id="user-content-completefromschema^eltspecs" href="#user-content-completefromschema^eltspecs">eltSpecs</a>: readonly <a href="#user-content-elementspec">ElementSpec</a>[], <a id="user-content-completefromschema^attrspecs" href="#user-content-completefromschema^attrspecs">attrSpecs</a>: readonly <a href="#user-content-attrspec">AttrSpec</a>[]) → <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
|
||||
|
||||
<dd><p>Create a completion source for the given schema.</p>
|
||||
</dd>
|
||||
<dt id="user-content-autoclosetags">
|
||||
<code><strong><a href="#user-content-autoclosetags">autoCloseTags</a></strong>: <a href="https://codemirror.net/docs/ref#state.Extension">Extension</a></code></dt>
|
||||
|
||||
<dd><p>Extension that will automatically insert close tags when a <code>></code> or
|
||||
<code>/</code> is typed.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
314
node_modules/@codemirror/lang-xml/dist/index.cjs
generated
vendored
Normal file
314
node_modules/@codemirror/lang-xml/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
'use strict';
|
||||
|
||||
var xml$1 = require('@lezer/xml');
|
||||
var language = require('@codemirror/language');
|
||||
var state = require('@codemirror/state');
|
||||
var view = require('@codemirror/view');
|
||||
|
||||
function tagName(doc, tag) {
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, name.to) : "";
|
||||
}
|
||||
function elementName$1(doc, tree) {
|
||||
let tag = tree && tree.firstChild;
|
||||
return !tag || tag.name != "OpenTag" ? "" : tagName(doc, tag);
|
||||
}
|
||||
function attrName(doc, tag, pos) {
|
||||
let attr = tag && tag.getChildren("Attribute").find(a => a.from <= pos && a.to >= pos);
|
||||
let name = attr && attr.getChild("AttributeName");
|
||||
return name ? doc.sliceString(name.from, name.to) : "";
|
||||
}
|
||||
function findParentElement(tree) {
|
||||
for (let cur = tree && tree.parent; cur; cur = cur.parent)
|
||||
if (cur.name == "Element")
|
||||
return cur;
|
||||
return null;
|
||||
}
|
||||
function findLocation(state, pos) {
|
||||
var _a;
|
||||
let at = language.syntaxTree(state).resolveInner(pos, -1), inTag = null;
|
||||
for (let cur = at; !inTag && cur.parent; cur = cur.parent)
|
||||
if (cur.name == "OpenTag" || cur.name == "CloseTag" || cur.name == "SelfClosingTag" || cur.name == "MismatchedCloseTag")
|
||||
inTag = cur;
|
||||
if (inTag && (inTag.to > pos || inTag.lastChild.type.isError)) {
|
||||
let elt = inTag.parent;
|
||||
if (at.name == "TagName")
|
||||
return inTag.name == "CloseTag" || inTag.name == "MismatchedCloseTag"
|
||||
? { type: "closeTag", from: at.from, context: elt }
|
||||
: { type: "openTag", from: at.from, context: findParentElement(elt) };
|
||||
if (at.name == "AttributeName")
|
||||
return { type: "attrName", from: at.from, context: inTag };
|
||||
if (at.name == "AttributeValue")
|
||||
return { type: "attrValue", from: at.from, context: inTag };
|
||||
let before = at == inTag || at.name == "Attribute" ? at.childBefore(pos) : at;
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "StartTag")
|
||||
return { type: "openTag", from: pos, context: findParentElement(elt) };
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "StartCloseTag" && before.to <= pos)
|
||||
return { type: "closeTag", from: pos, context: elt };
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "Is")
|
||||
return { type: "attrValue", from: pos, context: inTag };
|
||||
if (before)
|
||||
return { type: "attrName", from: pos, context: inTag };
|
||||
return null;
|
||||
}
|
||||
else if (at.name == "StartCloseTag") {
|
||||
return { type: "closeTag", from: pos, context: at.parent };
|
||||
}
|
||||
while (at.parent && at.to == pos && !((_a = at.lastChild) === null || _a === void 0 ? void 0 : _a.type.isError))
|
||||
at = at.parent;
|
||||
if (at.name == "Element" || at.name == "Text" || at.name == "Document")
|
||||
return { type: "tag", from: pos, context: at.name == "Element" ? at : findParentElement(at) };
|
||||
return null;
|
||||
}
|
||||
class Element {
|
||||
constructor(spec, attrs, attrValues) {
|
||||
this.attrs = attrs;
|
||||
this.attrValues = attrValues;
|
||||
this.children = [];
|
||||
this.name = spec.name;
|
||||
this.completion = Object.assign(Object.assign({ type: "type" }, spec.completion || {}), { label: this.name });
|
||||
this.openCompletion = Object.assign(Object.assign({}, this.completion), { label: "<" + this.name });
|
||||
this.closeCompletion = Object.assign(Object.assign({}, this.completion), { label: "</" + this.name + ">", boost: 2 });
|
||||
this.closeNameCompletion = Object.assign(Object.assign({}, this.completion), { label: this.name + ">" });
|
||||
this.text = spec.textContent ? spec.textContent.map(s => ({ label: s, type: "text" })) : [];
|
||||
}
|
||||
}
|
||||
const Identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
|
||||
function attrCompletion(spec) {
|
||||
return Object.assign(Object.assign({ type: "property" }, spec.completion || {}), { label: spec.name });
|
||||
}
|
||||
function valueCompletion(spec) {
|
||||
return typeof spec == "string" ? { label: `"${spec}"`, type: "constant" }
|
||||
: /^"/.test(spec.label) ? spec
|
||||
: Object.assign(Object.assign({}, spec), { label: `"${spec.label}"` });
|
||||
}
|
||||
/**
|
||||
Create a completion source for the given schema.
|
||||
*/
|
||||
function completeFromSchema(eltSpecs, attrSpecs) {
|
||||
let allAttrs = [], globalAttrs = [];
|
||||
let attrValues = Object.create(null);
|
||||
for (let s of attrSpecs) {
|
||||
let completion = attrCompletion(s);
|
||||
allAttrs.push(completion);
|
||||
if (s.global)
|
||||
globalAttrs.push(completion);
|
||||
if (s.values)
|
||||
attrValues[s.name] = s.values.map(valueCompletion);
|
||||
}
|
||||
let allElements = [], topElements = [];
|
||||
let byName = Object.create(null);
|
||||
for (let s of eltSpecs) {
|
||||
let attrs = globalAttrs, attrVals = attrValues;
|
||||
if (s.attributes)
|
||||
attrs = attrs.concat(s.attributes.map(s => {
|
||||
if (typeof s == "string")
|
||||
return allAttrs.find(a => a.label == s) || { label: s, type: "property" };
|
||||
if (s.values) {
|
||||
if (attrVals == attrValues)
|
||||
attrVals = Object.create(attrVals);
|
||||
attrVals[s.name] = s.values.map(valueCompletion);
|
||||
}
|
||||
return attrCompletion(s);
|
||||
}));
|
||||
let elt = new Element(s, attrs, attrVals);
|
||||
byName[elt.name] = elt;
|
||||
allElements.push(elt);
|
||||
if (s.top)
|
||||
topElements.push(elt);
|
||||
}
|
||||
if (!topElements.length)
|
||||
topElements = allElements;
|
||||
for (let i = 0; i < allElements.length; i++) {
|
||||
let s = eltSpecs[i], elt = allElements[i];
|
||||
if (s.children) {
|
||||
for (let ch of s.children)
|
||||
if (byName[ch])
|
||||
elt.children.push(byName[ch]);
|
||||
}
|
||||
else {
|
||||
elt.children = allElements;
|
||||
}
|
||||
}
|
||||
return cx => {
|
||||
var _a;
|
||||
let { doc } = cx.state, loc = findLocation(cx.state, cx.pos);
|
||||
if (!loc || (loc.type == "tag" && !cx.explicit))
|
||||
return null;
|
||||
let { type, from, context } = loc;
|
||||
if (type == "openTag") {
|
||||
let children = topElements;
|
||||
let parentName = elementName$1(doc, context);
|
||||
if (parentName) {
|
||||
let parent = byName[parentName];
|
||||
children = (parent === null || parent === void 0 ? void 0 : parent.children) || allElements;
|
||||
}
|
||||
return {
|
||||
from,
|
||||
options: children.map(ch => ch.completion),
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
else if (type == "closeTag") {
|
||||
let parentName = elementName$1(doc, context);
|
||||
return parentName ? {
|
||||
from,
|
||||
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == ">" ? 1 : 0),
|
||||
options: [((_a = byName[parentName]) === null || _a === void 0 ? void 0 : _a.closeNameCompletion) || { label: parentName + ">", type: "type" }],
|
||||
validFor: Identifier
|
||||
} : null;
|
||||
}
|
||||
else if (type == "attrName") {
|
||||
let parent = byName[tagName(doc, context)];
|
||||
return {
|
||||
from,
|
||||
options: (parent === null || parent === void 0 ? void 0 : parent.attrs) || globalAttrs,
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
else if (type == "attrValue") {
|
||||
let attr = attrName(doc, context, from);
|
||||
if (!attr)
|
||||
return null;
|
||||
let parent = byName[tagName(doc, context)];
|
||||
let values = ((parent === null || parent === void 0 ? void 0 : parent.attrValues) || attrValues)[attr];
|
||||
if (!values || !values.length)
|
||||
return null;
|
||||
return {
|
||||
from,
|
||||
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == '"' ? 1 : 0),
|
||||
options: values,
|
||||
validFor: /^"[^"]*"?$/
|
||||
};
|
||||
}
|
||||
else if (type == "tag") {
|
||||
let parentName = elementName$1(doc, context), parent = byName[parentName];
|
||||
let closing = [], last = context && context.lastChild;
|
||||
if (parentName && (!last || last.name != "CloseTag" || tagName(doc, last) != parentName))
|
||||
closing.push(parent ? parent.closeCompletion : { label: "</" + parentName + ">", type: "type", boost: 2 });
|
||||
let options = closing.concat(((parent === null || parent === void 0 ? void 0 : parent.children) || (context ? allElements : topElements)).map(e => e.openCompletion));
|
||||
if (context && (parent === null || parent === void 0 ? void 0 : parent.text.length)) {
|
||||
let openTag = context.firstChild;
|
||||
if (openTag.to > cx.pos - 20 && !/\S/.test(cx.state.sliceDoc(openTag.to, cx.pos)))
|
||||
options = options.concat(parent.text);
|
||||
}
|
||||
return {
|
||||
from,
|
||||
options,
|
||||
validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
|
||||
};
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer XML
|
||||
parser](https://github.com/lezer-parser/xml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const xmlLanguage = language.LRLanguage.define({
|
||||
name: "xml",
|
||||
parser: xml$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
Element(context) {
|
||||
let closed = /^\s*<\//.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
"OpenTag CloseTag SelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
}
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
Element(subtree) {
|
||||
let first = subtree.firstChild, last = subtree.lastChild;
|
||||
if (!first || first.name != "OpenTag")
|
||||
return null;
|
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : subtree.to };
|
||||
}
|
||||
}),
|
||||
language.bracketMatchingHandle.add({
|
||||
"OpenTag CloseTag": node => node.getChild("TagName")
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "<!--", close: "-->" } },
|
||||
indentOnInput: /^\s*<\/$/
|
||||
}
|
||||
});
|
||||
/**
|
||||
XML language support. Includes schema-based autocompletion when
|
||||
configured.
|
||||
*/
|
||||
function xml(conf = {}) {
|
||||
let support = [xmlLanguage.data.of({
|
||||
autocomplete: completeFromSchema(conf.elements || [], conf.attributes || [])
|
||||
})];
|
||||
if (conf.autoCloseTags !== false)
|
||||
support.push(autoCloseTags);
|
||||
return new language.LanguageSupport(xmlLanguage, support);
|
||||
}
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
if (!tree)
|
||||
return "";
|
||||
let tag = tree.firstChild;
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : "";
|
||||
}
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = view.EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
|
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") ||
|
||||
!xmlLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = insertTransaction(), { state: state$1 } = base;
|
||||
let closeTags = state$1.changeByRange(range => {
|
||||
var _a, _b, _c;
|
||||
let { head } = range;
|
||||
let didType = state$1.doc.sliceString(head - 1, head) == text;
|
||||
let after = language.syntaxTree(state$1).resolveInner(head, -1), name;
|
||||
if (didType && text == ">" && after.name == "EndTag") {
|
||||
let tag = after.parent;
|
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" &&
|
||||
(name = elementName(state$1.doc, tag.parent, head))) {
|
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `</${name}>`;
|
||||
return { range, changes: { from: head, to, insert } };
|
||||
}
|
||||
}
|
||||
else if (didType && text == "/" && after.name == "StartCloseTag") {
|
||||
let base = after.parent;
|
||||
if (after.from == head - 2 && ((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" &&
|
||||
(name = elementName(state$1.doc, base, head))) {
|
||||
let to = head + (state$1.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `${name}>`;
|
||||
return {
|
||||
range: state.EditorSelection.cursor(head + insert.length, -1),
|
||||
changes: { from: head, to, insert }
|
||||
};
|
||||
}
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state$1.update(closeTags, {
|
||||
userEvent: "input.complete",
|
||||
scrollIntoView: true
|
||||
})
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
exports.autoCloseTags = autoCloseTags;
|
||||
exports.completeFromSchema = completeFromSchema;
|
||||
exports.xml = xml;
|
||||
exports.xmlLanguage = xmlLanguage;
|
||||
104
node_modules/@codemirror/lang-xml/dist/index.d.cts
generated
vendored
Normal file
104
node_modules/@codemirror/lang-xml/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { Completion, CompletionSource } from '@codemirror/autocomplete';
|
||||
|
||||
/**
|
||||
Describes an element in your XML document schema.
|
||||
*/
|
||||
interface ElementSpec {
|
||||
/**
|
||||
The element name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Allowed children in this element. When not given, all elements
|
||||
are allowed inside it.
|
||||
*/
|
||||
children?: readonly string[];
|
||||
/**
|
||||
When given, allows users to complete the given content strings
|
||||
as plain text when at the start of the element.
|
||||
*/
|
||||
textContent?: readonly string[];
|
||||
/**
|
||||
Whether this element may appear at the top of the document.
|
||||
*/
|
||||
top?: boolean;
|
||||
/**
|
||||
Allowed attributes in this element. Strings refer to attributes
|
||||
specified in [`XMLConfig.attrs`](https://codemirror.net/6/docs/ref/#lang-xml.XMLConfig.attrs), but
|
||||
you can also provide one-off [attribute
|
||||
specs](https://codemirror.net/6/docs/ref/#lang-xml.AttrSpec). Attributes marked as
|
||||
[`global`](https://codemirror.net/6/docs/ref/#lang-xml.AttrSpec.global) are allowed in every
|
||||
element, and don't have to be mentioned here.
|
||||
*/
|
||||
attributes?: readonly (string | AttrSpec)[];
|
||||
/**
|
||||
Can be provided to add extra fields to the
|
||||
[completion](https://codemirror.net/6/docs/ref/#autocompletion.Completion) object created for this
|
||||
element.
|
||||
*/
|
||||
completion?: Partial<Completion>;
|
||||
}
|
||||
/**
|
||||
Describes an attribute in your XML schema.
|
||||
*/
|
||||
interface AttrSpec {
|
||||
/**
|
||||
The attribute name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Pre-defined values to complete for this attribute.
|
||||
*/
|
||||
values?: readonly (string | Completion)[];
|
||||
/**
|
||||
When `true`, this attribute can be added to all elements.
|
||||
*/
|
||||
global?: boolean;
|
||||
/**
|
||||
Provides extra fields to the
|
||||
[completion](https://codemirror.net/6/docs/ref/#autocompletion.Completion) object created for this
|
||||
element
|
||||
*/
|
||||
completion?: Partial<Completion>;
|
||||
}
|
||||
/**
|
||||
Create a completion source for the given schema.
|
||||
*/
|
||||
declare function completeFromSchema(eltSpecs: readonly ElementSpec[], attrSpecs: readonly AttrSpec[]): CompletionSource;
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer XML
|
||||
parser](https://github.com/lezer-parser/xml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const xmlLanguage: LRLanguage;
|
||||
type XMLConfig = {
|
||||
/**
|
||||
Provide a schema to create completions from.
|
||||
*/
|
||||
elements?: readonly ElementSpec[];
|
||||
/**
|
||||
Supporting attribute descriptions for the schema specified in
|
||||
[`elements`](https://codemirror.net/6/docs/ref/#lang-xml.xml^conf.elements).
|
||||
*/
|
||||
attributes?: readonly AttrSpec[];
|
||||
/**
|
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-xml.autoCloseTags)
|
||||
is included in the support extensions. Defaults to true.
|
||||
*/
|
||||
autoCloseTags?: boolean;
|
||||
};
|
||||
/**
|
||||
XML language support. Includes schema-based autocompletion when
|
||||
configured.
|
||||
*/
|
||||
declare function xml(conf?: XMLConfig): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
export { type AttrSpec, type ElementSpec, autoCloseTags, completeFromSchema, xml, xmlLanguage };
|
||||
104
node_modules/@codemirror/lang-xml/dist/index.d.ts
generated
vendored
Normal file
104
node_modules/@codemirror/lang-xml/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { LRLanguage, LanguageSupport } from '@codemirror/language';
|
||||
import { Completion, CompletionSource } from '@codemirror/autocomplete';
|
||||
|
||||
/**
|
||||
Describes an element in your XML document schema.
|
||||
*/
|
||||
interface ElementSpec {
|
||||
/**
|
||||
The element name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Allowed children in this element. When not given, all elements
|
||||
are allowed inside it.
|
||||
*/
|
||||
children?: readonly string[];
|
||||
/**
|
||||
When given, allows users to complete the given content strings
|
||||
as plain text when at the start of the element.
|
||||
*/
|
||||
textContent?: readonly string[];
|
||||
/**
|
||||
Whether this element may appear at the top of the document.
|
||||
*/
|
||||
top?: boolean;
|
||||
/**
|
||||
Allowed attributes in this element. Strings refer to attributes
|
||||
specified in [`XMLConfig.attrs`](https://codemirror.net/6/docs/ref/#lang-xml.XMLConfig.attrs), but
|
||||
you can also provide one-off [attribute
|
||||
specs](https://codemirror.net/6/docs/ref/#lang-xml.AttrSpec). Attributes marked as
|
||||
[`global`](https://codemirror.net/6/docs/ref/#lang-xml.AttrSpec.global) are allowed in every
|
||||
element, and don't have to be mentioned here.
|
||||
*/
|
||||
attributes?: readonly (string | AttrSpec)[];
|
||||
/**
|
||||
Can be provided to add extra fields to the
|
||||
[completion](https://codemirror.net/6/docs/ref/#autocompletion.Completion) object created for this
|
||||
element.
|
||||
*/
|
||||
completion?: Partial<Completion>;
|
||||
}
|
||||
/**
|
||||
Describes an attribute in your XML schema.
|
||||
*/
|
||||
interface AttrSpec {
|
||||
/**
|
||||
The attribute name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
Pre-defined values to complete for this attribute.
|
||||
*/
|
||||
values?: readonly (string | Completion)[];
|
||||
/**
|
||||
When `true`, this attribute can be added to all elements.
|
||||
*/
|
||||
global?: boolean;
|
||||
/**
|
||||
Provides extra fields to the
|
||||
[completion](https://codemirror.net/6/docs/ref/#autocompletion.Completion) object created for this
|
||||
element
|
||||
*/
|
||||
completion?: Partial<Completion>;
|
||||
}
|
||||
/**
|
||||
Create a completion source for the given schema.
|
||||
*/
|
||||
declare function completeFromSchema(eltSpecs: readonly ElementSpec[], attrSpecs: readonly AttrSpec[]): CompletionSource;
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer XML
|
||||
parser](https://github.com/lezer-parser/xml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const xmlLanguage: LRLanguage;
|
||||
type XMLConfig = {
|
||||
/**
|
||||
Provide a schema to create completions from.
|
||||
*/
|
||||
elements?: readonly ElementSpec[];
|
||||
/**
|
||||
Supporting attribute descriptions for the schema specified in
|
||||
[`elements`](https://codemirror.net/6/docs/ref/#lang-xml.xml^conf.elements).
|
||||
*/
|
||||
attributes?: readonly AttrSpec[];
|
||||
/**
|
||||
Determines whether [`autoCloseTags`](https://codemirror.net/6/docs/ref/#lang-xml.autoCloseTags)
|
||||
is included in the support extensions. Defaults to true.
|
||||
*/
|
||||
autoCloseTags?: boolean;
|
||||
};
|
||||
/**
|
||||
XML language support. Includes schema-based autocompletion when
|
||||
configured.
|
||||
*/
|
||||
declare function xml(conf?: XMLConfig): LanguageSupport;
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
declare const autoCloseTags: _codemirror_state.Extension;
|
||||
|
||||
export { type AttrSpec, type ElementSpec, autoCloseTags, completeFromSchema, xml, xmlLanguage };
|
||||
309
node_modules/@codemirror/lang-xml/dist/index.js
generated
vendored
Normal file
309
node_modules/@codemirror/lang-xml/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
import { parser } from '@lezer/xml';
|
||||
import { syntaxTree, LRLanguage, indentNodeProp, foldNodeProp, bracketMatchingHandle, LanguageSupport } from '@codemirror/language';
|
||||
import { EditorSelection } from '@codemirror/state';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
|
||||
function tagName(doc, tag) {
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, name.to) : "";
|
||||
}
|
||||
function elementName$1(doc, tree) {
|
||||
let tag = tree && tree.firstChild;
|
||||
return !tag || tag.name != "OpenTag" ? "" : tagName(doc, tag);
|
||||
}
|
||||
function attrName(doc, tag, pos) {
|
||||
let attr = tag && tag.getChildren("Attribute").find(a => a.from <= pos && a.to >= pos);
|
||||
let name = attr && attr.getChild("AttributeName");
|
||||
return name ? doc.sliceString(name.from, name.to) : "";
|
||||
}
|
||||
function findParentElement(tree) {
|
||||
for (let cur = tree && tree.parent; cur; cur = cur.parent)
|
||||
if (cur.name == "Element")
|
||||
return cur;
|
||||
return null;
|
||||
}
|
||||
function findLocation(state, pos) {
|
||||
var _a;
|
||||
let at = syntaxTree(state).resolveInner(pos, -1), inTag = null;
|
||||
for (let cur = at; !inTag && cur.parent; cur = cur.parent)
|
||||
if (cur.name == "OpenTag" || cur.name == "CloseTag" || cur.name == "SelfClosingTag" || cur.name == "MismatchedCloseTag")
|
||||
inTag = cur;
|
||||
if (inTag && (inTag.to > pos || inTag.lastChild.type.isError)) {
|
||||
let elt = inTag.parent;
|
||||
if (at.name == "TagName")
|
||||
return inTag.name == "CloseTag" || inTag.name == "MismatchedCloseTag"
|
||||
? { type: "closeTag", from: at.from, context: elt }
|
||||
: { type: "openTag", from: at.from, context: findParentElement(elt) };
|
||||
if (at.name == "AttributeName")
|
||||
return { type: "attrName", from: at.from, context: inTag };
|
||||
if (at.name == "AttributeValue")
|
||||
return { type: "attrValue", from: at.from, context: inTag };
|
||||
let before = at == inTag || at.name == "Attribute" ? at.childBefore(pos) : at;
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "StartTag")
|
||||
return { type: "openTag", from: pos, context: findParentElement(elt) };
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "StartCloseTag" && before.to <= pos)
|
||||
return { type: "closeTag", from: pos, context: elt };
|
||||
if ((before === null || before === void 0 ? void 0 : before.name) == "Is")
|
||||
return { type: "attrValue", from: pos, context: inTag };
|
||||
if (before)
|
||||
return { type: "attrName", from: pos, context: inTag };
|
||||
return null;
|
||||
}
|
||||
else if (at.name == "StartCloseTag") {
|
||||
return { type: "closeTag", from: pos, context: at.parent };
|
||||
}
|
||||
while (at.parent && at.to == pos && !((_a = at.lastChild) === null || _a === void 0 ? void 0 : _a.type.isError))
|
||||
at = at.parent;
|
||||
if (at.name == "Element" || at.name == "Text" || at.name == "Document")
|
||||
return { type: "tag", from: pos, context: at.name == "Element" ? at : findParentElement(at) };
|
||||
return null;
|
||||
}
|
||||
class Element {
|
||||
constructor(spec, attrs, attrValues) {
|
||||
this.attrs = attrs;
|
||||
this.attrValues = attrValues;
|
||||
this.children = [];
|
||||
this.name = spec.name;
|
||||
this.completion = Object.assign(Object.assign({ type: "type" }, spec.completion || {}), { label: this.name });
|
||||
this.openCompletion = Object.assign(Object.assign({}, this.completion), { label: "<" + this.name });
|
||||
this.closeCompletion = Object.assign(Object.assign({}, this.completion), { label: "</" + this.name + ">", boost: 2 });
|
||||
this.closeNameCompletion = Object.assign(Object.assign({}, this.completion), { label: this.name + ">" });
|
||||
this.text = spec.textContent ? spec.textContent.map(s => ({ label: s, type: "text" })) : [];
|
||||
}
|
||||
}
|
||||
const Identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
|
||||
function attrCompletion(spec) {
|
||||
return Object.assign(Object.assign({ type: "property" }, spec.completion || {}), { label: spec.name });
|
||||
}
|
||||
function valueCompletion(spec) {
|
||||
return typeof spec == "string" ? { label: `"${spec}"`, type: "constant" }
|
||||
: /^"/.test(spec.label) ? spec
|
||||
: Object.assign(Object.assign({}, spec), { label: `"${spec.label}"` });
|
||||
}
|
||||
/**
|
||||
Create a completion source for the given schema.
|
||||
*/
|
||||
function completeFromSchema(eltSpecs, attrSpecs) {
|
||||
let allAttrs = [], globalAttrs = [];
|
||||
let attrValues = Object.create(null);
|
||||
for (let s of attrSpecs) {
|
||||
let completion = attrCompletion(s);
|
||||
allAttrs.push(completion);
|
||||
if (s.global)
|
||||
globalAttrs.push(completion);
|
||||
if (s.values)
|
||||
attrValues[s.name] = s.values.map(valueCompletion);
|
||||
}
|
||||
let allElements = [], topElements = [];
|
||||
let byName = Object.create(null);
|
||||
for (let s of eltSpecs) {
|
||||
let attrs = globalAttrs, attrVals = attrValues;
|
||||
if (s.attributes)
|
||||
attrs = attrs.concat(s.attributes.map(s => {
|
||||
if (typeof s == "string")
|
||||
return allAttrs.find(a => a.label == s) || { label: s, type: "property" };
|
||||
if (s.values) {
|
||||
if (attrVals == attrValues)
|
||||
attrVals = Object.create(attrVals);
|
||||
attrVals[s.name] = s.values.map(valueCompletion);
|
||||
}
|
||||
return attrCompletion(s);
|
||||
}));
|
||||
let elt = new Element(s, attrs, attrVals);
|
||||
byName[elt.name] = elt;
|
||||
allElements.push(elt);
|
||||
if (s.top)
|
||||
topElements.push(elt);
|
||||
}
|
||||
if (!topElements.length)
|
||||
topElements = allElements;
|
||||
for (let i = 0; i < allElements.length; i++) {
|
||||
let s = eltSpecs[i], elt = allElements[i];
|
||||
if (s.children) {
|
||||
for (let ch of s.children)
|
||||
if (byName[ch])
|
||||
elt.children.push(byName[ch]);
|
||||
}
|
||||
else {
|
||||
elt.children = allElements;
|
||||
}
|
||||
}
|
||||
return cx => {
|
||||
var _a;
|
||||
let { doc } = cx.state, loc = findLocation(cx.state, cx.pos);
|
||||
if (!loc || (loc.type == "tag" && !cx.explicit))
|
||||
return null;
|
||||
let { type, from, context } = loc;
|
||||
if (type == "openTag") {
|
||||
let children = topElements;
|
||||
let parentName = elementName$1(doc, context);
|
||||
if (parentName) {
|
||||
let parent = byName[parentName];
|
||||
children = (parent === null || parent === void 0 ? void 0 : parent.children) || allElements;
|
||||
}
|
||||
return {
|
||||
from,
|
||||
options: children.map(ch => ch.completion),
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
else if (type == "closeTag") {
|
||||
let parentName = elementName$1(doc, context);
|
||||
return parentName ? {
|
||||
from,
|
||||
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == ">" ? 1 : 0),
|
||||
options: [((_a = byName[parentName]) === null || _a === void 0 ? void 0 : _a.closeNameCompletion) || { label: parentName + ">", type: "type" }],
|
||||
validFor: Identifier
|
||||
} : null;
|
||||
}
|
||||
else if (type == "attrName") {
|
||||
let parent = byName[tagName(doc, context)];
|
||||
return {
|
||||
from,
|
||||
options: (parent === null || parent === void 0 ? void 0 : parent.attrs) || globalAttrs,
|
||||
validFor: Identifier
|
||||
};
|
||||
}
|
||||
else if (type == "attrValue") {
|
||||
let attr = attrName(doc, context, from);
|
||||
if (!attr)
|
||||
return null;
|
||||
let parent = byName[tagName(doc, context)];
|
||||
let values = ((parent === null || parent === void 0 ? void 0 : parent.attrValues) || attrValues)[attr];
|
||||
if (!values || !values.length)
|
||||
return null;
|
||||
return {
|
||||
from,
|
||||
to: cx.pos + (doc.sliceString(cx.pos, cx.pos + 1) == '"' ? 1 : 0),
|
||||
options: values,
|
||||
validFor: /^"[^"]*"?$/
|
||||
};
|
||||
}
|
||||
else if (type == "tag") {
|
||||
let parentName = elementName$1(doc, context), parent = byName[parentName];
|
||||
let closing = [], last = context && context.lastChild;
|
||||
if (parentName && (!last || last.name != "CloseTag" || tagName(doc, last) != parentName))
|
||||
closing.push(parent ? parent.closeCompletion : { label: "</" + parentName + ">", type: "type", boost: 2 });
|
||||
let options = closing.concat(((parent === null || parent === void 0 ? void 0 : parent.children) || (context ? allElements : topElements)).map(e => e.openCompletion));
|
||||
if (context && (parent === null || parent === void 0 ? void 0 : parent.text.length)) {
|
||||
let openTag = context.firstChild;
|
||||
if (openTag.to > cx.pos - 20 && !/\S/.test(cx.state.sliceDoc(openTag.to, cx.pos)))
|
||||
options = options.concat(parent.text);
|
||||
}
|
||||
return {
|
||||
from,
|
||||
options,
|
||||
validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
|
||||
};
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer XML
|
||||
parser](https://github.com/lezer-parser/xml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const xmlLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "xml",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
Element(context) {
|
||||
let closed = /^\s*<\//.test(context.textAfter);
|
||||
return context.lineIndent(context.node.from) + (closed ? 0 : context.unit);
|
||||
},
|
||||
"OpenTag CloseTag SelfClosingTag"(context) {
|
||||
return context.column(context.node.from) + context.unit;
|
||||
}
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
Element(subtree) {
|
||||
let first = subtree.firstChild, last = subtree.lastChild;
|
||||
if (!first || first.name != "OpenTag")
|
||||
return null;
|
||||
return { from: first.to, to: last.name == "CloseTag" ? last.from : subtree.to };
|
||||
}
|
||||
}),
|
||||
/*@__PURE__*/bracketMatchingHandle.add({
|
||||
"OpenTag CloseTag": node => node.getChild("TagName")
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { block: { open: "<!--", close: "-->" } },
|
||||
indentOnInput: /^\s*<\/$/
|
||||
}
|
||||
});
|
||||
/**
|
||||
XML language support. Includes schema-based autocompletion when
|
||||
configured.
|
||||
*/
|
||||
function xml(conf = {}) {
|
||||
let support = [xmlLanguage.data.of({
|
||||
autocomplete: completeFromSchema(conf.elements || [], conf.attributes || [])
|
||||
})];
|
||||
if (conf.autoCloseTags !== false)
|
||||
support.push(autoCloseTags);
|
||||
return new LanguageSupport(xmlLanguage, support);
|
||||
}
|
||||
function elementName(doc, tree, max = doc.length) {
|
||||
if (!tree)
|
||||
return "";
|
||||
let tag = tree.firstChild;
|
||||
let name = tag && tag.getChild("TagName");
|
||||
return name ? doc.sliceString(name.from, Math.min(name.to, max)) : "";
|
||||
}
|
||||
/**
|
||||
Extension that will automatically insert close tags when a `>` or
|
||||
`/` is typed.
|
||||
*/
|
||||
const autoCloseTags = /*@__PURE__*/EditorView.inputHandler.of((view, from, to, text, insertTransaction) => {
|
||||
if (view.composing || view.state.readOnly || from != to || (text != ">" && text != "/") ||
|
||||
!xmlLanguage.isActiveAt(view.state, from, -1))
|
||||
return false;
|
||||
let base = insertTransaction(), { state } = base;
|
||||
let closeTags = state.changeByRange(range => {
|
||||
var _a, _b, _c;
|
||||
let { head } = range;
|
||||
let didType = state.doc.sliceString(head - 1, head) == text;
|
||||
let after = syntaxTree(state).resolveInner(head, -1), name;
|
||||
if (didType && text == ">" && after.name == "EndTag") {
|
||||
let tag = after.parent;
|
||||
if (((_b = (_a = tag.parent) === null || _a === void 0 ? void 0 : _a.lastChild) === null || _b === void 0 ? void 0 : _b.name) != "CloseTag" &&
|
||||
(name = elementName(state.doc, tag.parent, head))) {
|
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `</${name}>`;
|
||||
return { range, changes: { from: head, to, insert } };
|
||||
}
|
||||
}
|
||||
else if (didType && text == "/" && after.name == "StartCloseTag") {
|
||||
let base = after.parent;
|
||||
if (after.from == head - 2 && ((_c = base.lastChild) === null || _c === void 0 ? void 0 : _c.name) != "CloseTag" &&
|
||||
(name = elementName(state.doc, base, head))) {
|
||||
let to = head + (state.doc.sliceString(head, head + 1) === ">" ? 1 : 0);
|
||||
let insert = `${name}>`;
|
||||
return {
|
||||
range: EditorSelection.cursor(head + insert.length, -1),
|
||||
changes: { from: head, to, insert }
|
||||
};
|
||||
}
|
||||
}
|
||||
return { range };
|
||||
});
|
||||
if (closeTags.changes.empty)
|
||||
return false;
|
||||
view.dispatch([
|
||||
base,
|
||||
state.update(closeTags, {
|
||||
userEvent: "input.complete",
|
||||
scrollIntoView: true
|
||||
})
|
||||
]);
|
||||
return true;
|
||||
});
|
||||
|
||||
export { autoCloseTags, completeFromSchema, xml, xmlLanguage };
|
||||
43
node_modules/@codemirror/lang-xml/package.json
generated
vendored
Normal file
43
node_modules/@codemirror/lang-xml/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@codemirror/lang-xml",
|
||||
"version": "6.1.0",
|
||||
"description": "XML language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/xml.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.4.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/xml": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lang-xml.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lang-yaml/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lang-yaml/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
25
node_modules/@codemirror/lang-yaml/CHANGELOG.md
generated
vendored
Normal file
25
node_modules/@codemirror/lang-yaml/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
## 6.1.2 (2024-12-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
List `@lezer/lr` as a direct dependency for tools that require this.
|
||||
|
||||
Make block sequence items, rather than the whole sequence, fold targets.
|
||||
|
||||
## 6.1.1 (2024-04-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make block mapping entries, rather than the entire mapping, foldable.
|
||||
|
||||
## 6.1.0 (2024-04-07)
|
||||
|
||||
### New features
|
||||
|
||||
`yamlFrontmatter` can now be used to wrap a language with a YAML frontmatter.
|
||||
|
||||
## 6.0.0 (2024-01-22)
|
||||
|
||||
### New Features
|
||||
|
||||
First versioned release.
|
||||
21
node_modules/@codemirror/lang-yaml/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lang-yaml/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2024 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
46
node_modules/@codemirror/lang-yaml/README.md
generated
vendored
Normal file
46
node_modules/@codemirror/lang-yaml/README.md
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<!-- NOTE: README.md is generated from src/README.md -->
|
||||
|
||||
# @codemirror/lang-yaml [](https://www.npmjs.org/package/@codemirror/lang-yaml)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-yaml/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements YAML language support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lang-yaml/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
The initial implementation of this package was funded by [Braintrust Data](https://braintrustdata.com/).
|
||||
|
||||
## API Reference
|
||||
|
||||
<dl>
|
||||
<dt id="user-content-yaml">
|
||||
<code><strong><a href="#user-content-yaml">yaml</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>Language support for YAML.</p>
|
||||
</dd>
|
||||
<dt id="user-content-yamllanguage">
|
||||
<code><strong><a href="#user-content-yamllanguage">yamlLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
||||
|
||||
<dd><p>A language provider based on the <a href="https://github.com/lezer-parser/yaml">Lezer YAML
|
||||
parser</a>, extended with
|
||||
highlighting and indentation information.</p>
|
||||
</dd>
|
||||
<dt id="user-content-yamlfrontmatter">
|
||||
<code><strong><a href="#user-content-yamlfrontmatter">yamlFrontmatter</a></strong>(<a id="user-content-yamlfrontmatter^config" href="#user-content-yamlfrontmatter^config">config</a>: {content: <a href="https://codemirror.net/docs/ref#language.Language">Language</a> | <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a>}) → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
||||
|
||||
<dd><p>Returns language support for a document parsed as <code>config.content</code>
|
||||
with an optional YAML "frontmatter" delimited by lines that
|
||||
contain three dashes.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
100
node_modules/@codemirror/lang-yaml/dist/index.cjs
generated
vendored
Normal file
100
node_modules/@codemirror/lang-yaml/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
var yaml$1 = require('@lezer/yaml');
|
||||
var language = require('@codemirror/language');
|
||||
var common = require('@lezer/common');
|
||||
var highlight = require('@lezer/highlight');
|
||||
var lr = require('@lezer/lr');
|
||||
|
||||
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||||
const parser = lr.LRParser.deserialize({
|
||||
version: 14,
|
||||
states: "!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",
|
||||
stateData: "!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",
|
||||
goto: "vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",
|
||||
nodeNames: "⚠ Document Frontmatter DashLine FrontmatterContent Body",
|
||||
maxTerm: 10,
|
||||
skippedNodes: [0],
|
||||
repeatNodeCount: 2,
|
||||
tokenData: "$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",
|
||||
tokenizers: [0],
|
||||
topRules: {"Document":[0,1]},
|
||||
tokenPrec: 67
|
||||
});
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer YAML
|
||||
parser](https://github.com/lezer-parser/yaml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const yamlLanguage = language.LRLanguage.define({
|
||||
name: "yaml",
|
||||
parser: yaml$1.parser.configure({
|
||||
props: [
|
||||
language.indentNodeProp.add({
|
||||
Stream: cx => {
|
||||
for (let before = cx.node.resolve(cx.pos, -1); before && before.to >= cx.pos; before = before.parent) {
|
||||
if (before.name == "BlockLiteralContent" && before.from < before.to)
|
||||
return cx.baseIndentFor(before);
|
||||
if (before.name == "BlockLiteral")
|
||||
return cx.baseIndentFor(before) + cx.unit;
|
||||
if (before.name == "BlockSequence" || before.name == "BlockMapping")
|
||||
return cx.column(before.from, 1);
|
||||
if (before.name == "QuotedLiteral")
|
||||
return null;
|
||||
if (before.name == "Literal") {
|
||||
let col = cx.column(before.from, 1);
|
||||
if (col == cx.lineIndent(before.from, 1))
|
||||
return col; // Start on own line
|
||||
if (before.to > cx.pos)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
FlowMapping: language.delimitedIndent({ closing: "}" }),
|
||||
FlowSequence: language.delimitedIndent({ closing: "]" }),
|
||||
}),
|
||||
language.foldNodeProp.add({
|
||||
"FlowMapping FlowSequence": language.foldInside,
|
||||
"Item Pair BlockLiteral": (node, state) => ({ from: state.doc.lineAt(node.from).to, to: node.to })
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { line: "#" },
|
||||
indentOnInput: /^\s*[\]\}]$/,
|
||||
}
|
||||
});
|
||||
/**
|
||||
Language support for YAML.
|
||||
*/
|
||||
function yaml() {
|
||||
return new language.LanguageSupport(yamlLanguage);
|
||||
}
|
||||
const frontmatterLanguage = language.LRLanguage.define({
|
||||
name: "yaml-frontmatter",
|
||||
parser: parser.configure({
|
||||
props: [highlight.styleTags({ DashLine: highlight.tags.meta })]
|
||||
})
|
||||
});
|
||||
/**
|
||||
Returns language support for a document parsed as `config.content`
|
||||
with an optional YAML "frontmatter" delimited by lines that
|
||||
contain three dashes.
|
||||
*/
|
||||
function yamlFrontmatter(config) {
|
||||
let { language: language$1, support } = config.content instanceof language.LanguageSupport ? config.content
|
||||
: { language: config.content, support: [] };
|
||||
return new language.LanguageSupport(frontmatterLanguage.configure({
|
||||
wrap: common.parseMixed(node => {
|
||||
return node.name == "FrontmatterContent" ? { parser: yamlLanguage.parser }
|
||||
: node.name == "Body" ? { parser: language$1.parser }
|
||||
: null;
|
||||
})
|
||||
}), support);
|
||||
}
|
||||
|
||||
exports.yaml = yaml;
|
||||
exports.yamlFrontmatter = yamlFrontmatter;
|
||||
exports.yamlLanguage = yamlLanguage;
|
||||
22
node_modules/@codemirror/lang-yaml/dist/index.d.cts
generated
vendored
Normal file
22
node_modules/@codemirror/lang-yaml/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { LRLanguage, LanguageSupport, Language } from '@codemirror/language';
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer YAML
|
||||
parser](https://github.com/lezer-parser/yaml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const yamlLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for YAML.
|
||||
*/
|
||||
declare function yaml(): LanguageSupport;
|
||||
/**
|
||||
Returns language support for a document parsed as `config.content`
|
||||
with an optional YAML "frontmatter" delimited by lines that
|
||||
contain three dashes.
|
||||
*/
|
||||
declare function yamlFrontmatter(config: {
|
||||
content: Language | LanguageSupport;
|
||||
}): LanguageSupport;
|
||||
|
||||
export { yaml, yamlFrontmatter, yamlLanguage };
|
||||
22
node_modules/@codemirror/lang-yaml/dist/index.d.ts
generated
vendored
Normal file
22
node_modules/@codemirror/lang-yaml/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { LRLanguage, LanguageSupport, Language } from '@codemirror/language';
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer YAML
|
||||
parser](https://github.com/lezer-parser/yaml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
declare const yamlLanguage: LRLanguage;
|
||||
/**
|
||||
Language support for YAML.
|
||||
*/
|
||||
declare function yaml(): LanguageSupport;
|
||||
/**
|
||||
Returns language support for a document parsed as `config.content`
|
||||
with an optional YAML "frontmatter" delimited by lines that
|
||||
contain three dashes.
|
||||
*/
|
||||
declare function yamlFrontmatter(config: {
|
||||
content: Language | LanguageSupport;
|
||||
}): LanguageSupport;
|
||||
|
||||
export { yaml, yamlFrontmatter, yamlLanguage };
|
||||
96
node_modules/@codemirror/lang-yaml/dist/index.js
generated
vendored
Normal file
96
node_modules/@codemirror/lang-yaml/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
import { parser as parser$1 } from '@lezer/yaml';
|
||||
import { LRLanguage, indentNodeProp, delimitedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
|
||||
import { parseMixed } from '@lezer/common';
|
||||
import { styleTags, tags } from '@lezer/highlight';
|
||||
import { LRParser } from '@lezer/lr';
|
||||
|
||||
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||||
const parser = /*@__PURE__*/LRParser.deserialize({
|
||||
version: 14,
|
||||
states: "!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",
|
||||
stateData: "!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",
|
||||
goto: "vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",
|
||||
nodeNames: "⚠ Document Frontmatter DashLine FrontmatterContent Body",
|
||||
maxTerm: 10,
|
||||
skippedNodes: [0],
|
||||
repeatNodeCount: 2,
|
||||
tokenData: "$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",
|
||||
tokenizers: [0],
|
||||
topRules: {"Document":[0,1]},
|
||||
tokenPrec: 67
|
||||
});
|
||||
|
||||
/**
|
||||
A language provider based on the [Lezer YAML
|
||||
parser](https://github.com/lezer-parser/yaml), extended with
|
||||
highlighting and indentation information.
|
||||
*/
|
||||
const yamlLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "yaml",
|
||||
parser: /*@__PURE__*/parser$1.configure({
|
||||
props: [
|
||||
/*@__PURE__*/indentNodeProp.add({
|
||||
Stream: cx => {
|
||||
for (let before = cx.node.resolve(cx.pos, -1); before && before.to >= cx.pos; before = before.parent) {
|
||||
if (before.name == "BlockLiteralContent" && before.from < before.to)
|
||||
return cx.baseIndentFor(before);
|
||||
if (before.name == "BlockLiteral")
|
||||
return cx.baseIndentFor(before) + cx.unit;
|
||||
if (before.name == "BlockSequence" || before.name == "BlockMapping")
|
||||
return cx.column(before.from, 1);
|
||||
if (before.name == "QuotedLiteral")
|
||||
return null;
|
||||
if (before.name == "Literal") {
|
||||
let col = cx.column(before.from, 1);
|
||||
if (col == cx.lineIndent(before.from, 1))
|
||||
return col; // Start on own line
|
||||
if (before.to > cx.pos)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
FlowMapping: /*@__PURE__*/delimitedIndent({ closing: "}" }),
|
||||
FlowSequence: /*@__PURE__*/delimitedIndent({ closing: "]" }),
|
||||
}),
|
||||
/*@__PURE__*/foldNodeProp.add({
|
||||
"FlowMapping FlowSequence": foldInside,
|
||||
"Item Pair BlockLiteral": (node, state) => ({ from: state.doc.lineAt(node.from).to, to: node.to })
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
commentTokens: { line: "#" },
|
||||
indentOnInput: /^\s*[\]\}]$/,
|
||||
}
|
||||
});
|
||||
/**
|
||||
Language support for YAML.
|
||||
*/
|
||||
function yaml() {
|
||||
return new LanguageSupport(yamlLanguage);
|
||||
}
|
||||
const frontmatterLanguage = /*@__PURE__*/LRLanguage.define({
|
||||
name: "yaml-frontmatter",
|
||||
parser: /*@__PURE__*/parser.configure({
|
||||
props: [/*@__PURE__*/styleTags({ DashLine: tags.meta })]
|
||||
})
|
||||
});
|
||||
/**
|
||||
Returns language support for a document parsed as `config.content`
|
||||
with an optional YAML "frontmatter" delimited by lines that
|
||||
contain three dashes.
|
||||
*/
|
||||
function yamlFrontmatter(config) {
|
||||
let { language, support } = config.content instanceof LanguageSupport ? config.content
|
||||
: { language: config.content, support: [] };
|
||||
return new LanguageSupport(frontmatterLanguage.configure({
|
||||
wrap: parseMixed(node => {
|
||||
return node.name == "FrontmatterContent" ? { parser: yamlLanguage.parser }
|
||||
: node.name == "Body" ? { parser: language.parser }
|
||||
: null;
|
||||
})
|
||||
}), support);
|
||||
}
|
||||
|
||||
export { yaml, yamlFrontmatter, yamlLanguage };
|
||||
44
node_modules/@codemirror/lang-yaml/package.json
generated
vendored
Normal file
44
node_modules/@codemirror/lang-yaml/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@codemirror/lang-yaml",
|
||||
"version": "6.1.2",
|
||||
"description": "YAML language support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/yaml.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.2.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"@lezer/yaml": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/codemirror/lang-yaml.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/language/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/language/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
374
node_modules/@codemirror/language/CHANGELOG.md
generated
vendored
Normal file
374
node_modules/@codemirror/language/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,374 @@
|
||||
## 6.11.0 (2025-03-13)
|
||||
|
||||
### New features
|
||||
|
||||
Stream parsers now support a `mergeTokens` option that can be used to turn off automatic merging of adjacent tokens.
|
||||
|
||||
## 6.10.8 (2024-12-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression introduced 6.10.7 that caused indention to sometimes crash on nested language boundaries.
|
||||
|
||||
## 6.10.7 (2024-12-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where indentation for a stream language would fail to work when the parse covered only part of the document, far from the start.
|
||||
|
||||
Make sure the inner mode gets a chance to indent when indenting right at the end of a nested language section.
|
||||
|
||||
## 6.10.6 (2024-11-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash in `StreamLanguage` when the input range is entirely before the editor viewport.
|
||||
|
||||
## 6.10.5 (2024-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where a `StreamLanguage` could get confused when trying to reuse existing parse data when the parsed range changed.
|
||||
|
||||
## 6.10.4 (2024-11-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Join adjacent tokens of the same type into a single token in .
|
||||
|
||||
Call stream language indent functions even when the language is used as a nested parser.
|
||||
|
||||
Fix a crash in `StreamParser` when a parse was resumed with different input ranges.
|
||||
|
||||
## 6.10.3 (2024-09-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a TypeScript error when using `HighlightStyle` with the `exactOptionalPropertyTypes` typechecking option enabled.
|
||||
|
||||
Make `delimitedIndent` align to spaces after the opening token.
|
||||
|
||||
## 6.10.2 (2024-06-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an infinite loop that could occur when enabling `bidiIsolates` in documents with both bidirectional text and very long lines.
|
||||
|
||||
## 6.10.1 (2024-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where, when a lot of code is visible in the initial editor, the bottom bit of code is shown without highlighting for one frame.
|
||||
|
||||
## 6.10.0 (2023-12-28)
|
||||
|
||||
### New features
|
||||
|
||||
The new `bidiIsolates` extension can be used to wrap syntactic elements where this is appropriate in an element that isolates their text direction, avoiding weird ordering of neutral characters on direction boundaries.
|
||||
|
||||
## 6.9.3 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue in `StreamLanguage` where it ran out of node type ids if you repeatedly redefined a language with the same token table.
|
||||
|
||||
## 6.9.2 (2023-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow `StreamParser` tokens get multiple highlighting tags.
|
||||
|
||||
## 6.9.1 (2023-09-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Indentation now works a lot better in mixed-language documents that interleave the languages in a complex way.
|
||||
|
||||
Code folding is now able to pick the right foldable syntax node when the line end falls in a mixed-parsing language that doesn't match the target node.
|
||||
|
||||
## 6.9.0 (2023-08-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `getIndentation` return null, rather than 0, when there is no syntax tree available.
|
||||
|
||||
### New features
|
||||
|
||||
The new `preparePlaceholder` option to `codeFolding` makes it possible to display contextual information in a folded range placeholder widget.
|
||||
|
||||
## 6.8.0 (2023-06-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `baseIndentFor` method in `TreeIndentContext` can be used to find the base indentation for an arbitrary node.
|
||||
|
||||
## 6.7.0 (2023-05-19)
|
||||
|
||||
### New features
|
||||
|
||||
Export `DocInput` class for feeding editor documents to a Lezer parser.
|
||||
|
||||
## 6.6.0 (2023-02-13)
|
||||
|
||||
### New features
|
||||
|
||||
Syntax-driven language data queries now support sublanguages, which make it possible to return different data for specific parts of the tree produced by a single language.
|
||||
|
||||
## 6.5.0 (2023-02-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make indentation for stream languages more reliable by having `StringStream.indentation` return overridden indentations from the indent context.
|
||||
|
||||
### New features
|
||||
|
||||
The `toggleFold` command folds or unfolds depending on whether there's an existing folded range on the current line.
|
||||
|
||||
`indentUnit` now accepts any (repeated) whitespace character, not just spaces and tabs.
|
||||
|
||||
## 6.4.0 (2023-01-12)
|
||||
|
||||
### New features
|
||||
|
||||
The `bracketMatchingHandle` node prop can now be used to limit bracket matching behavior for larger nodes to a single subnode (for example the tag name of an HTML tag).
|
||||
|
||||
## 6.3.2 (2022-12-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `ensureSyntaxTree` to return incomplete trees when using a viewport-aware parser like `StreamLanguage`.
|
||||
|
||||
## 6.3.1 (2022-11-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make syntax-based folding include syntax nodes that start right at the end of a line as potential fold targets.
|
||||
|
||||
Fix the `indentService` protocol to allow a distinction between declining to handle the indentation and returning null to indicate the line has no definite indentation.
|
||||
|
||||
## 6.3.0 (2022-10-24)
|
||||
|
||||
### New features
|
||||
|
||||
`HighlightStyle` objects now have a `specs` property holding the tag styles that were used to define them.
|
||||
|
||||
`Language` objects now have a `name` field holding the language name.
|
||||
|
||||
## 6.2.1 (2022-07-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `bracketMatching` would incorrectly match nested brackets in syntax trees that put multiple pairs of brackets in the same parent node.
|
||||
|
||||
Fix a bug that could cause `indentRange` to loop infinitely.
|
||||
|
||||
## 6.2.0 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that prevented bracket matching to recognize plain brackets inside a language parsed as an overlay.
|
||||
|
||||
### New features
|
||||
|
||||
The `indentRange` function provides an easy way to programatically auto-indent a range of the document.
|
||||
|
||||
## 6.1.0 (2022-06-20)
|
||||
|
||||
### New features
|
||||
|
||||
The `foldState` field is now public, and can be used to serialize and deserialize the fold state.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### New features
|
||||
|
||||
The `foldingChanged` option to `foldGutter` can now be used to trigger a recomputation of the fold markers.
|
||||
|
||||
## 0.20.2 (2022-05-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
List style-mod as a dependency.
|
||||
|
||||
## 0.20.1 (2022-05-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure `all` styles in the CSS generated for a `HighlightStyle` have a lower precedence than the other rules defined for the style. Use a shorthand property
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`HighlightStyle.get` is now called `highlightingFor`.
|
||||
|
||||
`HighlightStyles` no longer function as extensions (to improve tree shaking), and must be wrapped with `syntaxHighlighting` to add to an editor configuration.
|
||||
|
||||
`Language` objects no longer have a `topNode` property.
|
||||
|
||||
### New features
|
||||
|
||||
`HighlightStyle` and `defaultHighlightStyle` from the now-removed @codemirror/highlight package now live in this package.
|
||||
|
||||
The new `forceParsing` function can be used to run the parser forward on an editor view.
|
||||
|
||||
The exports that used to live in @codemirror/matchbrackets are now exported from this package.
|
||||
|
||||
The @codemirror/fold package has been merged into this one.
|
||||
|
||||
The exports from the old @codemirror/stream-parser package now live in this package.
|
||||
|
||||
## 0.19.10 (2022-03-31)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Autocompletion may now also trigger automatic indentation on input.
|
||||
|
||||
## 0.19.9 (2022-03-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure nodes that end at the end of a partial parse aren't treated as valid fold targets.
|
||||
|
||||
Fix an issue where the parser sometimes wouldn't reuse parsing work done in the background on transactions.
|
||||
|
||||
## 0.19.8 (2022-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that could cause indentation logic to use the wrong line content when indenting multiple lines at once.
|
||||
|
||||
## 0.19.7 (2021-12-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the parse worker could incorrectly stop working when the parse tree has skipped gaps in it.
|
||||
|
||||
## 0.19.6 (2021-11-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fixes an issue where the background parse work would be scheduled too aggressively, degrading responsiveness on a newly-created editor with a large document.
|
||||
|
||||
Improve initial highlight for mixed-language editors and limit the amount of parsing done on state creation for faster startup.
|
||||
|
||||
## 0.19.5 (2021-11-17)
|
||||
|
||||
### New features
|
||||
|
||||
The new function `syntaxTreeAvailable` can be used to check if a fully-parsed syntax tree is available up to a given document position.
|
||||
|
||||
The module now exports `syntaxParserRunning`, which tells you whether the background parser is still planning to do more work for a given editor view.
|
||||
|
||||
## 0.19.4 (2021-11-13)
|
||||
|
||||
### New features
|
||||
|
||||
`LanguageDescription.of` now takes an optional already-loaded extension.
|
||||
|
||||
## 0.19.3 (2021-09-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where a parse that skipped content with `skipUntilInView` would in some cases not be restarted when the range came into view.
|
||||
|
||||
## 0.19.2 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `indentOnInput` to fire for the wrong kinds of transactions.
|
||||
|
||||
Fix a bug that could cause `indentOnInput` to apply its changes incorrectly.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect versions for @lezer dependencies.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
CodeMirror now uses lezer 0.15, which means different package names (scoped with @lezer) and some breaking changes in the library.
|
||||
|
||||
`EditorParseContext` is now called `ParseContext`. It is no longer passed to parsers, but must be retrieved with `ParseContext.get`.
|
||||
|
||||
`IndentContext.lineIndent` now takes a position, not a `Line` object, as argument.
|
||||
|
||||
`LezerLanguage` was renamed to `LRLanguage` (because all languages must emit Lezer-style trees, the name was misleading).
|
||||
|
||||
`Language.parseString` no longer exists. You can just call `.parser.parse(...)` instead.
|
||||
|
||||
### New features
|
||||
|
||||
New `IndentContext.lineAt` method to access lines in a way that is aware of simulated line breaks.
|
||||
|
||||
`IndentContext` now provides a `simulatedBreak` property through which client code can query whether the context has a simulated line break.
|
||||
|
||||
## 0.18.2 (2021-06-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where asynchronous re-parsing (with dynamically loaded languages) sometimes failed to fully happen.
|
||||
|
||||
## 0.18.1 (2021-03-31)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`EditorParseContext.getSkippingParser` now replaces `EditorParseContext.skippingParser` and allows you to provide a promise that'll cause parsing to start again. (The old property remains available until the next major release.)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where nested parsers could see past the end of the nested region.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The `Language` constructor takes an additional argument that provides the top node type.
|
||||
|
||||
### New features
|
||||
|
||||
`Language` instances now have a `topNode` property giving their top node type.
|
||||
|
||||
`TreeIndentContext` now has a `continue` method that allows an indenter to defer to the indentation of the parent nodes.
|
||||
|
||||
## 0.17.5 (2021-02-19)
|
||||
|
||||
### New features
|
||||
|
||||
This package now exports a `foldInside` helper function, a fold function that should work for most delimited node types.
|
||||
|
||||
## 0.17.4 (2021-01-15)
|
||||
|
||||
## 0.17.3 (2021-01-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Parse scheduling has been improved to reduce the likelyhood of the user looking at unparsed code in big documents.
|
||||
|
||||
Prevent parser from running too far past the current viewport in huge documents.
|
||||
|
||||
## 0.17.2 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.1 (2020-12-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where changing the editor configuration wouldn't update the language parser used.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/language/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/language/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
66
node_modules/@codemirror/language/README.md
generated
vendored
Normal file
66
node_modules/@codemirror/language/README.md
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
# @codemirror/language [](https://www.npmjs.org/package/@codemirror/language)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#language) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/language/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the language support infrastructure for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/language/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
|
||||
## Usage
|
||||
|
||||
Setting up a language from a [Lezer](https://lezer.codemirror.net)
|
||||
parser looks like this:
|
||||
|
||||
```javascript
|
||||
import {parser} from "@lezer/json"
|
||||
import {LRLanguage, continuedIndent, indentNodeProp,
|
||||
foldNodeProp, foldInside} from "@codemirror/language"
|
||||
|
||||
export const jsonLanguage = LRLanguage.define({
|
||||
name: "json",
|
||||
parser: parser.configure({
|
||||
props: [
|
||||
indentNodeProp.add({
|
||||
Object: continuedIndent({except: /^\s*\}/}),
|
||||
Array: continuedIndent({except: /^\s*\]/})
|
||||
}),
|
||||
foldNodeProp.add({
|
||||
"Object Array": foldInside
|
||||
})
|
||||
]
|
||||
}),
|
||||
languageData: {
|
||||
closeBrackets: {brackets: ["[", "{", '"']},
|
||||
indentOnInput: /^\s*[\}\]]$/
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
Often, you'll also use this package just to access some specific
|
||||
language-related features, such as accessing the editor's syntax
|
||||
tree...
|
||||
|
||||
```javascript
|
||||
import {syntaxTree} from "@codemirror/language"
|
||||
|
||||
const tree = syntaxTree(view)
|
||||
```
|
||||
|
||||
... or computing the appriate indentation at a given point.
|
||||
|
||||
```javascript
|
||||
import {getIndentation} from "@codemirror/language"
|
||||
|
||||
console.log(getIndentation(view.state, view.state.selection.main.head))
|
||||
```
|
||||
2719
node_modules/@codemirror/language/dist/index.cjs
generated
vendored
Normal file
2719
node_modules/@codemirror/language/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1220
node_modules/@codemirror/language/dist/index.d.cts
generated
vendored
Normal file
1220
node_modules/@codemirror/language/dist/index.d.cts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1220
node_modules/@codemirror/language/dist/index.d.ts
generated
vendored
Normal file
1220
node_modules/@codemirror/language/dist/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2664
node_modules/@codemirror/language/dist/index.js
generated
vendored
Normal file
2664
node_modules/@codemirror/language/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
44
node_modules/@codemirror/language/package.json
generated
vendored
Normal file
44
node_modules/@codemirror/language/package.json
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@codemirror/language",
|
||||
"version": "6.11.0",
|
||||
"description": "Language support infrastructure for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.23.0",
|
||||
"@lezer/common": "^1.1.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0",
|
||||
"@lezer/javascript": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/language.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/lint/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/lint/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
272
node_modules/@codemirror/lint/CHANGELOG.md
generated
vendored
Normal file
272
node_modules/@codemirror/lint/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
## 6.8.4 (2024-11-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't create overlapping decorations when diagnostics overlap.
|
||||
|
||||
Fix an issue where block widgets could cause the lint gutter to show diagnostics multiple times.
|
||||
|
||||
## 6.8.3 (2024-11-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that prevented tooltips in the lint gutter from being displayed.
|
||||
|
||||
## 6.8.2 (2024-09-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Show lint markers for code replaced by a block widget.
|
||||
|
||||
When multiple linters are installed, start displaying results from ones that return quickly even if others are slow to return.
|
||||
|
||||
## 6.8.1 (2024-06-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make lint markers non-inclusive again, since having them that way causes more issues than it solves.
|
||||
|
||||
## 6.8.0 (2024-05-23)
|
||||
|
||||
### New features
|
||||
|
||||
The new `autoPanel` option can be used to make the panel automatically appear when diagnostics are added and close when no diagnostics are left.
|
||||
|
||||
## 6.7.1 (2024-05-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't perform an additional superfluous timed lint run after `forceLinting` has been called.
|
||||
|
||||
## 6.7.0 (2024-04-30)
|
||||
|
||||
### New features
|
||||
|
||||
The `renderMessage` function is now called with the editor view as first argument.
|
||||
|
||||
## 6.6.0 (2024-04-29)
|
||||
|
||||
### New features
|
||||
|
||||
The new `hideOn` configuration option can be used to control in what circumstances lint tooltips get hidden by state changes.
|
||||
|
||||
## 6.5.0 (2024-01-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make lint mark decorations inclusive, so that they are applied even if the marked content is replaced by a widget decoration.
|
||||
|
||||
### New features
|
||||
|
||||
`linter` can now be called with null as source to only provide a configuration.
|
||||
|
||||
`markerFilter` and `tooltipFilter` function now get passed the current editor state.
|
||||
|
||||
## 6.4.2 (2023-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure scrolling diagnostic into view in the panel works when the editor is scaled.
|
||||
|
||||
## 6.4.1 (2023-08-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash that could occur when a view was reconfigured in a way that removed the lint extension.
|
||||
|
||||
## 6.4.0 (2023-07-03)
|
||||
|
||||
### New features
|
||||
|
||||
Diagnostics can now use `"hint"` as a severity level.
|
||||
|
||||
Diagnostics can now set a `markClass` property to add an additional CSS class to the text marked by the diagnostic.
|
||||
|
||||
## 6.3.0 (2023-06-23)
|
||||
|
||||
### New features
|
||||
|
||||
A new `previousDiagnostic` command can be used to move back through the active diagnostics.
|
||||
|
||||
## 6.2.2 (2023-06-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure lint gutter tooltips are properly closed when the content of their line changes.
|
||||
|
||||
## 6.2.1 (2023-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `linter` function now eagerly includes all lint-related extensions, rather than appending them to the configuration as-needed, so that turning off linting by clearing the compartment that contains it works properly.
|
||||
|
||||
## 6.2.0 (2023-02-27)
|
||||
|
||||
### New features
|
||||
|
||||
The new `needsRefresh` option to `linter` makes it possible to cause linting to be recalculated for non-document state changes.
|
||||
|
||||
## 6.1.1 (2023-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give lint action buttons a pointer cursor style.
|
||||
|
||||
Fix a bug that caused diagnostic action callbacks to be called twice when their button was clicked.
|
||||
|
||||
## 6.1.0 (2022-11-15)
|
||||
|
||||
### New features
|
||||
|
||||
The new `forEachDiagnostic` function can be used to iterate over the diagnostics in an editor state.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.3 (2022-05-25)
|
||||
|
||||
### New features
|
||||
|
||||
Diagnostic objects may now have a `renderMessage` method to render their message to the DOM.
|
||||
|
||||
## 0.20.2 (2022-05-02)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports the `LintSource` function type.
|
||||
|
||||
The new `markerFilter` and `tooltipFilter` options to `linter` and `lintGutter` allow more control over which diagnostics are visible and which have tooltips.
|
||||
|
||||
## 0.20.1 (2022-04-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Hide lint tooltips when the document is changed.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.20.0
|
||||
|
||||
## 0.19.6 (2022-03-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where hovering over the icons in the lint gutter would sometimes fail to show a tooltip or show the tooltip for another line.
|
||||
|
||||
## 0.19.5 (2022-02-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the lint gutter tooltips are positioned under their icon, even when the line is wrapped.
|
||||
|
||||
## 0.19.4 (2022-02-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where an outdated marker could stick around on the lint gutter after all diagnostics were removed.
|
||||
|
||||
### New features
|
||||
|
||||
Add a `hoverTime` option to the lint gutter. Change default hover time to 300
|
||||
|
||||
## 0.19.3 (2021-11-09)
|
||||
|
||||
### New features
|
||||
|
||||
Export a function `lintGutter` which returns an extension that installs a gutter marking lines with diagnostics.
|
||||
|
||||
The package now exports the effect used to update the diagnostics (`setDiagnosticsEffect`).
|
||||
|
||||
## 0.19.2 (2021-09-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where reconfiguring the lint source didn't restart linting.
|
||||
|
||||
## 0.19.1 (2021-09-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Prevent decorations that cover just a line break from being invisible by showing a widget instead of range for them.
|
||||
|
||||
### New features
|
||||
|
||||
The `diagnosticCount` method can now be used to determine whether there are active diagnostics.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.19.0
|
||||
|
||||
## 0.18.6 (2021-08-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash in the key handler of the lint panel when no diagnostics are available.
|
||||
|
||||
## 0.18.5 (2021-08-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that caused `openLintPanel` to not actually open the panel when ran before the editor had any lint state loaded.
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a `forceLinting` function that forces pending lint queries to run immediately.
|
||||
|
||||
## 0.18.4 (2021-06-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Multiple `linter` extensions can now be added to an editor without disrupting each other.
|
||||
|
||||
Fix poor layout on lint tooltips due to changes in @codemirror/tooltip.
|
||||
|
||||
## 0.18.3 (2021-05-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression where using `setDiagnostics` when linting hadn't been abled yet ignored the first set of diagnostics.
|
||||
|
||||
## 0.18.2 (2021-04-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Newlines in line messages are now shown as line breaks to the user.
|
||||
|
||||
### New features
|
||||
|
||||
You can now pass a delay option to `linter` to configure how long it waits before calling the linter.
|
||||
|
||||
## 0.18.1 (2021-03-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Adjust to current @codemirror/panel and @codemirror/tooltip interfaces.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure action access keys are discoverable for screen reader users.
|
||||
|
||||
Selection in the lint panel should now be properly visible to screen readers.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/lint/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/lint/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
18
node_modules/@codemirror/lint/README.md
generated
vendored
Normal file
18
node_modules/@codemirror/lint/README.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# @codemirror/lint [](https://www.npmjs.org/package/@codemirror/lint)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#lint) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lint/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements linting support for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/lint/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
908
node_modules/@codemirror/lint/dist/index.cjs
generated
vendored
Normal file
908
node_modules/@codemirror/lint/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,908 @@
|
||||
'use strict';
|
||||
|
||||
var view = require('@codemirror/view');
|
||||
var state = require('@codemirror/state');
|
||||
var elt = require('crelt');
|
||||
|
||||
class SelectedDiagnostic {
|
||||
constructor(from, to, diagnostic) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.diagnostic = diagnostic;
|
||||
}
|
||||
}
|
||||
class LintState {
|
||||
constructor(diagnostics, panel, selected) {
|
||||
this.diagnostics = diagnostics;
|
||||
this.panel = panel;
|
||||
this.selected = selected;
|
||||
}
|
||||
static init(diagnostics, panel, state$1) {
|
||||
// Filter the list of diagnostics for which to create markers
|
||||
let markedDiagnostics = diagnostics;
|
||||
let diagnosticFilter = state$1.facet(lintConfig).markerFilter;
|
||||
if (diagnosticFilter)
|
||||
markedDiagnostics = diagnosticFilter(markedDiagnostics, state$1);
|
||||
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
||||
let deco = new state.RangeSetBuilder(), active = [], pos = 0;
|
||||
for (let i = 0;;) {
|
||||
let next = i == sorted.length ? null : sorted[i];
|
||||
if (!next && !active.length)
|
||||
break;
|
||||
let from, to;
|
||||
if (active.length) {
|
||||
from = pos;
|
||||
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
|
||||
}
|
||||
else {
|
||||
from = next.from;
|
||||
to = next.to;
|
||||
active.push(next);
|
||||
i++;
|
||||
}
|
||||
while (i < sorted.length) {
|
||||
let next = sorted[i];
|
||||
if (next.from == from && (next.to > next.from || next.to == from)) {
|
||||
active.push(next);
|
||||
i++;
|
||||
to = Math.min(next.to, to);
|
||||
}
|
||||
else {
|
||||
to = Math.min(next.from, to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let sev = maxSeverity(active);
|
||||
if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state$1.doc.lineAt(d.from).to == d.from))) {
|
||||
deco.add(from, from, view.Decoration.widget({
|
||||
widget: new DiagnosticWidget(sev),
|
||||
diagnostics: active.slice()
|
||||
}));
|
||||
}
|
||||
else {
|
||||
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
|
||||
deco.add(from, to, view.Decoration.mark({
|
||||
class: "cm-lintRange cm-lintRange-" + sev + markClass,
|
||||
diagnostics: active.slice(),
|
||||
inclusiveEnd: active.some(a => a.to > to)
|
||||
}));
|
||||
}
|
||||
pos = to;
|
||||
for (let i = 0; i < active.length; i++)
|
||||
if (active[i].to <= pos)
|
||||
active.splice(i--, 1);
|
||||
}
|
||||
let set = deco.finish();
|
||||
return new LintState(set, panel, findDiagnostic(set));
|
||||
}
|
||||
}
|
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
||||
let found = null;
|
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
||||
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
|
||||
return;
|
||||
if (!found)
|
||||
found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
|
||||
else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
|
||||
return false;
|
||||
else
|
||||
found = new SelectedDiagnostic(found.from, to, found.diagnostic);
|
||||
});
|
||||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
let from = tooltip.pos, to = tooltip.end || from;
|
||||
let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
|
||||
if (result != null)
|
||||
return result;
|
||||
let line = tr.startState.doc.lineAt(tooltip.pos);
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
|
||||
}
|
||||
function maybeEnableLint(state$1, effects) {
|
||||
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of(lintExtensions));
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
diagnostics, and enables the lint extension if if wasn't already
|
||||
active.
|
||||
*/
|
||||
function setDiagnostics(state, diagnostics) {
|
||||
return {
|
||||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
|
||||
};
|
||||
}
|
||||
/**
|
||||
The state effect that updates the set of active diagnostics. Can
|
||||
be useful when writing an extension that needs to track these.
|
||||
*/
|
||||
const setDiagnosticsEffect = state.StateEffect.define();
|
||||
const togglePanel = state.StateEffect.define();
|
||||
const movePanelSelection = state.StateEffect.define();
|
||||
const lintState = state.StateField.define({
|
||||
create() {
|
||||
return new LintState(view.Decoration.none, null, null);
|
||||
},
|
||||
update(value, tr) {
|
||||
if (tr.docChanged && value.diagnostics.size) {
|
||||
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
|
||||
if (value.selected) {
|
||||
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
||||
}
|
||||
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
|
||||
panel = null;
|
||||
value = new LintState(mapped, panel, selected);
|
||||
}
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
|
||||
value = LintState.init(effect.value, panel, tr.state);
|
||||
}
|
||||
else if (effect.is(togglePanel)) {
|
||||
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
||||
}
|
||||
else if (effect.is(movePanelSelection)) {
|
||||
value = new LintState(value.diagnostics, value.panel, effect.value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
},
|
||||
provide: f => [view.showPanel.from(f, val => val.panel),
|
||||
view.EditorView.decorations.from(f, s => s.diagnostics)]
|
||||
});
|
||||
/**
|
||||
Returns the number of active lint diagnostics in the given state.
|
||||
*/
|
||||
function diagnosticCount(state) {
|
||||
let lint = state.field(lintState, false);
|
||||
return lint ? lint.diagnostics.size : 0;
|
||||
}
|
||||
const activeMark = view.Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
||||
function lintTooltip(view, pos, side) {
|
||||
let { diagnostics } = view.state.field(lintState);
|
||||
let found, start = -1, end = -1;
|
||||
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
|
||||
if (pos >= from && pos <= to &&
|
||||
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
|
||||
found = spec.diagnostics;
|
||||
start = from;
|
||||
end = to;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
||||
if (found && diagnosticFilter)
|
||||
found = diagnosticFilter(found, view.state);
|
||||
if (!found)
|
||||
return null;
|
||||
return {
|
||||
pos: start,
|
||||
end: end,
|
||||
above: view.state.doc.lineAt(start).to < end,
|
||||
create() {
|
||||
return { dom: diagnosticsTooltip(view, found) };
|
||||
}
|
||||
};
|
||||
}
|
||||
function diagnosticsTooltip(view, diagnostics) {
|
||||
return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
|
||||
}
|
||||
/**
|
||||
Command to open and focus the lint panel.
|
||||
*/
|
||||
const openLintPanel = (view$1) => {
|
||||
let field = view$1.state.field(lintState, false);
|
||||
if (!field || !field.panel)
|
||||
view$1.dispatch({ effects: maybeEnableLint(view$1.state, [togglePanel.of(true)]) });
|
||||
let panel = view.getPanel(view$1, LintPanel.open);
|
||||
if (panel)
|
||||
panel.dom.querySelector(".cm-panel-lint ul").focus();
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Command to close the lint panel, when open.
|
||||
*/
|
||||
const closeLintPanel = (view) => {
|
||||
let field = view.state.field(lintState, false);
|
||||
if (!field || !field.panel)
|
||||
return false;
|
||||
view.dispatch({ effects: togglePanel.of(false) });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the next diagnostic.
|
||||
*/
|
||||
const nextDiagnostic = (view) => {
|
||||
let field = view.state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
|
||||
if (!next.value) {
|
||||
next = field.diagnostics.iter(0);
|
||||
if (!next.value || next.from == sel.from && next.to == sel.to)
|
||||
return false;
|
||||
}
|
||||
view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
const previousDiagnostic = (view) => {
|
||||
let { state } = view, field = state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = state.selection.main;
|
||||
let prevFrom, prevTo, lastFrom, lastTo;
|
||||
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
||||
prevFrom = from;
|
||||
prevTo = to;
|
||||
}
|
||||
if (lastFrom == null || from > lastFrom) {
|
||||
lastFrom = from;
|
||||
lastTo = to;
|
||||
}
|
||||
});
|
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
||||
return false;
|
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/
|
||||
const lintKeymap = [
|
||||
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
|
||||
{ key: "F8", run: nextDiagnostic }
|
||||
];
|
||||
const lintPlugin = view.ViewPlugin.fromClass(class {
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
this.timeout = -1;
|
||||
this.set = true;
|
||||
let { delay } = view.state.facet(lintConfig);
|
||||
this.lintTime = Date.now() + delay;
|
||||
this.run = this.run.bind(this);
|
||||
this.timeout = setTimeout(this.run, delay);
|
||||
}
|
||||
run() {
|
||||
clearTimeout(this.timeout);
|
||||
let now = Date.now();
|
||||
if (now < this.lintTime - 10) {
|
||||
this.timeout = setTimeout(this.run, this.lintTime - now);
|
||||
}
|
||||
else {
|
||||
this.set = false;
|
||||
let { state } = this.view, { sources } = state.facet(lintConfig);
|
||||
if (sources.length)
|
||||
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => {
|
||||
if (this.view.state.doc == state.doc)
|
||||
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b))));
|
||||
}, error => { view.logException(this.view.state, error); });
|
||||
}
|
||||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
||||
config.needsRefresh && config.needsRefresh(update)) {
|
||||
this.lintTime = Date.now() + config.delay;
|
||||
if (!this.set) {
|
||||
this.set = true;
|
||||
this.timeout = setTimeout(this.run, config.delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
force() {
|
||||
if (this.set) {
|
||||
this.lintTime = Date.now();
|
||||
this.run();
|
||||
}
|
||||
}
|
||||
destroy() {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
});
|
||||
function batchResults(promises, sink, error) {
|
||||
let collected = [], timeout = -1;
|
||||
for (let p of promises)
|
||||
p.then(value => {
|
||||
collected.push(value);
|
||||
clearTimeout(timeout);
|
||||
if (collected.length == promises.length)
|
||||
sink(collected);
|
||||
else
|
||||
timeout = setTimeout(() => sink(collected), 200);
|
||||
}, error);
|
||||
}
|
||||
const lintConfig = state.Facet.define({
|
||||
combine(input) {
|
||||
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, state.combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null,
|
||||
hideOn: () => null,
|
||||
}, {
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
||||
}));
|
||||
}
|
||||
});
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed). If `null` is given as
|
||||
source, this only configures the lint extension.
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return [
|
||||
lintConfig.of({ source, config }),
|
||||
lintPlugin,
|
||||
lintExtensions
|
||||
];
|
||||
}
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away.
|
||||
*/
|
||||
function forceLinting(view) {
|
||||
let plugin = view.plugin(lintPlugin);
|
||||
if (plugin)
|
||||
plugin.force();
|
||||
}
|
||||
function assignKeys(actions) {
|
||||
let assigned = [];
|
||||
if (actions)
|
||||
actions: for (let { name } of actions) {
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
let ch = name[i];
|
||||
if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
|
||||
assigned.push(ch);
|
||||
continue actions;
|
||||
}
|
||||
}
|
||||
assigned.push("");
|
||||
}
|
||||
return assigned;
|
||||
}
|
||||
function renderDiagnostic(view, diagnostic, inPanel) {
|
||||
var _a;
|
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
||||
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
||||
let fired = false, click = (e) => {
|
||||
e.preventDefault();
|
||||
if (fired)
|
||||
return;
|
||||
fired = true;
|
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
action.apply(view, found.from, found.to);
|
||||
};
|
||||
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
||||
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
||||
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
||||
name.slice(keyIndex + 1)];
|
||||
return elt("button", {
|
||||
type: "button",
|
||||
class: "cm-diagnosticAction",
|
||||
onclick: click,
|
||||
onmousedown: click,
|
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
||||
}, nameElt);
|
||||
}), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
||||
}
|
||||
class DiagnosticWidget extends view.WidgetType {
|
||||
constructor(sev) {
|
||||
super();
|
||||
this.sev = sev;
|
||||
}
|
||||
eq(other) { return other.sev == this.sev; }
|
||||
toDOM() {
|
||||
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
|
||||
}
|
||||
}
|
||||
class PanelItem {
|
||||
constructor(view, diagnostic) {
|
||||
this.diagnostic = diagnostic;
|
||||
this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
|
||||
this.dom = renderDiagnostic(view, diagnostic, true);
|
||||
this.dom.id = this.id;
|
||||
this.dom.setAttribute("role", "option");
|
||||
}
|
||||
}
|
||||
class LintPanel {
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
this.items = [];
|
||||
let onkeydown = (event) => {
|
||||
if (event.keyCode == 27) { // Escape
|
||||
closeLintPanel(this.view);
|
||||
this.view.focus();
|
||||
}
|
||||
else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
|
||||
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
||||
}
|
||||
else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
|
||||
this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
||||
}
|
||||
else if (event.keyCode == 36) { // Home
|
||||
this.moveSelection(0);
|
||||
}
|
||||
else if (event.keyCode == 35) { // End
|
||||
this.moveSelection(this.items.length - 1);
|
||||
}
|
||||
else if (event.keyCode == 13) { // Enter
|
||||
this.view.focus();
|
||||
}
|
||||
else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
|
||||
let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
|
||||
for (let i = 0; i < keys.length; i++)
|
||||
if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
|
||||
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
diagnostic.actions[i].apply(view, found.from, found.to);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
};
|
||||
let onclick = (event) => {
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].dom.contains(event.target))
|
||||
this.moveSelection(i);
|
||||
}
|
||||
};
|
||||
this.list = elt("ul", {
|
||||
tabIndex: 0,
|
||||
role: "listbox",
|
||||
"aria-label": this.view.state.phrase("Diagnostics"),
|
||||
onkeydown,
|
||||
onclick
|
||||
});
|
||||
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", {
|
||||
type: "button",
|
||||
name: "close",
|
||||
"aria-label": this.view.state.phrase("close"),
|
||||
onclick: () => closeLintPanel(this.view)
|
||||
}, "×"));
|
||||
this.update();
|
||||
}
|
||||
get selectedIndex() {
|
||||
let selected = this.view.state.field(lintState).selected;
|
||||
if (!selected)
|
||||
return -1;
|
||||
for (let i = 0; i < this.items.length; i++)
|
||||
if (this.items[i].diagnostic == selected.diagnostic)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
update() {
|
||||
let { diagnostics, selected } = this.view.state.field(lintState);
|
||||
let i = 0, needsSync = false, newSelectedItem = null;
|
||||
let seen = new Set();
|
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
||||
for (let diagnostic of spec.diagnostics) {
|
||||
if (seen.has(diagnostic))
|
||||
continue;
|
||||
seen.add(diagnostic);
|
||||
let found = -1, item;
|
||||
for (let j = i; j < this.items.length; j++)
|
||||
if (this.items[j].diagnostic == diagnostic) {
|
||||
found = j;
|
||||
break;
|
||||
}
|
||||
if (found < 0) {
|
||||
item = new PanelItem(this.view, diagnostic);
|
||||
this.items.splice(i, 0, item);
|
||||
needsSync = true;
|
||||
}
|
||||
else {
|
||||
item = this.items[found];
|
||||
if (found > i) {
|
||||
this.items.splice(i, found - i);
|
||||
needsSync = true;
|
||||
}
|
||||
}
|
||||
if (selected && item.diagnostic == selected.diagnostic) {
|
||||
if (!item.dom.hasAttribute("aria-selected")) {
|
||||
item.dom.setAttribute("aria-selected", "true");
|
||||
newSelectedItem = item;
|
||||
}
|
||||
}
|
||||
else if (item.dom.hasAttribute("aria-selected")) {
|
||||
item.dom.removeAttribute("aria-selected");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
});
|
||||
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
|
||||
needsSync = true;
|
||||
this.items.pop();
|
||||
}
|
||||
if (this.items.length == 0) {
|
||||
this.items.push(new PanelItem(this.view, {
|
||||
from: -1, to: -1,
|
||||
severity: "info",
|
||||
message: this.view.state.phrase("No diagnostics")
|
||||
}));
|
||||
needsSync = true;
|
||||
}
|
||||
if (newSelectedItem) {
|
||||
this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
|
||||
this.view.requestMeasure({
|
||||
key: this,
|
||||
read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
|
||||
write: ({ sel, panel }) => {
|
||||
let scaleY = panel.height / this.list.offsetHeight;
|
||||
if (sel.top < panel.top)
|
||||
this.list.scrollTop -= (panel.top - sel.top) / scaleY;
|
||||
else if (sel.bottom > panel.bottom)
|
||||
this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (this.selectedIndex < 0) {
|
||||
this.list.removeAttribute("aria-activedescendant");
|
||||
}
|
||||
if (needsSync)
|
||||
this.sync();
|
||||
}
|
||||
sync() {
|
||||
let domPos = this.list.firstChild;
|
||||
function rm() {
|
||||
let prev = domPos;
|
||||
domPos = prev.nextSibling;
|
||||
prev.remove();
|
||||
}
|
||||
for (let item of this.items) {
|
||||
if (item.dom.parentNode == this.list) {
|
||||
while (domPos != item.dom)
|
||||
rm();
|
||||
domPos = item.dom.nextSibling;
|
||||
}
|
||||
else {
|
||||
this.list.insertBefore(item.dom, domPos);
|
||||
}
|
||||
}
|
||||
while (domPos)
|
||||
rm();
|
||||
}
|
||||
moveSelection(selectedIndex) {
|
||||
if (this.selectedIndex < 0)
|
||||
return;
|
||||
let field = this.view.state.field(lintState);
|
||||
let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
|
||||
if (!selection)
|
||||
return;
|
||||
this.view.dispatch({
|
||||
selection: { anchor: selection.from, head: selection.to },
|
||||
scrollIntoView: true,
|
||||
effects: movePanelSelection.of(selection)
|
||||
});
|
||||
}
|
||||
static open(view) { return new LintPanel(view); }
|
||||
}
|
||||
function svg(content, attrs = `viewBox="0 0 40 40"`) {
|
||||
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
|
||||
}
|
||||
function underline(color) {
|
||||
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
|
||||
}
|
||||
const baseTheme = view.EditorView.baseTheme({
|
||||
".cm-diagnostic": {
|
||||
padding: "3px 6px 3px 8px",
|
||||
marginLeft: "-1px",
|
||||
display: "block",
|
||||
whiteSpace: "pre-wrap"
|
||||
},
|
||||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
||||
".cm-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
padding: "2px 4px",
|
||||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px",
|
||||
cursor: "pointer"
|
||||
},
|
||||
".cm-diagnosticSource": {
|
||||
fontSize: "70%",
|
||||
opacity: .7
|
||||
},
|
||||
".cm-lintRange": {
|
||||
backgroundPosition: "left bottom",
|
||||
backgroundRepeat: "repeat-x",
|
||||
paddingBottom: "0.7px",
|
||||
},
|
||||
".cm-lintRange-error": { backgroundImage: underline("#d11") },
|
||||
".cm-lintRange-warning": { backgroundImage: underline("orange") },
|
||||
".cm-lintRange-info": { backgroundImage: underline("#999") },
|
||||
".cm-lintRange-hint": { backgroundImage: underline("#66d") },
|
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
||||
".cm-tooltip-lint": {
|
||||
padding: 0,
|
||||
margin: 0
|
||||
},
|
||||
".cm-lintPoint": {
|
||||
position: "relative",
|
||||
"&:after": {
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
left: "-2px",
|
||||
borderLeft: "3px solid transparent",
|
||||
borderRight: "3px solid transparent",
|
||||
borderBottom: "4px solid #d11"
|
||||
}
|
||||
},
|
||||
".cm-lintPoint-warning": {
|
||||
"&:after": { borderBottomColor: "orange" }
|
||||
},
|
||||
".cm-lintPoint-info": {
|
||||
"&:after": { borderBottomColor: "#999" }
|
||||
},
|
||||
".cm-lintPoint-hint": {
|
||||
"&:after": { borderBottomColor: "#66d" }
|
||||
},
|
||||
".cm-panel.cm-panel-lint": {
|
||||
position: "relative",
|
||||
"& ul": {
|
||||
maxHeight: "100px",
|
||||
overflowY: "auto",
|
||||
"& [aria-selected]": {
|
||||
backgroundColor: "#ddd",
|
||||
"& u": { textDecoration: "underline" }
|
||||
},
|
||||
"&:focus [aria-selected]": {
|
||||
background_fallback: "#bdf",
|
||||
backgroundColor: "Highlight",
|
||||
color_fallback: "white",
|
||||
color: "HighlightText"
|
||||
},
|
||||
"& u": { textDecoration: "none" },
|
||||
padding: 0,
|
||||
margin: 0
|
||||
},
|
||||
"& [name=close]": {
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
right: "2px",
|
||||
background: "inherit",
|
||||
border: "none",
|
||||
font: "inherit",
|
||||
padding: 0,
|
||||
margin: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
function severityWeight(sev) {
|
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
||||
}
|
||||
function maxSeverity(diagnostics) {
|
||||
let sev = "hint", weight = 1;
|
||||
for (let d of diagnostics) {
|
||||
let w = severityWeight(d.severity);
|
||||
if (w > weight) {
|
||||
weight = w;
|
||||
sev = d.severity;
|
||||
}
|
||||
}
|
||||
return sev;
|
||||
}
|
||||
class LintGutterMarker extends view.GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = maxSeverity(diagnostics);
|
||||
}
|
||||
toDOM(view) {
|
||||
let elt = document.createElement("div");
|
||||
elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
|
||||
let diagnostics = this.diagnostics;
|
||||
let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
|
||||
if (diagnosticsFilter)
|
||||
diagnostics = diagnosticsFilter(diagnostics, view.state);
|
||||
if (diagnostics.length)
|
||||
elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
|
||||
return elt;
|
||||
}
|
||||
}
|
||||
function trackHoverOn(view, marker) {
|
||||
let mousemove = (event) => {
|
||||
let rect = marker.getBoundingClientRect();
|
||||
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
|
||||
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
|
||||
return;
|
||||
for (let target = event.target; target; target = target.parentNode) {
|
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
||||
return;
|
||||
}
|
||||
window.removeEventListener("mousemove", mousemove);
|
||||
if (view.state.field(lintGutterTooltip))
|
||||
view.dispatch({ effects: setLintGutterTooltip.of(null) });
|
||||
};
|
||||
window.addEventListener("mousemove", mousemove);
|
||||
}
|
||||
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
||||
function hovered() {
|
||||
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
||||
const linePos = view.coordsAtPos(line.from);
|
||||
if (linePos) {
|
||||
view.dispatch({ effects: setLintGutterTooltip.of({
|
||||
pos: line.from,
|
||||
above: false,
|
||||
clip: false,
|
||||
create() {
|
||||
return {
|
||||
dom: diagnosticsTooltip(view, diagnostics),
|
||||
getCoords: () => marker.getBoundingClientRect()
|
||||
};
|
||||
}
|
||||
}) });
|
||||
}
|
||||
marker.onmouseout = marker.onmousemove = null;
|
||||
trackHoverOn(view, marker);
|
||||
}
|
||||
let { hoverTime } = view.state.facet(lintGutterConfig);
|
||||
let hoverTimeout = setTimeout(hovered, hoverTime);
|
||||
marker.onmouseout = () => {
|
||||
clearTimeout(hoverTimeout);
|
||||
marker.onmouseout = marker.onmousemove = null;
|
||||
};
|
||||
marker.onmousemove = () => {
|
||||
clearTimeout(hoverTimeout);
|
||||
hoverTimeout = setTimeout(hovered, hoverTime);
|
||||
};
|
||||
}
|
||||
function markersForDiagnostics(doc, diagnostics) {
|
||||
let byLine = Object.create(null);
|
||||
for (let diagnostic of diagnostics) {
|
||||
let line = doc.lineAt(diagnostic.from);
|
||||
(byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
|
||||
}
|
||||
let markers = [];
|
||||
for (let line in byLine) {
|
||||
markers.push(new LintGutterMarker(byLine[line]).range(+line));
|
||||
}
|
||||
return state.RangeSet.of(markers, true);
|
||||
}
|
||||
const lintGutterExtension = view.gutter({
|
||||
class: "cm-gutter-lint",
|
||||
markers: view => view.state.field(lintGutterMarkers),
|
||||
widgetMarker: (view, widget, block) => {
|
||||
let diagnostics = [];
|
||||
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
|
||||
if (from > block.from && from < block.to)
|
||||
diagnostics.push(...value.diagnostics);
|
||||
});
|
||||
return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
|
||||
}
|
||||
});
|
||||
const lintGutterMarkers = state.StateField.define({
|
||||
create() {
|
||||
return state.RangeSet.empty;
|
||||
},
|
||||
update(markers, tr) {
|
||||
markers = markers.map(tr.changes);
|
||||
let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
let diagnostics = effect.value;
|
||||
if (diagnosticFilter)
|
||||
diagnostics = diagnosticFilter(diagnostics || [], tr.state);
|
||||
markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
|
||||
}
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
});
|
||||
const setLintGutterTooltip = state.StateEffect.define();
|
||||
const lintGutterTooltip = state.StateField.define({
|
||||
create() { return null; },
|
||||
update(tooltip, tr) {
|
||||
if (tooltip && tr.docChanged)
|
||||
tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
||||
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
||||
},
|
||||
provide: field => view.showTooltip.from(field)
|
||||
});
|
||||
const lintGutterTheme = view.EditorView.baseTheme({
|
||||
".cm-gutter-lint": {
|
||||
width: "1.4em",
|
||||
"& .cm-gutterElement": {
|
||||
padding: ".2em"
|
||||
}
|
||||
},
|
||||
".cm-lint-marker": {
|
||||
width: "1em",
|
||||
height: "1em"
|
||||
},
|
||||
".cm-lint-marker-info": {
|
||||
content: svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
|
||||
},
|
||||
".cm-lint-marker-warning": {
|
||||
content: svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
|
||||
},
|
||||
".cm-lint-marker-error": {
|
||||
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintExtensions = [
|
||||
lintState,
|
||||
view.EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? view.Decoration.none : view.Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
view.hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
];
|
||||
const lintGutterConfig = state.Facet.define({
|
||||
combine(configs) {
|
||||
return state.combineConfig(configs, {
|
||||
hoverTime: 300 /* Hover.Time */,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
});
|
||||
}
|
||||
});
|
||||
/**
|
||||
Returns an extension that installs a gutter showing markers for
|
||||
each line that has diagnostics, which can be hovered over to see
|
||||
the diagnostics.
|
||||
*/
|
||||
function lintGutter(config = {}) {
|
||||
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
||||
}
|
||||
/**
|
||||
Iterate over the marked diagnostics for the given editor state,
|
||||
calling `f` for each of them. Note that, if the document changed
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
function forEachDiagnostic(state$1, f) {
|
||||
let lState = state$1.field(lintState, false);
|
||||
if (lState && lState.diagnostics.size) {
|
||||
let pending = [], pendingStart = [], lastEnd = -1;
|
||||
for (let iter = state.RangeSet.iter([lState.diagnostics]);; iter.next()) {
|
||||
for (let i = 0; i < pending.length; i++)
|
||||
if (!iter.value || iter.value.spec.diagnostics.indexOf(pending[i]) < 0) {
|
||||
f(pending[i], pendingStart[i], lastEnd);
|
||||
pending.splice(i, 1);
|
||||
pendingStart.splice(i--, 1);
|
||||
}
|
||||
if (!iter.value)
|
||||
break;
|
||||
for (let d of iter.value.spec.diagnostics)
|
||||
if (pending.indexOf(d) < 0) {
|
||||
pending.push(d);
|
||||
pendingStart.push(iter.from);
|
||||
}
|
||||
lastEnd = iter.to;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.closeLintPanel = closeLintPanel;
|
||||
exports.diagnosticCount = diagnosticCount;
|
||||
exports.forEachDiagnostic = forEachDiagnostic;
|
||||
exports.forceLinting = forceLinting;
|
||||
exports.lintGutter = lintGutter;
|
||||
exports.lintKeymap = lintKeymap;
|
||||
exports.linter = linter;
|
||||
exports.nextDiagnostic = nextDiagnostic;
|
||||
exports.openLintPanel = openLintPanel;
|
||||
exports.previousDiagnostic = previousDiagnostic;
|
||||
exports.setDiagnostics = setDiagnostics;
|
||||
exports.setDiagnosticsEffect = setDiagnosticsEffect;
|
||||
188
node_modules/@codemirror/lint/dist/index.d.cts
generated
vendored
Normal file
188
node_modules/@codemirror/lint/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state';
|
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
||||
|
||||
type Severity = "hint" | "info" | "warning" | "error";
|
||||
/**
|
||||
Describes a problem or hint for a piece of code.
|
||||
*/
|
||||
interface Diagnostic {
|
||||
/**
|
||||
The start position of the relevant text.
|
||||
*/
|
||||
from: number;
|
||||
/**
|
||||
The end position. May be equal to `from`, though actually
|
||||
covering text is preferable.
|
||||
*/
|
||||
to: number;
|
||||
/**
|
||||
The severity of the problem. This will influence how it is
|
||||
displayed.
|
||||
*/
|
||||
severity: Severity;
|
||||
/**
|
||||
When given, add an extra CSS class to parts of the code that
|
||||
this diagnostic applies to.
|
||||
*/
|
||||
markClass?: string;
|
||||
/**
|
||||
An optional source string indicating where the diagnostic is
|
||||
coming from. You can put the name of your linter here, if
|
||||
applicable.
|
||||
*/
|
||||
source?: string;
|
||||
/**
|
||||
The message associated with this diagnostic.
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
An optional custom rendering function that displays the message
|
||||
as a DOM node.
|
||||
*/
|
||||
renderMessage?: (view: EditorView) => Node;
|
||||
/**
|
||||
An optional array of actions that can be taken on this
|
||||
diagnostic.
|
||||
*/
|
||||
actions?: readonly Action[];
|
||||
}
|
||||
/**
|
||||
An action associated with a diagnostic.
|
||||
*/
|
||||
interface Action {
|
||||
/**
|
||||
The label to show to the user. Should be relatively short.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The function to call when the user activates this action. Is
|
||||
given the diagnostic's _current_ position, which may have
|
||||
changed since the creation of the diagnostic, due to editing.
|
||||
*/
|
||||
apply: (view: EditorView, from: number, to: number) => void;
|
||||
}
|
||||
type DiagnosticFilter = (diagnostics: readonly Diagnostic[], state: EditorState) => Diagnostic[];
|
||||
interface LintConfig {
|
||||
/**
|
||||
Time to wait (in milliseconds) after a change before running
|
||||
the linter. Defaults to 750ms.
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
Optional predicate that can be used to indicate when diagnostics
|
||||
need to be recomputed. Linting is always re-done on document
|
||||
changes.
|
||||
*/
|
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean);
|
||||
/**
|
||||
Optional filter to determine which diagnostics produce markers
|
||||
in the content.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Filter applied to a set of diagnostics shown in a tooltip. No
|
||||
tooltip will appear if the empty set is returned.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Can be used to control what kind of transactions cause lint
|
||||
hover tooltips associated with the given document range to be
|
||||
hidden. By default any transactions that changes the line
|
||||
around the range will hide it. Returning null falls back to this
|
||||
behavior.
|
||||
*/
|
||||
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
||||
/**
|
||||
When enabled (defaults to off), this will cause the lint panel
|
||||
to automatically open when diagnostics are found, and close when
|
||||
all diagnostics are resolved or removed.
|
||||
*/
|
||||
autoPanel?: boolean;
|
||||
}
|
||||
interface LintGutterConfig {
|
||||
/**
|
||||
The delay before showing a tooltip when hovering over a lint gutter marker.
|
||||
*/
|
||||
hoverTime?: number;
|
||||
/**
|
||||
Optional filter determining which diagnostics show a marker in
|
||||
the gutter.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Optional filter for diagnostics displayed in a tooltip, which
|
||||
can also be used to prevent a tooltip appearing.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
diagnostics, and enables the lint extension if if wasn't already
|
||||
active.
|
||||
*/
|
||||
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec;
|
||||
/**
|
||||
The state effect that updates the set of active diagnostics. Can
|
||||
be useful when writing an extension that needs to track these.
|
||||
*/
|
||||
declare const setDiagnosticsEffect: _codemirror_state.StateEffectType<readonly Diagnostic[]>;
|
||||
/**
|
||||
Returns the number of active lint diagnostics in the given state.
|
||||
*/
|
||||
declare function diagnosticCount(state: EditorState): number;
|
||||
/**
|
||||
Command to open and focus the lint panel.
|
||||
*/
|
||||
declare const openLintPanel: Command;
|
||||
/**
|
||||
Command to close the lint panel, when open.
|
||||
*/
|
||||
declare const closeLintPanel: Command;
|
||||
/**
|
||||
Move the selection to the next diagnostic.
|
||||
*/
|
||||
declare const nextDiagnostic: Command;
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
declare const previousDiagnostic: Command;
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/
|
||||
declare const lintKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
The type of a function that produces diagnostics.
|
||||
*/
|
||||
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed). If `null` is given as
|
||||
source, this only configures the lint extension.
|
||||
*/
|
||||
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away.
|
||||
*/
|
||||
declare function forceLinting(view: EditorView): void;
|
||||
/**
|
||||
Returns an extension that installs a gutter showing markers for
|
||||
each line that has diagnostics, which can be hovered over to see
|
||||
the diagnostics.
|
||||
*/
|
||||
declare function lintGutter(config?: LintGutterConfig): Extension;
|
||||
/**
|
||||
Iterate over the marked diagnostics for the given editor state,
|
||||
calling `f` for each of them. Note that, if the document changed
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void;
|
||||
|
||||
export { type Action, type Diagnostic, type LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
||||
188
node_modules/@codemirror/lint/dist/index.d.ts
generated
vendored
Normal file
188
node_modules/@codemirror/lint/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Extension, Transaction } from '@codemirror/state';
|
||||
import { EditorView, Command, KeyBinding, ViewUpdate } from '@codemirror/view';
|
||||
|
||||
type Severity = "hint" | "info" | "warning" | "error";
|
||||
/**
|
||||
Describes a problem or hint for a piece of code.
|
||||
*/
|
||||
interface Diagnostic {
|
||||
/**
|
||||
The start position of the relevant text.
|
||||
*/
|
||||
from: number;
|
||||
/**
|
||||
The end position. May be equal to `from`, though actually
|
||||
covering text is preferable.
|
||||
*/
|
||||
to: number;
|
||||
/**
|
||||
The severity of the problem. This will influence how it is
|
||||
displayed.
|
||||
*/
|
||||
severity: Severity;
|
||||
/**
|
||||
When given, add an extra CSS class to parts of the code that
|
||||
this diagnostic applies to.
|
||||
*/
|
||||
markClass?: string;
|
||||
/**
|
||||
An optional source string indicating where the diagnostic is
|
||||
coming from. You can put the name of your linter here, if
|
||||
applicable.
|
||||
*/
|
||||
source?: string;
|
||||
/**
|
||||
The message associated with this diagnostic.
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
An optional custom rendering function that displays the message
|
||||
as a DOM node.
|
||||
*/
|
||||
renderMessage?: (view: EditorView) => Node;
|
||||
/**
|
||||
An optional array of actions that can be taken on this
|
||||
diagnostic.
|
||||
*/
|
||||
actions?: readonly Action[];
|
||||
}
|
||||
/**
|
||||
An action associated with a diagnostic.
|
||||
*/
|
||||
interface Action {
|
||||
/**
|
||||
The label to show to the user. Should be relatively short.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
The function to call when the user activates this action. Is
|
||||
given the diagnostic's _current_ position, which may have
|
||||
changed since the creation of the diagnostic, due to editing.
|
||||
*/
|
||||
apply: (view: EditorView, from: number, to: number) => void;
|
||||
}
|
||||
type DiagnosticFilter = (diagnostics: readonly Diagnostic[], state: EditorState) => Diagnostic[];
|
||||
interface LintConfig {
|
||||
/**
|
||||
Time to wait (in milliseconds) after a change before running
|
||||
the linter. Defaults to 750ms.
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
Optional predicate that can be used to indicate when diagnostics
|
||||
need to be recomputed. Linting is always re-done on document
|
||||
changes.
|
||||
*/
|
||||
needsRefresh?: null | ((update: ViewUpdate) => boolean);
|
||||
/**
|
||||
Optional filter to determine which diagnostics produce markers
|
||||
in the content.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Filter applied to a set of diagnostics shown in a tooltip. No
|
||||
tooltip will appear if the empty set is returned.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Can be used to control what kind of transactions cause lint
|
||||
hover tooltips associated with the given document range to be
|
||||
hidden. By default any transactions that changes the line
|
||||
around the range will hide it. Returning null falls back to this
|
||||
behavior.
|
||||
*/
|
||||
hideOn?: (tr: Transaction, from: number, to: number) => boolean | null;
|
||||
/**
|
||||
When enabled (defaults to off), this will cause the lint panel
|
||||
to automatically open when diagnostics are found, and close when
|
||||
all diagnostics are resolved or removed.
|
||||
*/
|
||||
autoPanel?: boolean;
|
||||
}
|
||||
interface LintGutterConfig {
|
||||
/**
|
||||
The delay before showing a tooltip when hovering over a lint gutter marker.
|
||||
*/
|
||||
hoverTime?: number;
|
||||
/**
|
||||
Optional filter determining which diagnostics show a marker in
|
||||
the gutter.
|
||||
*/
|
||||
markerFilter?: null | DiagnosticFilter;
|
||||
/**
|
||||
Optional filter for diagnostics displayed in a tooltip, which
|
||||
can also be used to prevent a tooltip appearing.
|
||||
*/
|
||||
tooltipFilter?: null | DiagnosticFilter;
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
diagnostics, and enables the lint extension if if wasn't already
|
||||
active.
|
||||
*/
|
||||
declare function setDiagnostics(state: EditorState, diagnostics: readonly Diagnostic[]): TransactionSpec;
|
||||
/**
|
||||
The state effect that updates the set of active diagnostics. Can
|
||||
be useful when writing an extension that needs to track these.
|
||||
*/
|
||||
declare const setDiagnosticsEffect: _codemirror_state.StateEffectType<readonly Diagnostic[]>;
|
||||
/**
|
||||
Returns the number of active lint diagnostics in the given state.
|
||||
*/
|
||||
declare function diagnosticCount(state: EditorState): number;
|
||||
/**
|
||||
Command to open and focus the lint panel.
|
||||
*/
|
||||
declare const openLintPanel: Command;
|
||||
/**
|
||||
Command to close the lint panel, when open.
|
||||
*/
|
||||
declare const closeLintPanel: Command;
|
||||
/**
|
||||
Move the selection to the next diagnostic.
|
||||
*/
|
||||
declare const nextDiagnostic: Command;
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
declare const previousDiagnostic: Command;
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/
|
||||
declare const lintKeymap: readonly KeyBinding[];
|
||||
/**
|
||||
The type of a function that produces diagnostics.
|
||||
*/
|
||||
type LintSource = (view: EditorView) => readonly Diagnostic[] | Promise<readonly Diagnostic[]>;
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed). If `null` is given as
|
||||
source, this only configures the lint extension.
|
||||
*/
|
||||
declare function linter(source: LintSource | null, config?: LintConfig): Extension;
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away.
|
||||
*/
|
||||
declare function forceLinting(view: EditorView): void;
|
||||
/**
|
||||
Returns an extension that installs a gutter showing markers for
|
||||
each line that has diagnostics, which can be hovered over to see
|
||||
the diagnostics.
|
||||
*/
|
||||
declare function lintGutter(config?: LintGutterConfig): Extension;
|
||||
/**
|
||||
Iterate over the marked diagnostics for the given editor state,
|
||||
calling `f` for each of them. Note that, if the document changed
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void;
|
||||
|
||||
export { type Action, type Diagnostic, type LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
||||
895
node_modules/@codemirror/lint/dist/index.js
generated
vendored
Normal file
895
node_modules/@codemirror/lint/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,895 @@
|
||||
import { Decoration, showPanel, EditorView, ViewPlugin, gutter, showTooltip, hoverTooltip, getPanel, logException, WidgetType, GutterMarker } from '@codemirror/view';
|
||||
import { StateEffect, StateField, Facet, combineConfig, RangeSet, RangeSetBuilder } from '@codemirror/state';
|
||||
import elt from 'crelt';
|
||||
|
||||
class SelectedDiagnostic {
|
||||
constructor(from, to, diagnostic) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.diagnostic = diagnostic;
|
||||
}
|
||||
}
|
||||
class LintState {
|
||||
constructor(diagnostics, panel, selected) {
|
||||
this.diagnostics = diagnostics;
|
||||
this.panel = panel;
|
||||
this.selected = selected;
|
||||
}
|
||||
static init(diagnostics, panel, state) {
|
||||
// Filter the list of diagnostics for which to create markers
|
||||
let markedDiagnostics = diagnostics;
|
||||
let diagnosticFilter = state.facet(lintConfig).markerFilter;
|
||||
if (diagnosticFilter)
|
||||
markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
|
||||
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
||||
let deco = new RangeSetBuilder(), active = [], pos = 0;
|
||||
for (let i = 0;;) {
|
||||
let next = i == sorted.length ? null : sorted[i];
|
||||
if (!next && !active.length)
|
||||
break;
|
||||
let from, to;
|
||||
if (active.length) {
|
||||
from = pos;
|
||||
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
|
||||
}
|
||||
else {
|
||||
from = next.from;
|
||||
to = next.to;
|
||||
active.push(next);
|
||||
i++;
|
||||
}
|
||||
while (i < sorted.length) {
|
||||
let next = sorted[i];
|
||||
if (next.from == from && (next.to > next.from || next.to == from)) {
|
||||
active.push(next);
|
||||
i++;
|
||||
to = Math.min(next.to, to);
|
||||
}
|
||||
else {
|
||||
to = Math.min(next.from, to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
let sev = maxSeverity(active);
|
||||
if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
|
||||
deco.add(from, from, Decoration.widget({
|
||||
widget: new DiagnosticWidget(sev),
|
||||
diagnostics: active.slice()
|
||||
}));
|
||||
}
|
||||
else {
|
||||
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
|
||||
deco.add(from, to, Decoration.mark({
|
||||
class: "cm-lintRange cm-lintRange-" + sev + markClass,
|
||||
diagnostics: active.slice(),
|
||||
inclusiveEnd: active.some(a => a.to > to)
|
||||
}));
|
||||
}
|
||||
pos = to;
|
||||
for (let i = 0; i < active.length; i++)
|
||||
if (active[i].to <= pos)
|
||||
active.splice(i--, 1);
|
||||
}
|
||||
let set = deco.finish();
|
||||
return new LintState(set, panel, findDiagnostic(set));
|
||||
}
|
||||
}
|
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
||||
let found = null;
|
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
||||
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
|
||||
return;
|
||||
if (!found)
|
||||
found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
|
||||
else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
|
||||
return false;
|
||||
else
|
||||
found = new SelectedDiagnostic(found.from, to, found.diagnostic);
|
||||
});
|
||||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
let from = tooltip.pos, to = tooltip.end || from;
|
||||
let result = tr.state.facet(lintConfig).hideOn(tr, from, to);
|
||||
if (result != null)
|
||||
return result;
|
||||
let line = tr.startState.doc.lineAt(tooltip.pos);
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(line.from, Math.max(line.to, to)));
|
||||
}
|
||||
function maybeEnableLint(state, effects) {
|
||||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of(lintExtensions));
|
||||
}
|
||||
/**
|
||||
Returns a transaction spec which updates the current set of
|
||||
diagnostics, and enables the lint extension if if wasn't already
|
||||
active.
|
||||
*/
|
||||
function setDiagnostics(state, diagnostics) {
|
||||
return {
|
||||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)])
|
||||
};
|
||||
}
|
||||
/**
|
||||
The state effect that updates the set of active diagnostics. Can
|
||||
be useful when writing an extension that needs to track these.
|
||||
*/
|
||||
const setDiagnosticsEffect = /*@__PURE__*/StateEffect.define();
|
||||
const togglePanel = /*@__PURE__*/StateEffect.define();
|
||||
const movePanelSelection = /*@__PURE__*/StateEffect.define();
|
||||
const lintState = /*@__PURE__*/StateField.define({
|
||||
create() {
|
||||
return new LintState(Decoration.none, null, null);
|
||||
},
|
||||
update(value, tr) {
|
||||
if (tr.docChanged && value.diagnostics.size) {
|
||||
let mapped = value.diagnostics.map(tr.changes), selected = null, panel = value.panel;
|
||||
if (value.selected) {
|
||||
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
||||
}
|
||||
if (!mapped.size && panel && tr.state.facet(lintConfig).autoPanel)
|
||||
panel = null;
|
||||
value = new LintState(mapped, panel, selected);
|
||||
}
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
let panel = !tr.state.facet(lintConfig).autoPanel ? value.panel : effect.value.length ? LintPanel.open : null;
|
||||
value = LintState.init(effect.value, panel, tr.state);
|
||||
}
|
||||
else if (effect.is(togglePanel)) {
|
||||
value = new LintState(value.diagnostics, effect.value ? LintPanel.open : null, value.selected);
|
||||
}
|
||||
else if (effect.is(movePanelSelection)) {
|
||||
value = new LintState(value.diagnostics, value.panel, effect.value);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
},
|
||||
provide: f => [showPanel.from(f, val => val.panel),
|
||||
EditorView.decorations.from(f, s => s.diagnostics)]
|
||||
});
|
||||
/**
|
||||
Returns the number of active lint diagnostics in the given state.
|
||||
*/
|
||||
function diagnosticCount(state) {
|
||||
let lint = state.field(lintState, false);
|
||||
return lint ? lint.diagnostics.size : 0;
|
||||
}
|
||||
const activeMark = /*@__PURE__*/Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
||||
function lintTooltip(view, pos, side) {
|
||||
let { diagnostics } = view.state.field(lintState);
|
||||
let found, start = -1, end = -1;
|
||||
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
|
||||
if (pos >= from && pos <= to &&
|
||||
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
|
||||
found = spec.diagnostics;
|
||||
start = from;
|
||||
end = to;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
||||
if (found && diagnosticFilter)
|
||||
found = diagnosticFilter(found, view.state);
|
||||
if (!found)
|
||||
return null;
|
||||
return {
|
||||
pos: start,
|
||||
end: end,
|
||||
above: view.state.doc.lineAt(start).to < end,
|
||||
create() {
|
||||
return { dom: diagnosticsTooltip(view, found) };
|
||||
}
|
||||
};
|
||||
}
|
||||
function diagnosticsTooltip(view, diagnostics) {
|
||||
return elt("ul", { class: "cm-tooltip-lint" }, diagnostics.map(d => renderDiagnostic(view, d, false)));
|
||||
}
|
||||
/**
|
||||
Command to open and focus the lint panel.
|
||||
*/
|
||||
const openLintPanel = (view) => {
|
||||
let field = view.state.field(lintState, false);
|
||||
if (!field || !field.panel)
|
||||
view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) });
|
||||
let panel = getPanel(view, LintPanel.open);
|
||||
if (panel)
|
||||
panel.dom.querySelector(".cm-panel-lint ul").focus();
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Command to close the lint panel, when open.
|
||||
*/
|
||||
const closeLintPanel = (view) => {
|
||||
let field = view.state.field(lintState, false);
|
||||
if (!field || !field.panel)
|
||||
return false;
|
||||
view.dispatch({ effects: togglePanel.of(false) });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the next diagnostic.
|
||||
*/
|
||||
const nextDiagnostic = (view) => {
|
||||
let field = view.state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = view.state.selection.main, next = field.diagnostics.iter(sel.to + 1);
|
||||
if (!next.value) {
|
||||
next = field.diagnostics.iter(0);
|
||||
if (!next.value || next.from == sel.from && next.to == sel.to)
|
||||
return false;
|
||||
}
|
||||
view.dispatch({ selection: { anchor: next.from, head: next.to }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
Move the selection to the previous diagnostic.
|
||||
*/
|
||||
const previousDiagnostic = (view) => {
|
||||
let { state } = view, field = state.field(lintState, false);
|
||||
if (!field)
|
||||
return false;
|
||||
let sel = state.selection.main;
|
||||
let prevFrom, prevTo, lastFrom, lastTo;
|
||||
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
||||
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
||||
prevFrom = from;
|
||||
prevTo = to;
|
||||
}
|
||||
if (lastFrom == null || from > lastFrom) {
|
||||
lastFrom = from;
|
||||
lastTo = to;
|
||||
}
|
||||
});
|
||||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
||||
return false;
|
||||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
A set of default key bindings for the lint functionality.
|
||||
|
||||
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
||||
- F8: [`nextDiagnostic`](https://codemirror.net/6/docs/ref/#lint.nextDiagnostic)
|
||||
*/
|
||||
const lintKeymap = [
|
||||
{ key: "Mod-Shift-m", run: openLintPanel, preventDefault: true },
|
||||
{ key: "F8", run: nextDiagnostic }
|
||||
];
|
||||
const lintPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
this.timeout = -1;
|
||||
this.set = true;
|
||||
let { delay } = view.state.facet(lintConfig);
|
||||
this.lintTime = Date.now() + delay;
|
||||
this.run = this.run.bind(this);
|
||||
this.timeout = setTimeout(this.run, delay);
|
||||
}
|
||||
run() {
|
||||
clearTimeout(this.timeout);
|
||||
let now = Date.now();
|
||||
if (now < this.lintTime - 10) {
|
||||
this.timeout = setTimeout(this.run, this.lintTime - now);
|
||||
}
|
||||
else {
|
||||
this.set = false;
|
||||
let { state } = this.view, { sources } = state.facet(lintConfig);
|
||||
if (sources.length)
|
||||
batchResults(sources.map(s => Promise.resolve(s(this.view))), annotations => {
|
||||
if (this.view.state.doc == state.doc)
|
||||
this.view.dispatch(setDiagnostics(this.view.state, annotations.reduce((a, b) => a.concat(b))));
|
||||
}, error => { logException(this.view.state, error); });
|
||||
}
|
||||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig) ||
|
||||
config.needsRefresh && config.needsRefresh(update)) {
|
||||
this.lintTime = Date.now() + config.delay;
|
||||
if (!this.set) {
|
||||
this.set = true;
|
||||
this.timeout = setTimeout(this.run, config.delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
force() {
|
||||
if (this.set) {
|
||||
this.lintTime = Date.now();
|
||||
this.run();
|
||||
}
|
||||
}
|
||||
destroy() {
|
||||
clearTimeout(this.timeout);
|
||||
}
|
||||
});
|
||||
function batchResults(promises, sink, error) {
|
||||
let collected = [], timeout = -1;
|
||||
for (let p of promises)
|
||||
p.then(value => {
|
||||
collected.push(value);
|
||||
clearTimeout(timeout);
|
||||
if (collected.length == promises.length)
|
||||
sink(collected);
|
||||
else
|
||||
timeout = setTimeout(() => sink(collected), 200);
|
||||
}, error);
|
||||
}
|
||||
const lintConfig = /*@__PURE__*/Facet.define({
|
||||
combine(input) {
|
||||
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null,
|
||||
hideOn: () => null,
|
||||
}, {
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
||||
}));
|
||||
}
|
||||
});
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed). If `null` is given as
|
||||
source, this only configures the lint extension.
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return [
|
||||
lintConfig.of({ source, config }),
|
||||
lintPlugin,
|
||||
lintExtensions
|
||||
];
|
||||
}
|
||||
/**
|
||||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the
|
||||
editor is idle to run right away.
|
||||
*/
|
||||
function forceLinting(view) {
|
||||
let plugin = view.plugin(lintPlugin);
|
||||
if (plugin)
|
||||
plugin.force();
|
||||
}
|
||||
function assignKeys(actions) {
|
||||
let assigned = [];
|
||||
if (actions)
|
||||
actions: for (let { name } of actions) {
|
||||
for (let i = 0; i < name.length; i++) {
|
||||
let ch = name[i];
|
||||
if (/[a-zA-Z]/.test(ch) && !assigned.some(c => c.toLowerCase() == ch.toLowerCase())) {
|
||||
assigned.push(ch);
|
||||
continue actions;
|
||||
}
|
||||
}
|
||||
assigned.push("");
|
||||
}
|
||||
return assigned;
|
||||
}
|
||||
function renderDiagnostic(view, diagnostic, inPanel) {
|
||||
var _a;
|
||||
let keys = inPanel ? assignKeys(diagnostic.actions) : [];
|
||||
return elt("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage(view) : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
||||
let fired = false, click = (e) => {
|
||||
e.preventDefault();
|
||||
if (fired)
|
||||
return;
|
||||
fired = true;
|
||||
let found = findDiagnostic(view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
action.apply(view, found.from, found.to);
|
||||
};
|
||||
let { name } = action, keyIndex = keys[i] ? name.indexOf(keys[i]) : -1;
|
||||
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
||||
elt("u", name.slice(keyIndex, keyIndex + 1)),
|
||||
name.slice(keyIndex + 1)];
|
||||
return elt("button", {
|
||||
type: "button",
|
||||
class: "cm-diagnosticAction",
|
||||
onclick: click,
|
||||
onmousedown: click,
|
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
||||
}, nameElt);
|
||||
}), diagnostic.source && elt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
||||
}
|
||||
class DiagnosticWidget extends WidgetType {
|
||||
constructor(sev) {
|
||||
super();
|
||||
this.sev = sev;
|
||||
}
|
||||
eq(other) { return other.sev == this.sev; }
|
||||
toDOM() {
|
||||
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
|
||||
}
|
||||
}
|
||||
class PanelItem {
|
||||
constructor(view, diagnostic) {
|
||||
this.diagnostic = diagnostic;
|
||||
this.id = "item_" + Math.floor(Math.random() * 0xffffffff).toString(16);
|
||||
this.dom = renderDiagnostic(view, diagnostic, true);
|
||||
this.dom.id = this.id;
|
||||
this.dom.setAttribute("role", "option");
|
||||
}
|
||||
}
|
||||
class LintPanel {
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
this.items = [];
|
||||
let onkeydown = (event) => {
|
||||
if (event.keyCode == 27) { // Escape
|
||||
closeLintPanel(this.view);
|
||||
this.view.focus();
|
||||
}
|
||||
else if (event.keyCode == 38 || event.keyCode == 33) { // ArrowUp, PageUp
|
||||
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
||||
}
|
||||
else if (event.keyCode == 40 || event.keyCode == 34) { // ArrowDown, PageDown
|
||||
this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
||||
}
|
||||
else if (event.keyCode == 36) { // Home
|
||||
this.moveSelection(0);
|
||||
}
|
||||
else if (event.keyCode == 35) { // End
|
||||
this.moveSelection(this.items.length - 1);
|
||||
}
|
||||
else if (event.keyCode == 13) { // Enter
|
||||
this.view.focus();
|
||||
}
|
||||
else if (event.keyCode >= 65 && event.keyCode <= 90 && this.selectedIndex >= 0) { // A-Z
|
||||
let { diagnostic } = this.items[this.selectedIndex], keys = assignKeys(diagnostic.actions);
|
||||
for (let i = 0; i < keys.length; i++)
|
||||
if (keys[i].toUpperCase().charCodeAt(0) == event.keyCode) {
|
||||
let found = findDiagnostic(this.view.state.field(lintState).diagnostics, diagnostic);
|
||||
if (found)
|
||||
diagnostic.actions[i].apply(view, found.from, found.to);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
};
|
||||
let onclick = (event) => {
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
if (this.items[i].dom.contains(event.target))
|
||||
this.moveSelection(i);
|
||||
}
|
||||
};
|
||||
this.list = elt("ul", {
|
||||
tabIndex: 0,
|
||||
role: "listbox",
|
||||
"aria-label": this.view.state.phrase("Diagnostics"),
|
||||
onkeydown,
|
||||
onclick
|
||||
});
|
||||
this.dom = elt("div", { class: "cm-panel-lint" }, this.list, elt("button", {
|
||||
type: "button",
|
||||
name: "close",
|
||||
"aria-label": this.view.state.phrase("close"),
|
||||
onclick: () => closeLintPanel(this.view)
|
||||
}, "×"));
|
||||
this.update();
|
||||
}
|
||||
get selectedIndex() {
|
||||
let selected = this.view.state.field(lintState).selected;
|
||||
if (!selected)
|
||||
return -1;
|
||||
for (let i = 0; i < this.items.length; i++)
|
||||
if (this.items[i].diagnostic == selected.diagnostic)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
update() {
|
||||
let { diagnostics, selected } = this.view.state.field(lintState);
|
||||
let i = 0, needsSync = false, newSelectedItem = null;
|
||||
let seen = new Set();
|
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
||||
for (let diagnostic of spec.diagnostics) {
|
||||
if (seen.has(diagnostic))
|
||||
continue;
|
||||
seen.add(diagnostic);
|
||||
let found = -1, item;
|
||||
for (let j = i; j < this.items.length; j++)
|
||||
if (this.items[j].diagnostic == diagnostic) {
|
||||
found = j;
|
||||
break;
|
||||
}
|
||||
if (found < 0) {
|
||||
item = new PanelItem(this.view, diagnostic);
|
||||
this.items.splice(i, 0, item);
|
||||
needsSync = true;
|
||||
}
|
||||
else {
|
||||
item = this.items[found];
|
||||
if (found > i) {
|
||||
this.items.splice(i, found - i);
|
||||
needsSync = true;
|
||||
}
|
||||
}
|
||||
if (selected && item.diagnostic == selected.diagnostic) {
|
||||
if (!item.dom.hasAttribute("aria-selected")) {
|
||||
item.dom.setAttribute("aria-selected", "true");
|
||||
newSelectedItem = item;
|
||||
}
|
||||
}
|
||||
else if (item.dom.hasAttribute("aria-selected")) {
|
||||
item.dom.removeAttribute("aria-selected");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
});
|
||||
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
|
||||
needsSync = true;
|
||||
this.items.pop();
|
||||
}
|
||||
if (this.items.length == 0) {
|
||||
this.items.push(new PanelItem(this.view, {
|
||||
from: -1, to: -1,
|
||||
severity: "info",
|
||||
message: this.view.state.phrase("No diagnostics")
|
||||
}));
|
||||
needsSync = true;
|
||||
}
|
||||
if (newSelectedItem) {
|
||||
this.list.setAttribute("aria-activedescendant", newSelectedItem.id);
|
||||
this.view.requestMeasure({
|
||||
key: this,
|
||||
read: () => ({ sel: newSelectedItem.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
|
||||
write: ({ sel, panel }) => {
|
||||
let scaleY = panel.height / this.list.offsetHeight;
|
||||
if (sel.top < panel.top)
|
||||
this.list.scrollTop -= (panel.top - sel.top) / scaleY;
|
||||
else if (sel.bottom > panel.bottom)
|
||||
this.list.scrollTop += (sel.bottom - panel.bottom) / scaleY;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (this.selectedIndex < 0) {
|
||||
this.list.removeAttribute("aria-activedescendant");
|
||||
}
|
||||
if (needsSync)
|
||||
this.sync();
|
||||
}
|
||||
sync() {
|
||||
let domPos = this.list.firstChild;
|
||||
function rm() {
|
||||
let prev = domPos;
|
||||
domPos = prev.nextSibling;
|
||||
prev.remove();
|
||||
}
|
||||
for (let item of this.items) {
|
||||
if (item.dom.parentNode == this.list) {
|
||||
while (domPos != item.dom)
|
||||
rm();
|
||||
domPos = item.dom.nextSibling;
|
||||
}
|
||||
else {
|
||||
this.list.insertBefore(item.dom, domPos);
|
||||
}
|
||||
}
|
||||
while (domPos)
|
||||
rm();
|
||||
}
|
||||
moveSelection(selectedIndex) {
|
||||
if (this.selectedIndex < 0)
|
||||
return;
|
||||
let field = this.view.state.field(lintState);
|
||||
let selection = findDiagnostic(field.diagnostics, this.items[selectedIndex].diagnostic);
|
||||
if (!selection)
|
||||
return;
|
||||
this.view.dispatch({
|
||||
selection: { anchor: selection.from, head: selection.to },
|
||||
scrollIntoView: true,
|
||||
effects: movePanelSelection.of(selection)
|
||||
});
|
||||
}
|
||||
static open(view) { return new LintPanel(view); }
|
||||
}
|
||||
function svg(content, attrs = `viewBox="0 0 40 40"`) {
|
||||
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${attrs}>${encodeURIComponent(content)}</svg>')`;
|
||||
}
|
||||
function underline(color) {
|
||||
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${color}" fill="none" stroke-width=".7"/>`, `width="6" height="3"`);
|
||||
}
|
||||
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
||||
".cm-diagnostic": {
|
||||
padding: "3px 6px 3px 8px",
|
||||
marginLeft: "-1px",
|
||||
display: "block",
|
||||
whiteSpace: "pre-wrap"
|
||||
},
|
||||
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
||||
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
||||
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
||||
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
||||
".cm-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
padding: "2px 4px",
|
||||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px",
|
||||
cursor: "pointer"
|
||||
},
|
||||
".cm-diagnosticSource": {
|
||||
fontSize: "70%",
|
||||
opacity: .7
|
||||
},
|
||||
".cm-lintRange": {
|
||||
backgroundPosition: "left bottom",
|
||||
backgroundRepeat: "repeat-x",
|
||||
paddingBottom: "0.7px",
|
||||
},
|
||||
".cm-lintRange-error": { backgroundImage: /*@__PURE__*/underline("#d11") },
|
||||
".cm-lintRange-warning": { backgroundImage: /*@__PURE__*/underline("orange") },
|
||||
".cm-lintRange-info": { backgroundImage: /*@__PURE__*/underline("#999") },
|
||||
".cm-lintRange-hint": { backgroundImage: /*@__PURE__*/underline("#66d") },
|
||||
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
||||
".cm-tooltip-lint": {
|
||||
padding: 0,
|
||||
margin: 0
|
||||
},
|
||||
".cm-lintPoint": {
|
||||
position: "relative",
|
||||
"&:after": {
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
bottom: 0,
|
||||
left: "-2px",
|
||||
borderLeft: "3px solid transparent",
|
||||
borderRight: "3px solid transparent",
|
||||
borderBottom: "4px solid #d11"
|
||||
}
|
||||
},
|
||||
".cm-lintPoint-warning": {
|
||||
"&:after": { borderBottomColor: "orange" }
|
||||
},
|
||||
".cm-lintPoint-info": {
|
||||
"&:after": { borderBottomColor: "#999" }
|
||||
},
|
||||
".cm-lintPoint-hint": {
|
||||
"&:after": { borderBottomColor: "#66d" }
|
||||
},
|
||||
".cm-panel.cm-panel-lint": {
|
||||
position: "relative",
|
||||
"& ul": {
|
||||
maxHeight: "100px",
|
||||
overflowY: "auto",
|
||||
"& [aria-selected]": {
|
||||
backgroundColor: "#ddd",
|
||||
"& u": { textDecoration: "underline" }
|
||||
},
|
||||
"&:focus [aria-selected]": {
|
||||
background_fallback: "#bdf",
|
||||
backgroundColor: "Highlight",
|
||||
color_fallback: "white",
|
||||
color: "HighlightText"
|
||||
},
|
||||
"& u": { textDecoration: "none" },
|
||||
padding: 0,
|
||||
margin: 0
|
||||
},
|
||||
"& [name=close]": {
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
right: "2px",
|
||||
background: "inherit",
|
||||
border: "none",
|
||||
font: "inherit",
|
||||
padding: 0,
|
||||
margin: 0
|
||||
}
|
||||
}
|
||||
});
|
||||
function severityWeight(sev) {
|
||||
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
||||
}
|
||||
function maxSeverity(diagnostics) {
|
||||
let sev = "hint", weight = 1;
|
||||
for (let d of diagnostics) {
|
||||
let w = severityWeight(d.severity);
|
||||
if (w > weight) {
|
||||
weight = w;
|
||||
sev = d.severity;
|
||||
}
|
||||
}
|
||||
return sev;
|
||||
}
|
||||
class LintGutterMarker extends GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = maxSeverity(diagnostics);
|
||||
}
|
||||
toDOM(view) {
|
||||
let elt = document.createElement("div");
|
||||
elt.className = "cm-lint-marker cm-lint-marker-" + this.severity;
|
||||
let diagnostics = this.diagnostics;
|
||||
let diagnosticsFilter = view.state.facet(lintGutterConfig).tooltipFilter;
|
||||
if (diagnosticsFilter)
|
||||
diagnostics = diagnosticsFilter(diagnostics, view.state);
|
||||
if (diagnostics.length)
|
||||
elt.onmouseover = () => gutterMarkerMouseOver(view, elt, diagnostics);
|
||||
return elt;
|
||||
}
|
||||
}
|
||||
function trackHoverOn(view, marker) {
|
||||
let mousemove = (event) => {
|
||||
let rect = marker.getBoundingClientRect();
|
||||
if (event.clientX > rect.left - 10 /* Hover.Margin */ && event.clientX < rect.right + 10 /* Hover.Margin */ &&
|
||||
event.clientY > rect.top - 10 /* Hover.Margin */ && event.clientY < rect.bottom + 10 /* Hover.Margin */)
|
||||
return;
|
||||
for (let target = event.target; target; target = target.parentNode) {
|
||||
if (target.nodeType == 1 && target.classList.contains("cm-tooltip-lint"))
|
||||
return;
|
||||
}
|
||||
window.removeEventListener("mousemove", mousemove);
|
||||
if (view.state.field(lintGutterTooltip))
|
||||
view.dispatch({ effects: setLintGutterTooltip.of(null) });
|
||||
};
|
||||
window.addEventListener("mousemove", mousemove);
|
||||
}
|
||||
function gutterMarkerMouseOver(view, marker, diagnostics) {
|
||||
function hovered() {
|
||||
let line = view.elementAtHeight(marker.getBoundingClientRect().top + 5 - view.documentTop);
|
||||
const linePos = view.coordsAtPos(line.from);
|
||||
if (linePos) {
|
||||
view.dispatch({ effects: setLintGutterTooltip.of({
|
||||
pos: line.from,
|
||||
above: false,
|
||||
clip: false,
|
||||
create() {
|
||||
return {
|
||||
dom: diagnosticsTooltip(view, diagnostics),
|
||||
getCoords: () => marker.getBoundingClientRect()
|
||||
};
|
||||
}
|
||||
}) });
|
||||
}
|
||||
marker.onmouseout = marker.onmousemove = null;
|
||||
trackHoverOn(view, marker);
|
||||
}
|
||||
let { hoverTime } = view.state.facet(lintGutterConfig);
|
||||
let hoverTimeout = setTimeout(hovered, hoverTime);
|
||||
marker.onmouseout = () => {
|
||||
clearTimeout(hoverTimeout);
|
||||
marker.onmouseout = marker.onmousemove = null;
|
||||
};
|
||||
marker.onmousemove = () => {
|
||||
clearTimeout(hoverTimeout);
|
||||
hoverTimeout = setTimeout(hovered, hoverTime);
|
||||
};
|
||||
}
|
||||
function markersForDiagnostics(doc, diagnostics) {
|
||||
let byLine = Object.create(null);
|
||||
for (let diagnostic of diagnostics) {
|
||||
let line = doc.lineAt(diagnostic.from);
|
||||
(byLine[line.from] || (byLine[line.from] = [])).push(diagnostic);
|
||||
}
|
||||
let markers = [];
|
||||
for (let line in byLine) {
|
||||
markers.push(new LintGutterMarker(byLine[line]).range(+line));
|
||||
}
|
||||
return RangeSet.of(markers, true);
|
||||
}
|
||||
const lintGutterExtension = /*@__PURE__*/gutter({
|
||||
class: "cm-gutter-lint",
|
||||
markers: view => view.state.field(lintGutterMarkers),
|
||||
widgetMarker: (view, widget, block) => {
|
||||
let diagnostics = [];
|
||||
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
|
||||
if (from > block.from && from < block.to)
|
||||
diagnostics.push(...value.diagnostics);
|
||||
});
|
||||
return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
|
||||
}
|
||||
});
|
||||
const lintGutterMarkers = /*@__PURE__*/StateField.define({
|
||||
create() {
|
||||
return RangeSet.empty;
|
||||
},
|
||||
update(markers, tr) {
|
||||
markers = markers.map(tr.changes);
|
||||
let diagnosticFilter = tr.state.facet(lintGutterConfig).markerFilter;
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
let diagnostics = effect.value;
|
||||
if (diagnosticFilter)
|
||||
diagnostics = diagnosticFilter(diagnostics || [], tr.state);
|
||||
markers = markersForDiagnostics(tr.state.doc, diagnostics.slice(0));
|
||||
}
|
||||
}
|
||||
return markers;
|
||||
}
|
||||
});
|
||||
const setLintGutterTooltip = /*@__PURE__*/StateEffect.define();
|
||||
const lintGutterTooltip = /*@__PURE__*/StateField.define({
|
||||
create() { return null; },
|
||||
update(tooltip, tr) {
|
||||
if (tooltip && tr.docChanged)
|
||||
tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
||||
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
||||
},
|
||||
provide: field => showTooltip.from(field)
|
||||
});
|
||||
const lintGutterTheme = /*@__PURE__*/EditorView.baseTheme({
|
||||
".cm-gutter-lint": {
|
||||
width: "1.4em",
|
||||
"& .cm-gutterElement": {
|
||||
padding: ".2em"
|
||||
}
|
||||
},
|
||||
".cm-lint-marker": {
|
||||
width: "1em",
|
||||
height: "1em"
|
||||
},
|
||||
".cm-lint-marker-info": {
|
||||
content: /*@__PURE__*/svg(`<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>`)
|
||||
},
|
||||
".cm-lint-marker-warning": {
|
||||
content: /*@__PURE__*/svg(`<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>`),
|
||||
},
|
||||
".cm-lint-marker-error": {
|
||||
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintExtensions = [
|
||||
lintState,
|
||||
/*@__PURE__*/EditorView.decorations.compute([lintState], state => {
|
||||
let { selected, panel } = state.field(lintState);
|
||||
return !selected || !panel || selected.from == selected.to ? Decoration.none : Decoration.set([
|
||||
activeMark.range(selected.from, selected.to)
|
||||
]);
|
||||
}),
|
||||
/*@__PURE__*/hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
];
|
||||
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
||||
combine(configs) {
|
||||
return combineConfig(configs, {
|
||||
hoverTime: 300 /* Hover.Time */,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
});
|
||||
}
|
||||
});
|
||||
/**
|
||||
Returns an extension that installs a gutter showing markers for
|
||||
each line that has diagnostics, which can be hovered over to see
|
||||
the diagnostics.
|
||||
*/
|
||||
function lintGutter(config = {}) {
|
||||
return [lintGutterConfig.of(config), lintGutterMarkers, lintGutterExtension, lintGutterTheme, lintGutterTooltip];
|
||||
}
|
||||
/**
|
||||
Iterate over the marked diagnostics for the given editor state,
|
||||
calling `f` for each of them. Note that, if the document changed
|
||||
since the diagnostics were created, the `Diagnostic` object will
|
||||
hold the original outdated position, whereas the `to` and `from`
|
||||
arguments hold the diagnostic's current position.
|
||||
*/
|
||||
function forEachDiagnostic(state, f) {
|
||||
let lState = state.field(lintState, false);
|
||||
if (lState && lState.diagnostics.size) {
|
||||
let pending = [], pendingStart = [], lastEnd = -1;
|
||||
for (let iter = RangeSet.iter([lState.diagnostics]);; iter.next()) {
|
||||
for (let i = 0; i < pending.length; i++)
|
||||
if (!iter.value || iter.value.spec.diagnostics.indexOf(pending[i]) < 0) {
|
||||
f(pending[i], pendingStart[i], lastEnd);
|
||||
pending.splice(i, 1);
|
||||
pendingStart.splice(i--, 1);
|
||||
}
|
||||
if (!iter.value)
|
||||
break;
|
||||
for (let d of iter.value.spec.diagnostics)
|
||||
if (pending.indexOf(d) < 0) {
|
||||
pending.push(d);
|
||||
pendingStart.push(iter.from);
|
||||
}
|
||||
lastEnd = iter.to;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
||||
40
node_modules/@codemirror/lint/package.json
generated
vendored
Normal file
40
node_modules/@codemirror/lint/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@codemirror/lint",
|
||||
"version": "6.8.4",
|
||||
"description": "Linting support for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/lint.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.35.0",
|
||||
"crelt": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lint.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/search/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/search/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
312
node_modules/@codemirror/search/CHANGELOG.md
generated
vendored
Normal file
312
node_modules/@codemirror/search/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,312 @@
|
||||
## 6.5.10 (2025-02-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add a close button to the `gotoLine` panel.
|
||||
|
||||
## 6.5.9 (2025-02-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When replacing a regexp match, don't expand multi-digit replacement markers to numbers beyond the captured group count in the query.
|
||||
|
||||
## 6.5.8 (2024-11-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that put the selection in the wrong place after running `replaceNext` with a regexp query that could match strings of different length.
|
||||
|
||||
## 6.5.7 (2024-11-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `findNext` and `findPrevious` would do nothing when the only match in the document was partially selected.
|
||||
|
||||
Fix an infinite loop in `SearchCursor` when the normalizer function deletes characters.
|
||||
|
||||
## 6.5.6 (2024-02-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `highlightSelectionMatches` include whitespace in the selection in its matches.
|
||||
|
||||
Fix a bug that caused `SearchCursor` to return invalid ranges when matching astral chars that the the normalizer normalized to single-code-unit chars.
|
||||
|
||||
## 6.5.5 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused codes like `\n` to be unescaped in strings inserted via replace placeholders like `$&`.
|
||||
|
||||
Use the keybinding Mod-Alt-g for `gotoLine` to the search keymap, to make it usable for people whose keyboard layout uses Alt/Option-g to type some character.
|
||||
|
||||
## 6.5.4 (2023-09-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused whole-word search to incorrectly check for word boundaries in some circumstances.
|
||||
|
||||
## 6.5.3 (2023-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `gotoLine` dialog is now populated with the current line number when you open it.
|
||||
|
||||
## 6.5.2 (2023-08-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't use the very lowest precedence for match highlighting decorations.
|
||||
|
||||
## 6.5.1 (2023-08-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `gotoLine` prefer to scroll the target line to the middle of the view.
|
||||
|
||||
Fix an issue in `SearchCursor` where character normalization could produce nonsensical matches.
|
||||
|
||||
## 6.5.0 (2023-06-05)
|
||||
|
||||
### New features
|
||||
|
||||
The new `regexp` option to `search` can be used to control whether queries have the regexp flag on by default.
|
||||
|
||||
## 6.4.0 (2023-04-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `findNext` and `findPrevious` commands now select the search field text if that field is focused.
|
||||
|
||||
### New features
|
||||
|
||||
The `scrollToMatch` callback option now receives the editor view as a second parameter.
|
||||
|
||||
## 6.3.0 (2023-03-20)
|
||||
|
||||
### New features
|
||||
|
||||
The new `scrollToMatch` search option allows you to adjust the way the editor scrolls search matches into view.
|
||||
|
||||
## 6.2.3 (2022-11-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that hid the search dialog's close button when the editor was read-only.
|
||||
|
||||
## 6.2.2 (2022-10-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When `literal` is off, \n, \r, and \t escapes are now also supported in replacement text.
|
||||
|
||||
Make sure search dialog inputs don't get treated as form fields when the editor is created inside a form.
|
||||
|
||||
Fix a bug in `RegExpCursor` that would cause it to stop matching in the middle of a line when its current match position was equal to the length of the line.
|
||||
|
||||
## 6.2.1 (2022-09-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
By-word search queries will now skip any result that had word characters both before and after a match boundary.
|
||||
|
||||
## 6.2.0 (2022-08-25)
|
||||
|
||||
### New features
|
||||
|
||||
A new `wholeWord` search query flag can be used to limit matches to whole words.
|
||||
|
||||
`SearchCursor` and `RegExpCursor` now support a `test` parameter that can be used to ignore certain matches.
|
||||
|
||||
## 6.1.0 (2022-08-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an infinite loop when the match position of a `RegExpCursor` ended up in the middle of an UTF16 surrogate pair.
|
||||
|
||||
### New features
|
||||
|
||||
The `literal` search option can now be set to make literal queries the default.
|
||||
|
||||
The new `searchPanelOpen` function can be used to find out whether the search panel is open for a given state.
|
||||
|
||||
## 6.0.1 (2022-07-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`findNext` and `findPrevious` will now return to the current result (and scroll it into view) if no other matches are found.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't crash when a custom search panel doesn't have a field named 'search'.
|
||||
|
||||
Make sure replacements are announced to screen readers.
|
||||
|
||||
## 0.20.1 (2022-04-22)
|
||||
|
||||
### New features
|
||||
|
||||
It is now possible to disable backslash escapes in search queries with the `literal` option.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make the `wholeWords` option to `highlightSelectionMatches` default to false, as intended.
|
||||
|
||||
## 0.19.10 (2022-04-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure search matches are highlighted when scrolling new content into view.
|
||||
|
||||
## 0.19.9 (2022-03-03)
|
||||
|
||||
### New features
|
||||
|
||||
The selection-matching extension now accepts a `wholeWords` option that makes it only highlight matches that span a whole word. Add SearchQuery.getCursor
|
||||
|
||||
The `SearchQuery` class now has a `getCursor` method that allows external code to create a cursor for the query.
|
||||
|
||||
## 0.19.8 (2022-02-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused the search panel to start open when configuring a state with the `search()` extension.
|
||||
|
||||
## 0.19.7 (2022-02-14)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`searchConfig` is deprecated in favor of `search` (but will exist until next major release).
|
||||
|
||||
### New features
|
||||
|
||||
The new `search` function is now used to enable and configure the search extension.
|
||||
|
||||
## 0.19.6 (2022-01-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `selectNextOccurrence` scroll the newly selected range into view.
|
||||
|
||||
## 0.19.5 (2021-12-16)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The search option `matchCase` was renamed to `caseSensitive` (the old name will continue to work until the next breaking release).
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`openSearchPanel` will now update the search query to the current selection even if the panel was already open.
|
||||
|
||||
### New features
|
||||
|
||||
Client code can now pass a custom search panel creation function in the search configuration.
|
||||
|
||||
The `getSearchQuery` function and `setSearchQuery` effect can now be used to inspect or change the current search query.
|
||||
|
||||
## 0.19.4 (2021-12-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The search panel will no longer show the replace interface when the editor is read-only.
|
||||
|
||||
## 0.19.3 (2021-11-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add `userEvent` annotations to search and replace transactions.
|
||||
|
||||
Make sure the editor handles keys bound to `findNext`/`findPrevious` even when there are no matches, to avoid the browser's search interrupting users.
|
||||
|
||||
### New features
|
||||
|
||||
Add a `Symbol.iterator` property to the cursor types, so that they can be used with `for`/`of`.
|
||||
|
||||
## 0.19.2 (2021-09-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`selectNextOccurrence` will now only select partial words if the current main selection hold a partial word.
|
||||
|
||||
Explicitly set the button's type to prevent the browser from submitting forms wrapped around the editor.
|
||||
|
||||
## 0.19.1 (2021-09-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `highlightSelectionMatches` not produce overlapping decorations, since those tend to just get unreadable.
|
||||
|
||||
Make sure any existing search text is selected when opening the search panel. Add search config option to not match case when search panel is opened (#4)
|
||||
|
||||
### New features
|
||||
|
||||
The `searchConfig` function now takes a `matchCase` option that controls whether the search panel starts in case-sensitive mode.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure to prevent the native Mod-d behavior so that the editor doesn't lose focus after selecting past the last occurrence.
|
||||
|
||||
## 0.18.4 (2021-05-27)
|
||||
|
||||
### New features
|
||||
|
||||
Initialize the search query to the current selection, when there is one, when opening the search dialog.
|
||||
|
||||
Add a `searchConfig` function, supporting an option to put the search panel at the top of the editor.
|
||||
|
||||
## 0.18.3 (2021-05-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where the first search command in a new editor wouldn't properly open the panel.
|
||||
|
||||
### New features
|
||||
|
||||
New command `selectNextOccurrence` that selects the next occurrence of the selected word (bound to Mod-d in the search keymap).
|
||||
|
||||
## 0.18.2 (2021-03-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The search interface and cursor will no longer include overlapping matches (aligning with what all other editors are doing).
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a `RegExpCursor` which is a search cursor that matches regular expression patterns.
|
||||
|
||||
The search/replace interface now allows the user to use regular expressions.
|
||||
|
||||
The `SearchCursor` class now has a `nextOverlapping` method that includes matches that start inside the previous match.
|
||||
|
||||
Basic backslash escapes (\n, \r, \t, and \\) are now accepted in string search patterns in the UI.
|
||||
|
||||
## 0.18.1 (2021-03-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where entering an invalid input in the goto-line dialog would submit a form and reload the page.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 0.18.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
21
node_modules/@codemirror/search/LICENSE
generated
vendored
Normal file
21
node_modules/@codemirror/search/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
18
node_modules/@codemirror/search/README.md
generated
vendored
Normal file
18
node_modules/@codemirror/search/README.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# @codemirror/search [](https://www.npmjs.org/package/@codemirror/search)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/) | [**DOCS**](https://codemirror.net/docs/ref/#search) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/search/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements search functionality for the
|
||||
[CodeMirror](https://codemirror.net/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/) has more information, a
|
||||
number of [examples](https://codemirror.net/examples/) and the
|
||||
[documentation](https://codemirror.net/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/search/tree/main/LICENSE).
|
||||
|
||||
We aim to be an inclusive, welcoming community. To make that explicit,
|
||||
we have a [code of
|
||||
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
||||
to communication around the project.
|
||||
1271
node_modules/@codemirror/search/dist/index.cjs
generated
vendored
Normal file
1271
node_modules/@codemirror/search/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
375
node_modules/@codemirror/search/dist/index.d.cts
generated
vendored
Normal file
375
node_modules/@codemirror/search/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,375 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Text, Extension, StateCommand, EditorState, SelectionRange, StateEffect } from '@codemirror/state';
|
||||
import { Command, KeyBinding, EditorView, Panel } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A search cursor provides an iterator over text matches in a
|
||||
document.
|
||||
*/
|
||||
declare class SearchCursor implements Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}> {
|
||||
private test?;
|
||||
private iter;
|
||||
/**
|
||||
The current match (only holds a meaningful value after
|
||||
[`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
|
||||
`done` is false).
|
||||
*/
|
||||
value: {
|
||||
from: number;
|
||||
to: number;
|
||||
};
|
||||
/**
|
||||
Whether the end of the iterated region has been reached.
|
||||
*/
|
||||
done: boolean;
|
||||
private matches;
|
||||
private buffer;
|
||||
private bufferPos;
|
||||
private bufferStart;
|
||||
private normalize;
|
||||
private query;
|
||||
/**
|
||||
Create a text cursor. The query is the search string, `from` to
|
||||
`to` provides the region to search.
|
||||
|
||||
When `normalize` is given, it will be called, on both the query
|
||||
string and the content it is matched against, before comparing.
|
||||
You can, for example, create a case-insensitive search by
|
||||
passing `s => s.toLowerCase()`.
|
||||
|
||||
Text is always normalized with
|
||||
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
||||
(when supported).
|
||||
*/
|
||||
constructor(text: Text, query: string, from?: number, to?: number, normalize?: (string: string) => string, test?: ((from: number, to: number, buffer: string, bufferPos: number) => boolean) | undefined);
|
||||
private peek;
|
||||
/**
|
||||
Look for the next match. Updates the iterator's
|
||||
[`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
|
||||
[`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
|
||||
at least once before using the cursor.
|
||||
*/
|
||||
next(): this;
|
||||
/**
|
||||
The `next` method will ignore matches that partially overlap a
|
||||
previous match. This method behaves like `next`, but includes
|
||||
such matches.
|
||||
*/
|
||||
nextOverlapping(): this;
|
||||
private match;
|
||||
[Symbol.iterator]: () => Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface RegExpCursorOptions {
|
||||
ignoreCase?: boolean;
|
||||
test?: (from: number, to: number, match: RegExpExecArray) => boolean;
|
||||
}
|
||||
/**
|
||||
This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
|
||||
but searches for a regular expression pattern instead of a plain
|
||||
string.
|
||||
*/
|
||||
declare class RegExpCursor implements Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
}> {
|
||||
private text;
|
||||
private to;
|
||||
private iter;
|
||||
private re;
|
||||
private test?;
|
||||
private curLine;
|
||||
private curLineStart;
|
||||
private matchPos;
|
||||
/**
|
||||
Set to `true` when the cursor has reached the end of the search
|
||||
range.
|
||||
*/
|
||||
done: boolean;
|
||||
/**
|
||||
Will contain an object with the extent of the match and the
|
||||
match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
|
||||
sucessfully finds a match.
|
||||
*/
|
||||
value: {
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
};
|
||||
/**
|
||||
Create a cursor that will search the given range in the given
|
||||
document. `query` should be the raw pattern (as you'd pass it to
|
||||
`new RegExp`).
|
||||
*/
|
||||
constructor(text: Text, query: string, options?: RegExpCursorOptions, from?: number, to?: number);
|
||||
private getLine;
|
||||
private nextLine;
|
||||
/**
|
||||
Move to the next match, if there is one.
|
||||
*/
|
||||
next(): this;
|
||||
[Symbol.iterator]: () => Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
Command that shows a dialog asking the user for a line number, and
|
||||
when a valid position is provided, moves the cursor to that line.
|
||||
|
||||
Supports line numbers, relative line offsets prefixed with `+` or
|
||||
`-`, document percentages suffixed with `%`, and an optional
|
||||
column position by adding `:` and a second number after the line
|
||||
number.
|
||||
*/
|
||||
declare const gotoLine: Command;
|
||||
|
||||
type HighlightOptions = {
|
||||
/**
|
||||
Determines whether, when nothing is selected, the word around
|
||||
the cursor is matched instead. Defaults to false.
|
||||
*/
|
||||
highlightWordAroundCursor?: boolean;
|
||||
/**
|
||||
The minimum length of the selection before it is highlighted.
|
||||
Defaults to 1 (always highlight non-cursor selections).
|
||||
*/
|
||||
minSelectionLength?: number;
|
||||
/**
|
||||
The amount of matches (in the viewport) at which to disable
|
||||
highlighting. Defaults to 100.
|
||||
*/
|
||||
maxMatches?: number;
|
||||
/**
|
||||
Whether to only highlight whole words.
|
||||
*/
|
||||
wholeWords?: boolean;
|
||||
};
|
||||
/**
|
||||
This extension highlights text that matches the selection. It uses
|
||||
the `"cm-selectionMatch"` class for the highlighting. When
|
||||
`highlightWordAroundCursor` is enabled, the word at the cursor
|
||||
itself will be highlighted with `"cm-selectionMatch-main"`.
|
||||
*/
|
||||
declare function highlightSelectionMatches(options?: HighlightOptions): Extension;
|
||||
/**
|
||||
Select next occurrence of the current selection. Expand selection
|
||||
to the surrounding word when the selection is empty.
|
||||
*/
|
||||
declare const selectNextOccurrence: StateCommand;
|
||||
|
||||
interface SearchConfig {
|
||||
/**
|
||||
Whether to position the search panel at the top of the editor
|
||||
(the default is at the bottom).
|
||||
*/
|
||||
top?: boolean;
|
||||
/**
|
||||
Whether to enable case sensitivity by default when the search
|
||||
panel is activated (defaults to false).
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
Whether to treat string searches literally by default (defaults to false).
|
||||
*/
|
||||
literal?: boolean;
|
||||
/**
|
||||
Controls whether the default query has by-word matching enabled.
|
||||
Defaults to false.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
/**
|
||||
Used to turn on regular expression search in the default query.
|
||||
Defaults to false.
|
||||
*/
|
||||
regexp?: boolean;
|
||||
/**
|
||||
Can be used to override the way the search panel is implemented.
|
||||
Should create a [Panel](https://codemirror.net/6/docs/ref/#view.Panel) that contains a form
|
||||
which lets the user:
|
||||
|
||||
- See the [current](https://codemirror.net/6/docs/ref/#search.getSearchQuery) search query.
|
||||
- Manipulate the [query](https://codemirror.net/6/docs/ref/#search.SearchQuery) and
|
||||
[update](https://codemirror.net/6/docs/ref/#search.setSearchQuery) the search state with a new
|
||||
query.
|
||||
- Notice external changes to the query by reacting to the
|
||||
appropriate [state effect](https://codemirror.net/6/docs/ref/#search.setSearchQuery).
|
||||
- Run some of the search commands.
|
||||
|
||||
The field that should be focused when opening the panel must be
|
||||
tagged with a `main-field=true` DOM attribute.
|
||||
*/
|
||||
createPanel?: (view: EditorView) => Panel;
|
||||
/**
|
||||
By default, matches are scrolled into view using the default
|
||||
behavior of
|
||||
[`EditorView.scrollIntoView`](https://codemirror.net/6/docs/ref/#view.EditorView^scrollIntoView).
|
||||
This option allows you to pass a custom function to produce the
|
||||
scroll effect.
|
||||
*/
|
||||
scrollToMatch?: (range: SelectionRange, view: EditorView) => StateEffect<unknown>;
|
||||
}
|
||||
/**
|
||||
Add search state to the editor configuration, and optionally
|
||||
configure the search extension.
|
||||
([`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) will automatically
|
||||
enable this if it isn't already on).
|
||||
*/
|
||||
declare function search(config?: SearchConfig): Extension;
|
||||
/**
|
||||
A search query. Part of the editor's search state.
|
||||
*/
|
||||
declare class SearchQuery {
|
||||
/**
|
||||
The search string (or regular expression).
|
||||
*/
|
||||
readonly search: string;
|
||||
/**
|
||||
Indicates whether the search is case-sensitive.
|
||||
*/
|
||||
readonly caseSensitive: boolean;
|
||||
/**
|
||||
By default, string search will replace `\n`, `\r`, and `\t` in
|
||||
the query with newline, return, and tab characters. When this
|
||||
is set to true, that behavior is disabled.
|
||||
*/
|
||||
readonly literal: boolean;
|
||||
/**
|
||||
When true, the search string is interpreted as a regular
|
||||
expression.
|
||||
*/
|
||||
readonly regexp: boolean;
|
||||
/**
|
||||
The replace text, or the empty string if no replace text has
|
||||
been given.
|
||||
*/
|
||||
readonly replace: string;
|
||||
/**
|
||||
Whether this query is non-empty and, in case of a regular
|
||||
expression search, syntactically valid.
|
||||
*/
|
||||
readonly valid: boolean;
|
||||
/**
|
||||
When true, matches that contain words are ignored when there are
|
||||
further word characters around them.
|
||||
*/
|
||||
readonly wholeWord: boolean;
|
||||
/**
|
||||
Create a query object.
|
||||
*/
|
||||
constructor(config: {
|
||||
/**
|
||||
The search string.
|
||||
*/
|
||||
search: string;
|
||||
/**
|
||||
Controls whether the search should be case-sensitive.
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
By default, string search will replace `\n`, `\r`, and `\t` in
|
||||
the query with newline, return, and tab characters. When this
|
||||
is set to true, that behavior is disabled.
|
||||
*/
|
||||
literal?: boolean;
|
||||
/**
|
||||
When true, interpret the search string as a regular expression.
|
||||
*/
|
||||
regexp?: boolean;
|
||||
/**
|
||||
The replace text.
|
||||
*/
|
||||
replace?: string;
|
||||
/**
|
||||
Enable whole-word matching.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
});
|
||||
/**
|
||||
Compare this query to another query.
|
||||
*/
|
||||
eq(other: SearchQuery): boolean;
|
||||
/**
|
||||
Get a search cursor for this query, searching through the given
|
||||
range in the given state.
|
||||
*/
|
||||
getCursor(state: EditorState | Text, from?: number, to?: number): Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
A state effect that updates the current search query. Note that
|
||||
this only has an effect if the search state has been initialized
|
||||
(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
|
||||
by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
|
||||
once).
|
||||
*/
|
||||
declare const setSearchQuery: _codemirror_state.StateEffectType<SearchQuery>;
|
||||
/**
|
||||
Get the current search query from an editor state.
|
||||
*/
|
||||
declare function getSearchQuery(state: EditorState): SearchQuery;
|
||||
/**
|
||||
Query whether the search panel is open in the given editor state.
|
||||
*/
|
||||
declare function searchPanelOpen(state: EditorState): boolean;
|
||||
/**
|
||||
Open the search panel if it isn't already open, and move the
|
||||
selection to the first match after the current main selection.
|
||||
Will wrap around to the start of the document when it reaches the
|
||||
end.
|
||||
*/
|
||||
declare const findNext: Command;
|
||||
/**
|
||||
Move the selection to the previous instance of the search query,
|
||||
before the current main selection. Will wrap past the start
|
||||
of the document to start searching at the end again.
|
||||
*/
|
||||
declare const findPrevious: Command;
|
||||
/**
|
||||
Select all instances of the search query.
|
||||
*/
|
||||
declare const selectMatches: Command;
|
||||
/**
|
||||
Select all instances of the currently selected text.
|
||||
*/
|
||||
declare const selectSelectionMatches: StateCommand;
|
||||
/**
|
||||
Replace the current match of the search query.
|
||||
*/
|
||||
declare const replaceNext: Command;
|
||||
/**
|
||||
Replace all instances of the search query with the given
|
||||
replacement.
|
||||
*/
|
||||
declare const replaceAll: Command;
|
||||
/**
|
||||
Make sure the search panel is open and focused.
|
||||
*/
|
||||
declare const openSearchPanel: Command;
|
||||
/**
|
||||
Close the search panel.
|
||||
*/
|
||||
declare const closeSearchPanel: Command;
|
||||
/**
|
||||
Default search-related key bindings.
|
||||
|
||||
- Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
|
||||
- F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
|
||||
- Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
|
||||
- Mod-Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
|
||||
- Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
|
||||
*/
|
||||
declare const searchKeymap: readonly KeyBinding[];
|
||||
|
||||
export { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
||||
375
node_modules/@codemirror/search/dist/index.d.ts
generated
vendored
Normal file
375
node_modules/@codemirror/search/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,375 @@
|
||||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Text, Extension, StateCommand, EditorState, SelectionRange, StateEffect } from '@codemirror/state';
|
||||
import { Command, KeyBinding, EditorView, Panel } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
A search cursor provides an iterator over text matches in a
|
||||
document.
|
||||
*/
|
||||
declare class SearchCursor implements Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}> {
|
||||
private test?;
|
||||
private iter;
|
||||
/**
|
||||
The current match (only holds a meaningful value after
|
||||
[`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when
|
||||
`done` is false).
|
||||
*/
|
||||
value: {
|
||||
from: number;
|
||||
to: number;
|
||||
};
|
||||
/**
|
||||
Whether the end of the iterated region has been reached.
|
||||
*/
|
||||
done: boolean;
|
||||
private matches;
|
||||
private buffer;
|
||||
private bufferPos;
|
||||
private bufferStart;
|
||||
private normalize;
|
||||
private query;
|
||||
/**
|
||||
Create a text cursor. The query is the search string, `from` to
|
||||
`to` provides the region to search.
|
||||
|
||||
When `normalize` is given, it will be called, on both the query
|
||||
string and the content it is matched against, before comparing.
|
||||
You can, for example, create a case-insensitive search by
|
||||
passing `s => s.toLowerCase()`.
|
||||
|
||||
Text is always normalized with
|
||||
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
||||
(when supported).
|
||||
*/
|
||||
constructor(text: Text, query: string, from?: number, to?: number, normalize?: (string: string) => string, test?: ((from: number, to: number, buffer: string, bufferPos: number) => boolean) | undefined);
|
||||
private peek;
|
||||
/**
|
||||
Look for the next match. Updates the iterator's
|
||||
[`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
|
||||
[`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
|
||||
at least once before using the cursor.
|
||||
*/
|
||||
next(): this;
|
||||
/**
|
||||
The `next` method will ignore matches that partially overlap a
|
||||
previous match. This method behaves like `next`, but includes
|
||||
such matches.
|
||||
*/
|
||||
nextOverlapping(): this;
|
||||
private match;
|
||||
[Symbol.iterator]: () => Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface RegExpCursorOptions {
|
||||
ignoreCase?: boolean;
|
||||
test?: (from: number, to: number, match: RegExpExecArray) => boolean;
|
||||
}
|
||||
/**
|
||||
This class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)
|
||||
but searches for a regular expression pattern instead of a plain
|
||||
string.
|
||||
*/
|
||||
declare class RegExpCursor implements Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
}> {
|
||||
private text;
|
||||
private to;
|
||||
private iter;
|
||||
private re;
|
||||
private test?;
|
||||
private curLine;
|
||||
private curLineStart;
|
||||
private matchPos;
|
||||
/**
|
||||
Set to `true` when the cursor has reached the end of the search
|
||||
range.
|
||||
*/
|
||||
done: boolean;
|
||||
/**
|
||||
Will contain an object with the extent of the match and the
|
||||
match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)
|
||||
sucessfully finds a match.
|
||||
*/
|
||||
value: {
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
};
|
||||
/**
|
||||
Create a cursor that will search the given range in the given
|
||||
document. `query` should be the raw pattern (as you'd pass it to
|
||||
`new RegExp`).
|
||||
*/
|
||||
constructor(text: Text, query: string, options?: RegExpCursorOptions, from?: number, to?: number);
|
||||
private getLine;
|
||||
private nextLine;
|
||||
/**
|
||||
Move to the next match, if there is one.
|
||||
*/
|
||||
next(): this;
|
||||
[Symbol.iterator]: () => Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
match: RegExpExecArray;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
Command that shows a dialog asking the user for a line number, and
|
||||
when a valid position is provided, moves the cursor to that line.
|
||||
|
||||
Supports line numbers, relative line offsets prefixed with `+` or
|
||||
`-`, document percentages suffixed with `%`, and an optional
|
||||
column position by adding `:` and a second number after the line
|
||||
number.
|
||||
*/
|
||||
declare const gotoLine: Command;
|
||||
|
||||
type HighlightOptions = {
|
||||
/**
|
||||
Determines whether, when nothing is selected, the word around
|
||||
the cursor is matched instead. Defaults to false.
|
||||
*/
|
||||
highlightWordAroundCursor?: boolean;
|
||||
/**
|
||||
The minimum length of the selection before it is highlighted.
|
||||
Defaults to 1 (always highlight non-cursor selections).
|
||||
*/
|
||||
minSelectionLength?: number;
|
||||
/**
|
||||
The amount of matches (in the viewport) at which to disable
|
||||
highlighting. Defaults to 100.
|
||||
*/
|
||||
maxMatches?: number;
|
||||
/**
|
||||
Whether to only highlight whole words.
|
||||
*/
|
||||
wholeWords?: boolean;
|
||||
};
|
||||
/**
|
||||
This extension highlights text that matches the selection. It uses
|
||||
the `"cm-selectionMatch"` class for the highlighting. When
|
||||
`highlightWordAroundCursor` is enabled, the word at the cursor
|
||||
itself will be highlighted with `"cm-selectionMatch-main"`.
|
||||
*/
|
||||
declare function highlightSelectionMatches(options?: HighlightOptions): Extension;
|
||||
/**
|
||||
Select next occurrence of the current selection. Expand selection
|
||||
to the surrounding word when the selection is empty.
|
||||
*/
|
||||
declare const selectNextOccurrence: StateCommand;
|
||||
|
||||
interface SearchConfig {
|
||||
/**
|
||||
Whether to position the search panel at the top of the editor
|
||||
(the default is at the bottom).
|
||||
*/
|
||||
top?: boolean;
|
||||
/**
|
||||
Whether to enable case sensitivity by default when the search
|
||||
panel is activated (defaults to false).
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
Whether to treat string searches literally by default (defaults to false).
|
||||
*/
|
||||
literal?: boolean;
|
||||
/**
|
||||
Controls whether the default query has by-word matching enabled.
|
||||
Defaults to false.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
/**
|
||||
Used to turn on regular expression search in the default query.
|
||||
Defaults to false.
|
||||
*/
|
||||
regexp?: boolean;
|
||||
/**
|
||||
Can be used to override the way the search panel is implemented.
|
||||
Should create a [Panel](https://codemirror.net/6/docs/ref/#view.Panel) that contains a form
|
||||
which lets the user:
|
||||
|
||||
- See the [current](https://codemirror.net/6/docs/ref/#search.getSearchQuery) search query.
|
||||
- Manipulate the [query](https://codemirror.net/6/docs/ref/#search.SearchQuery) and
|
||||
[update](https://codemirror.net/6/docs/ref/#search.setSearchQuery) the search state with a new
|
||||
query.
|
||||
- Notice external changes to the query by reacting to the
|
||||
appropriate [state effect](https://codemirror.net/6/docs/ref/#search.setSearchQuery).
|
||||
- Run some of the search commands.
|
||||
|
||||
The field that should be focused when opening the panel must be
|
||||
tagged with a `main-field=true` DOM attribute.
|
||||
*/
|
||||
createPanel?: (view: EditorView) => Panel;
|
||||
/**
|
||||
By default, matches are scrolled into view using the default
|
||||
behavior of
|
||||
[`EditorView.scrollIntoView`](https://codemirror.net/6/docs/ref/#view.EditorView^scrollIntoView).
|
||||
This option allows you to pass a custom function to produce the
|
||||
scroll effect.
|
||||
*/
|
||||
scrollToMatch?: (range: SelectionRange, view: EditorView) => StateEffect<unknown>;
|
||||
}
|
||||
/**
|
||||
Add search state to the editor configuration, and optionally
|
||||
configure the search extension.
|
||||
([`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) will automatically
|
||||
enable this if it isn't already on).
|
||||
*/
|
||||
declare function search(config?: SearchConfig): Extension;
|
||||
/**
|
||||
A search query. Part of the editor's search state.
|
||||
*/
|
||||
declare class SearchQuery {
|
||||
/**
|
||||
The search string (or regular expression).
|
||||
*/
|
||||
readonly search: string;
|
||||
/**
|
||||
Indicates whether the search is case-sensitive.
|
||||
*/
|
||||
readonly caseSensitive: boolean;
|
||||
/**
|
||||
By default, string search will replace `\n`, `\r`, and `\t` in
|
||||
the query with newline, return, and tab characters. When this
|
||||
is set to true, that behavior is disabled.
|
||||
*/
|
||||
readonly literal: boolean;
|
||||
/**
|
||||
When true, the search string is interpreted as a regular
|
||||
expression.
|
||||
*/
|
||||
readonly regexp: boolean;
|
||||
/**
|
||||
The replace text, or the empty string if no replace text has
|
||||
been given.
|
||||
*/
|
||||
readonly replace: string;
|
||||
/**
|
||||
Whether this query is non-empty and, in case of a regular
|
||||
expression search, syntactically valid.
|
||||
*/
|
||||
readonly valid: boolean;
|
||||
/**
|
||||
When true, matches that contain words are ignored when there are
|
||||
further word characters around them.
|
||||
*/
|
||||
readonly wholeWord: boolean;
|
||||
/**
|
||||
Create a query object.
|
||||
*/
|
||||
constructor(config: {
|
||||
/**
|
||||
The search string.
|
||||
*/
|
||||
search: string;
|
||||
/**
|
||||
Controls whether the search should be case-sensitive.
|
||||
*/
|
||||
caseSensitive?: boolean;
|
||||
/**
|
||||
By default, string search will replace `\n`, `\r`, and `\t` in
|
||||
the query with newline, return, and tab characters. When this
|
||||
is set to true, that behavior is disabled.
|
||||
*/
|
||||
literal?: boolean;
|
||||
/**
|
||||
When true, interpret the search string as a regular expression.
|
||||
*/
|
||||
regexp?: boolean;
|
||||
/**
|
||||
The replace text.
|
||||
*/
|
||||
replace?: string;
|
||||
/**
|
||||
Enable whole-word matching.
|
||||
*/
|
||||
wholeWord?: boolean;
|
||||
});
|
||||
/**
|
||||
Compare this query to another query.
|
||||
*/
|
||||
eq(other: SearchQuery): boolean;
|
||||
/**
|
||||
Get a search cursor for this query, searching through the given
|
||||
range in the given state.
|
||||
*/
|
||||
getCursor(state: EditorState | Text, from?: number, to?: number): Iterator<{
|
||||
from: number;
|
||||
to: number;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
A state effect that updates the current search query. Note that
|
||||
this only has an effect if the search state has been initialized
|
||||
(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or
|
||||
by running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least
|
||||
once).
|
||||
*/
|
||||
declare const setSearchQuery: _codemirror_state.StateEffectType<SearchQuery>;
|
||||
/**
|
||||
Get the current search query from an editor state.
|
||||
*/
|
||||
declare function getSearchQuery(state: EditorState): SearchQuery;
|
||||
/**
|
||||
Query whether the search panel is open in the given editor state.
|
||||
*/
|
||||
declare function searchPanelOpen(state: EditorState): boolean;
|
||||
/**
|
||||
Open the search panel if it isn't already open, and move the
|
||||
selection to the first match after the current main selection.
|
||||
Will wrap around to the start of the document when it reaches the
|
||||
end.
|
||||
*/
|
||||
declare const findNext: Command;
|
||||
/**
|
||||
Move the selection to the previous instance of the search query,
|
||||
before the current main selection. Will wrap past the start
|
||||
of the document to start searching at the end again.
|
||||
*/
|
||||
declare const findPrevious: Command;
|
||||
/**
|
||||
Select all instances of the search query.
|
||||
*/
|
||||
declare const selectMatches: Command;
|
||||
/**
|
||||
Select all instances of the currently selected text.
|
||||
*/
|
||||
declare const selectSelectionMatches: StateCommand;
|
||||
/**
|
||||
Replace the current match of the search query.
|
||||
*/
|
||||
declare const replaceNext: Command;
|
||||
/**
|
||||
Replace all instances of the search query with the given
|
||||
replacement.
|
||||
*/
|
||||
declare const replaceAll: Command;
|
||||
/**
|
||||
Make sure the search panel is open and focused.
|
||||
*/
|
||||
declare const openSearchPanel: Command;
|
||||
/**
|
||||
Close the search panel.
|
||||
*/
|
||||
declare const closeSearchPanel: Command;
|
||||
/**
|
||||
Default search-related key bindings.
|
||||
|
||||
- Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)
|
||||
- F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)
|
||||
- Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)
|
||||
- Mod-Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)
|
||||
- Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)
|
||||
*/
|
||||
declare const searchKeymap: readonly KeyBinding[];
|
||||
|
||||
export { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
||||
1251
node_modules/@codemirror/search/dist/index.js
generated
vendored
Normal file
1251
node_modules/@codemirror/search/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
40
node_modules/@codemirror/search/package.json
generated
vendored
Normal file
40
node_modules/@codemirror/search/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@codemirror/search",
|
||||
"version": "6.5.10",
|
||||
"description": "Search functionality for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/search.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"editor",
|
||||
"code"
|
||||
],
|
||||
"author": {
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijn@haverbeke.berlin",
|
||||
"url": "http://marijnhaverbeke.nl"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "dist/index.js",
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"crelt": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^1.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/search.git"
|
||||
}
|
||||
}
|
||||
16
node_modules/@codemirror/state/.github/workflows/dispatch.yml
generated
vendored
Normal file
16
node_modules/@codemirror/state/.github/workflows/dispatch.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: Trigger CI
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Dispatch to main repo
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Emit repository_dispatch
|
||||
uses: mvasigh/dispatch-action@main
|
||||
with:
|
||||
# You should create a personal access token and store it in your repository
|
||||
token: ${{ secrets.DISPATCH_AUTH }}
|
||||
repo: dev
|
||||
owner: codemirror
|
||||
event_type: push
|
||||
286
node_modules/@codemirror/state/CHANGELOG.md
generated
vendored
Normal file
286
node_modules/@codemirror/state/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,286 @@
|
||||
## 6.5.2 (2025-02-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where reconfiguring a field with a new `init` value didn't update the value of the field.
|
||||
|
||||
## 6.5.1 (2025-01-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
`countColumn` no longer loops infinitely when given a `to` that's higher than the input string's length.
|
||||
|
||||
## 6.5.0 (2024-12-09)
|
||||
|
||||
### New features
|
||||
|
||||
`RangeSet.compare` now supports a `boundChange` callback that is called when there's a change in the way ranges are split.
|
||||
|
||||
## 6.4.1 (2024-02-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that caused widgets at the end of a mark decoration to be rendered in their own separate mark DOM element.
|
||||
|
||||
## 6.4.0 (2023-12-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When multiple ranges in a single range set overlap, put the smaller ones inside the bigger ones, so that overlapping decorations don't break up each other's elements when coming from the same source.
|
||||
|
||||
### New features
|
||||
|
||||
Selection and selection range `eq` methods now support an optional argument that makes them also compare by cursor associativity.
|
||||
|
||||
The `RangeSet.join` function can be used to join multiple range sets together.
|
||||
|
||||
## 6.3.3 (2023-12-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where `Text.slice` and `Text.replace` could return objects with incorrect `length` when the given `from`/`to` values were out of range for the text.
|
||||
|
||||
## 6.3.2 (2023-11-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure transactions cannot add multiple selections when `allowMultipleSelections` is false.
|
||||
|
||||
Fix a bug that caused `Text.iterLines` to not return empty lines at the end of the iterated ranges.
|
||||
|
||||
## 6.3.1 (2023-10-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Give the tag property on `FacetReader` the type of the output type parameter to force TypeScript to infer the proper type when converting from `Facet` to `FacetReader`.
|
||||
|
||||
## 6.3.0 (2023-10-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `FacetReader` type provides a way to export a read-only handle to a `Facet`.
|
||||
|
||||
## 6.2.1 (2023-05-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that could cause `RangeSet.compare` to miss changes in the set of active ranges around a point range.
|
||||
|
||||
## 6.2.0 (2022-12-26)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.range` now accepts an optional 4th argument to specify the bidi level of the range's head position.
|
||||
|
||||
## 6.1.4 (2022-11-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused the `openStart` value passed to span iterators to be incorrect around widgets in some circumstances.
|
||||
|
||||
## 6.1.3 (2022-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid unnecessary calls to computed facet getters when a state is reconfigured but no dependencies of the computed facet change.
|
||||
|
||||
Fix an infinite loop in `RangeSet.eq` when the `to` parameter isn't given.
|
||||
|
||||
## 6.1.2 (2022-09-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where, when multiple transaction extenders took effect, only the highest-precedence one was actually included in the transaction.
|
||||
|
||||
## 6.1.1 (2022-08-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in range set span iteration that would cause decorations to be inappropriately split in some situations.
|
||||
|
||||
## 6.1.0 (2022-06-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Refine change mapping to preserve insertions made by concurrent changes.
|
||||
|
||||
### New features
|
||||
|
||||
The `enables` option to `Facet.define` may now take a function, which will be called with the facet value to create the extensions.
|
||||
|
||||
## 6.0.1 (2022-06-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a problem that caused effects' `map` methods to be called with an incorrect change set when filtering changes.
|
||||
|
||||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Update dependencies to 6.0.0
|
||||
|
||||
## 0.20.1 (2022-06-02)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorView.phrase` now accepts additional arguments, which it will interpolate into the phrase in the place of `$` markers.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The deprecated precedence names `fallback`, `extend`, and `override` were removed from the library.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where, if an extension value occurs multiple times, its lowest, rather than highest precedence is used.
|
||||
|
||||
Fix an issue where facets with computed inputs would unneccesarily have their outputs recreated on state reconfiguration.
|
||||
|
||||
Fix a bug in the order in which new values for state fields and facets were computed, which could cause dynamic facets to hold the wrong value in some situations.
|
||||
|
||||
### New features
|
||||
|
||||
The exports from @codemirror/rangeset now live in this package.
|
||||
|
||||
The exports from @codemirror/text now live in this package.
|
||||
|
||||
## 0.19.9 (2022-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Mapping a non-empty selection range now always puts any newly inserted text on the sides of the range outside of the mapped version.
|
||||
|
||||
## 0.19.8 (2022-02-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where facet values with computed inputs could incorrectly retain their old value on reconfiguration.
|
||||
|
||||
## 0.19.7 (2022-02-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid recomputing facets on state reconfiguration if that facet's inputs stayed precisely the same.
|
||||
|
||||
Selection ranges created with `EditorSelection.range` will now have an assoc pointing at their anchor, when non-empty.
|
||||
|
||||
## 0.19.6 (2021-11-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused facet compare functions to be called with an invalid value in some situations.
|
||||
|
||||
Fix a bug that caused dynamic facet values to be incorrectly kept unchanged when reconfiguration changed one of their dependencies.
|
||||
|
||||
## 0.19.5 (2021-11-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would cause dynamic facet values influenced by a state reconfiguration to not properly recompute.
|
||||
|
||||
## 0.19.4 (2021-11-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
When reconfiguring a state, effects from the reconfiguring transaction can now be seen by newly added state fields.
|
||||
|
||||
## 0.19.3 (2021-11-03)
|
||||
|
||||
### New features
|
||||
|
||||
The precedence levels (under `Prec`) now have more generic names, because their 'meaningful' names were entirely inappropriate in many situations.
|
||||
|
||||
## 0.19.2 (2021-09-13)
|
||||
|
||||
### New features
|
||||
|
||||
The editor state now has a `readOnly` property with a matching facet to control its value.
|
||||
|
||||
## 0.19.1 (2021-08-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `wordAt` never returned a useful result.
|
||||
|
||||
## 0.19.0 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
User event strings now work differently—the events emitted by the core packages follow a different system, and hierarchical event tags can be created by separating the words with dots.
|
||||
|
||||
### New features
|
||||
|
||||
`languageDataAt` now takes an optional `side` argument to specificy which side of the position you're interested in.
|
||||
|
||||
It is now possible to add a user event annotation with a direct `userEvent` property on a transaction spec.
|
||||
|
||||
Transactions now have an `isUserEvent` method that can be used to check if it is (a subtype of) some user event type.
|
||||
|
||||
## 0.18.7 (2021-05-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where state fields might be initialized with a state that they aren't actually part of during reconfiguration.
|
||||
|
||||
## 0.18.6 (2021-04-12)
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorState.wordAt` method finds the word at a given position.
|
||||
|
||||
## 0.18.5 (2021-04-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue in the compiled output that would break the code when minified with terser.
|
||||
|
||||
## 0.18.4 (2021-04-06)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Transaction.remote` annotation can be used to mark and recognize transactions created by other actors.
|
||||
|
||||
## 0.18.3 (2021-03-23)
|
||||
|
||||
### New features
|
||||
|
||||
The `ChangeDesc` class now has `toJSON` and `fromJSON` methods.
|
||||
|
||||
## 0.18.2 (2021-03-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix unintended ES2020 output (the package contains ES6 code again).
|
||||
|
||||
## 0.18.1 (2021-03-10)
|
||||
|
||||
### New features
|
||||
|
||||
The new `Compartment.get` method can be used to get the content of a compartment in a given state.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`tagExtension` and the `reconfigure` transaction spec property have been replaced with the concept of configuration compartments and reconfiguration effects (see `Compartment`, `StateEffect.reconfigure`, and `StateEffect.appendConfig`).
|
||||
|
||||
## 0.17.2 (2021-02-19)
|
||||
|
||||
### New features
|
||||
|
||||
`EditorSelection.map` and `SelectionRange.map` now take an optional second argument to indicate which direction to map to.
|
||||
|
||||
## 0.17.1 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user