Do not ignore node_modules
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
|
280
node_modules/@codemirror/autocomplete/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,280 @@
|
|||
## 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
|
@ -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.
|
18
node_modules/@codemirror/autocomplete/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# @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.
|
1787
node_modules/@codemirror/autocomplete/dist/index.cjs
generated
vendored
Normal file
459
node_modules/@codemirror/autocomplete/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,459 @@
|
|||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Transaction, StateCommand, Facet, Extension, StateEffect } from '@codemirror/state';
|
||||
import { EditorView, KeyBinding, Command } from '@codemirror/view';
|
||||
import * as _lezer_common from '@lezer/common';
|
||||
|
||||
interface CompletionConfig {
|
||||
/**
|
||||
When enabled (defaults to true), autocompletion will start
|
||||
whenever the user types something that can be completed.
|
||||
*/
|
||||
activateOnTyping?: 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;
|
||||
/**
|
||||
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 70.
|
||||
*/
|
||||
addToOptions?: {
|
||||
render: (completion: Completion, state: EditorState) => Node | null;
|
||||
position: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
/**
|
||||
Objects type used to represent individual completions.
|
||||
*/
|
||||
interface Completion {
|
||||
/**
|
||||
The label to show in the completion picker. This is what input
|
||||
is matched agains to determine whether a completion matches (and
|
||||
how well it matches).
|
||||
*/
|
||||
label: 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) => (Node | null | Promise<Node | null>));
|
||||
/**
|
||||
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 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;
|
||||
}
|
||||
/**
|
||||
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;
|
||||
/**
|
||||
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);
|
||||
/**
|
||||
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).
|
||||
*/
|
||||
addEventListener(type: "abort", listener: () => void): 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.
|
||||
*/
|
||||
declare 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`, 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.
|
||||
*/
|
||||
getMatch?: (completion: Completion) => 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;
|
||||
}
|
||||
/**
|
||||
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;
|
||||
|
||||
/**
|
||||
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 after the dollar or hash and before the brace (`$\\{`).
|
||||
This will be removed and the sequence will not be interpreted as a
|
||||
placeholder.
|
||||
*/
|
||||
declare function snippet(template: string): (editor: {
|
||||
state: EditorState;
|
||||
dispatch: (tr: Transaction) => void;
|
||||
}, _completion: Completion, 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;
|
||||
/**
|
||||
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;
|
||||
}
|
||||
/**
|
||||
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: [`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 { CloseBracketConfig, Completion, CompletionContext, CompletionResult, CompletionSource, acceptCompletion, autocompletion, clearSnippet, closeBrackets, closeBracketsKeymap, closeCompletion, completeAnyWord, completeFromList, completionKeymap, completionStatus, currentCompletions, deleteBracketPair, ifIn, ifNotIn, insertBracket, insertCompletionText, moveCompletionSelection, nextSnippetField, pickedCompletion, prevSnippetField, selectedCompletion, selectedCompletionIndex, setSelectedCompletion, snippet, snippetCompletion, snippetKeymap, startCompletion };
|
1756
node_modules/@codemirror/autocomplete/dist/index.js
generated
vendored
Normal file
41
node_modules/@codemirror/autocomplete/package.json
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
"name": "@codemirror/autocomplete",
|
||||
"version": "6.0.1",
|
||||
"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": "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",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/autocomplete.git"
|
||||
}
|
||||
}
|
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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
174
node_modules/@codemirror/commands/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
## 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
|
@ -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.
|
18
node_modules/@codemirror/commands/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# @codemirror/commands [](https://www.npmjs.org/package/@codemirror/commands)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#commands) | [**ISSUES**](https://github.com/codemirror/codemirror.next/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/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/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.
|
1631
node_modules/@codemirror/commands/dist/index.cjs
generated
vendored
Normal file
543
node_modules/@codemirror/commands/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,543 @@
|
|||
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;
|
||||
}
|
||||
/**
|
||||
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): [`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 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 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 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 [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 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 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
|
||||
before the cursor.
|
||||
*/
|
||||
declare const deleteCharBackward: 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 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 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;
|
||||
/**
|
||||
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: [`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): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).
|
||||
- Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).
|
||||
*/
|
||||
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 (Comd-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).
|
||||
*/
|
||||
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 { CommentTokens, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };
|
1534
node_modules/@codemirror/commands/dist/index.js
generated
vendored
Normal file
42
node_modules/@codemirror/commands/package.json
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"name": "@codemirror/commands",
|
||||
"version": "6.0.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": "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",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.5",
|
||||
"@codemirror/lang-javascript": "^6.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/commands.git"
|
||||
}
|
||||
}
|
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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
194
node_modules/@codemirror/language/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,194 @@
|
|||
## 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
|
@ -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.
|
18
node_modules/@codemirror/language/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# @codemirror/language [](https://www.npmjs.org/package/@codemirror/language)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#language) | [**ISSUES**](https://github.com/codemirror/codemirror.next/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/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/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.
|
2360
node_modules/@codemirror/language/dist/index.cjs
generated
vendored
Normal file
1064
node_modules/@codemirror/language/dist/index.d.ts
generated
vendored
Normal file
2310
node_modules/@codemirror/language/dist/index.js
generated
vendored
Normal file
44
node_modules/@codemirror/language/package.json
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "@codemirror/language",
|
||||
"version": "6.0.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": "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/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0",
|
||||
"style-mod": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.5",
|
||||
"@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
|
@ -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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
150
node_modules/@codemirror/lint/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
## 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
|
@ -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.
|
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/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#lint) | [**ISSUES**](https://github.com/codemirror/codemirror.next/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/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/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.
|
749
node_modules/@codemirror/lint/dist/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,749 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var view = require('@codemirror/view');
|
||||
var state = require('@codemirror/state');
|
||||
var elt = require('crelt');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var elt__default = /*#__PURE__*/_interopDefaultLegacy(elt);
|
||||
|
||||
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);
|
||||
let ranges = view.Decoration.set(markedDiagnostics.map((d) => {
|
||||
// For zero-length ranges or ranges covering only a line break, create a widget
|
||||
return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
|
||||
? view.Decoration.widget({
|
||||
widget: new DiagnosticWidget(d),
|
||||
diagnostic: d
|
||||
}).range(d.from)
|
||||
: view.Decoration.mark({
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
||||
diagnostic: d
|
||||
}).range(d.from, d.to);
|
||||
}), true);
|
||||
return new LintState(ranges, panel, findDiagnostic(ranges));
|
||||
}
|
||||
}
|
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
||||
let found = null;
|
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
||||
if (diagnostic && spec.diagnostic != diagnostic)
|
||||
return;
|
||||
found = new SelectedDiagnostic(from, to, spec.diagnostic);
|
||||
return false;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
||||
}
|
||||
function maybeEnableLint(state$1, effects) {
|
||||
return state$1.field(lintState, false) ? effects : effects.concat(state.StateEffect.appendConfig.of([
|
||||
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
|
||||
]));
|
||||
}
|
||||
/**
|
||||
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) {
|
||||
let mapped = value.diagnostics.map(tr.changes), selected = null;
|
||||
if (value.selected) {
|
||||
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
||||
}
|
||||
value = new LintState(mapped, value.panel, selected);
|
||||
}
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
value = LintState.init(effect.value, 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 = [], stackStart = 2e8, stackEnd = 0;
|
||||
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.push(spec.diagnostic);
|
||||
stackStart = Math.min(from, stackStart);
|
||||
stackEnd = Math.max(to, stackEnd);
|
||||
}
|
||||
});
|
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
||||
if (diagnosticFilter)
|
||||
found = diagnosticFilter(found);
|
||||
if (!found.length)
|
||||
return null;
|
||||
return {
|
||||
pos: stackStart,
|
||||
end: stackEnd,
|
||||
above: view.state.doc.lineAt(stackStart).to < stackEnd,
|
||||
create() {
|
||||
return { dom: diagnosticsTooltip(view, found) };
|
||||
}
|
||||
};
|
||||
}
|
||||
function diagnosticsTooltip(view, diagnostics) {
|
||||
return elt__default["default"]("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;
|
||||
};
|
||||
/**
|
||||
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 },
|
||||
{ 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() {
|
||||
let now = Date.now();
|
||||
if (now < this.lintTime - 10) {
|
||||
setTimeout(this.run, this.lintTime - now);
|
||||
}
|
||||
else {
|
||||
this.set = false;
|
||||
let { state } = this.view, { sources } = state.facet(lintConfig);
|
||||
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
|
||||
let all = annotations.reduce((a, b) => a.concat(b));
|
||||
if (this.view.state.doc == state.doc)
|
||||
this.view.dispatch(setDiagnostics(this.view.state, all));
|
||||
}, error => { view.logException(this.view.state, error); });
|
||||
}
|
||||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig)) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
const lintConfig = state.Facet.define({
|
||||
combine(input) {
|
||||
return Object.assign({ sources: input.map(i => i.source) }, state.combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
}));
|
||||
},
|
||||
enables: lintPlugin
|
||||
});
|
||||
/**
|
||||
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).
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return lintConfig.of({ source, config });
|
||||
}
|
||||
/**
|
||||
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__default["default"]("li", { class: "cm-diagnostic cm-diagnostic-" + diagnostic.severity }, elt__default["default"]("span", { class: "cm-diagnosticText" }, diagnostic.renderMessage ? diagnostic.renderMessage() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
||||
let click = (e) => {
|
||||
e.preventDefault();
|
||||
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__default["default"]("u", name.slice(keyIndex, keyIndex + 1)),
|
||||
name.slice(keyIndex + 1)];
|
||||
return elt__default["default"]("button", {
|
||||
type: "button",
|
||||
class: "cm-diagnosticAction",
|
||||
onclick: click,
|
||||
onmousedown: click,
|
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
||||
}, nameElt);
|
||||
}), diagnostic.source && elt__default["default"]("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
||||
}
|
||||
class DiagnosticWidget extends view.WidgetType {
|
||||
constructor(diagnostic) {
|
||||
super();
|
||||
this.diagnostic = diagnostic;
|
||||
}
|
||||
eq(other) { return other.diagnostic == this.diagnostic; }
|
||||
toDOM() {
|
||||
return elt__default["default"]("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
|
||||
}
|
||||
}
|
||||
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__default["default"]("ul", {
|
||||
tabIndex: 0,
|
||||
role: "listbox",
|
||||
"aria-label": this.view.state.phrase("Diagnostics"),
|
||||
onkeydown,
|
||||
onclick
|
||||
});
|
||||
this.dom = elt__default["default"]("div", { class: "cm-panel-lint" }, this.list, elt__default["default"]("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;
|
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
||||
let found = -1, item;
|
||||
for (let j = i; j < this.items.length; j++)
|
||||
if (this.items[j].diagnostic == spec.diagnostic) {
|
||||
found = j;
|
||||
break;
|
||||
}
|
||||
if (found < 0) {
|
||||
item = new PanelItem(this.view, spec.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 }) => {
|
||||
if (sel.top < panel.top)
|
||||
this.list.scrollTop -= panel.top - sel.top;
|
||||
else if (sel.bottom > panel.bottom)
|
||||
this.list.scrollTop += sel.bottom - panel.bottom;
|
||||
}
|
||||
});
|
||||
}
|
||||
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-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
padding: "2px 4px",
|
||||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px"
|
||||
},
|
||||
".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-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-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
|
||||
}
|
||||
}
|
||||
});
|
||||
class LintGutterMarker extends view.GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = diagnostics.reduce((max, d) => {
|
||||
let s = d.severity;
|
||||
return s == "error" || s == "warning" && max == "info" ? s : max;
|
||||
}, "info");
|
||||
}
|
||||
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);
|
||||
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 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ &&
|
||||
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* 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,
|
||||
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),
|
||||
});
|
||||
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 || []);
|
||||
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:before": {
|
||||
content: svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintGutterConfig = state.Facet.define({
|
||||
combine(configs) {
|
||||
return state.combineConfig(configs, {
|
||||
hoverTime: 300 /* 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];
|
||||
}
|
||||
|
||||
exports.closeLintPanel = closeLintPanel;
|
||||
exports.diagnosticCount = diagnosticCount;
|
||||
exports.forceLinting = forceLinting;
|
||||
exports.lintGutter = lintGutter;
|
||||
exports.lintKeymap = lintKeymap;
|
||||
exports.linter = linter;
|
||||
exports.nextDiagnostic = nextDiagnostic;
|
||||
exports.openLintPanel = openLintPanel;
|
||||
exports.setDiagnostics = setDiagnostics;
|
||||
exports.setDiagnosticsEffect = setDiagnosticsEffect;
|
149
node_modules/@codemirror/lint/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { EditorState, TransactionSpec, Extension } from '@codemirror/state';
|
||||
import { EditorView, Command, KeyBinding } from '@codemirror/view';
|
||||
|
||||
/**
|
||||
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: "info" | "warning" | "error";
|
||||
/**
|
||||
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?: () => 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;
|
||||
}
|
||||
declare type DiagnosticFilter = (diagnostics: readonly Diagnostic[]) => Diagnostic[];
|
||||
interface LintConfig {
|
||||
/**
|
||||
Time to wait (in milliseconds) after a change before running
|
||||
the linter. Defaults to 750ms.
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
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;
|
||||
}
|
||||
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;
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
declare 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).
|
||||
*/
|
||||
declare function linter(source: LintSource, 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;
|
||||
|
||||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
732
node_modules/@codemirror/lint/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,732 @@
|
|||
import { Decoration, showPanel, EditorView, ViewPlugin, hoverTooltip, logException, gutter, showTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view';
|
||||
import { StateEffect, StateField, Facet, combineConfig, RangeSet } 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);
|
||||
let ranges = Decoration.set(markedDiagnostics.map((d) => {
|
||||
// For zero-length ranges or ranges covering only a line break, create a widget
|
||||
return d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from)
|
||||
? Decoration.widget({
|
||||
widget: new DiagnosticWidget(d),
|
||||
diagnostic: d
|
||||
}).range(d.from)
|
||||
: Decoration.mark({
|
||||
attributes: { class: "cm-lintRange cm-lintRange-" + d.severity },
|
||||
diagnostic: d
|
||||
}).range(d.from, d.to);
|
||||
}), true);
|
||||
return new LintState(ranges, panel, findDiagnostic(ranges));
|
||||
}
|
||||
}
|
||||
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
||||
let found = null;
|
||||
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
||||
if (diagnostic && spec.diagnostic != diagnostic)
|
||||
return;
|
||||
found = new SelectedDiagnostic(from, to, spec.diagnostic);
|
||||
return false;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
function hideTooltip(tr, tooltip) {
|
||||
return !!(tr.effects.some(e => e.is(setDiagnosticsEffect)) || tr.changes.touchesRange(tooltip.pos));
|
||||
}
|
||||
function maybeEnableLint(state, effects) {
|
||||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([
|
||||
lintState,
|
||||
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)
|
||||
]);
|
||||
}),
|
||||
hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
||||
baseTheme
|
||||
]));
|
||||
}
|
||||
/**
|
||||
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) {
|
||||
let mapped = value.diagnostics.map(tr.changes), selected = null;
|
||||
if (value.selected) {
|
||||
let selPos = tr.changes.mapPos(value.selected.from, 1);
|
||||
selected = findDiagnostic(mapped, value.selected.diagnostic, selPos) || findDiagnostic(mapped, null, selPos);
|
||||
}
|
||||
value = new LintState(mapped, value.panel, selected);
|
||||
}
|
||||
for (let effect of tr.effects) {
|
||||
if (effect.is(setDiagnosticsEffect)) {
|
||||
value = LintState.init(effect.value, 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 = [], stackStart = 2e8, stackEnd = 0;
|
||||
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.push(spec.diagnostic);
|
||||
stackStart = Math.min(from, stackStart);
|
||||
stackEnd = Math.max(to, stackEnd);
|
||||
}
|
||||
});
|
||||
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
||||
if (diagnosticFilter)
|
||||
found = diagnosticFilter(found);
|
||||
if (!found.length)
|
||||
return null;
|
||||
return {
|
||||
pos: stackStart,
|
||||
end: stackEnd,
|
||||
above: view.state.doc.lineAt(stackStart).to < stackEnd,
|
||||
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;
|
||||
};
|
||||
/**
|
||||
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 },
|
||||
{ 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() {
|
||||
let now = Date.now();
|
||||
if (now < this.lintTime - 10) {
|
||||
setTimeout(this.run, this.lintTime - now);
|
||||
}
|
||||
else {
|
||||
this.set = false;
|
||||
let { state } = this.view, { sources } = state.facet(lintConfig);
|
||||
Promise.all(sources.map(source => Promise.resolve(source(this.view)))).then(annotations => {
|
||||
let all = annotations.reduce((a, b) => a.concat(b));
|
||||
if (this.view.state.doc == state.doc)
|
||||
this.view.dispatch(setDiagnostics(this.view.state, all));
|
||||
}, error => { logException(this.view.state, error); });
|
||||
}
|
||||
}
|
||||
update(update) {
|
||||
let config = update.state.facet(lintConfig);
|
||||
if (update.docChanged || config != update.startState.facet(lintConfig)) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
const lintConfig = /*@__PURE__*/Facet.define({
|
||||
combine(input) {
|
||||
return Object.assign({ sources: input.map(i => i.source) }, combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null
|
||||
}));
|
||||
},
|
||||
enables: lintPlugin
|
||||
});
|
||||
/**
|
||||
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).
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return lintConfig.of({ source, config });
|
||||
}
|
||||
/**
|
||||
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() : diagnostic.message), (_a = diagnostic.actions) === null || _a === void 0 ? void 0 : _a.map((action, i) => {
|
||||
let click = (e) => {
|
||||
e.preventDefault();
|
||||
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(diagnostic) {
|
||||
super();
|
||||
this.diagnostic = diagnostic;
|
||||
}
|
||||
eq(other) { return other.diagnostic == this.diagnostic; }
|
||||
toDOM() {
|
||||
return elt("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
|
||||
}
|
||||
}
|
||||
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;
|
||||
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
||||
let found = -1, item;
|
||||
for (let j = i; j < this.items.length; j++)
|
||||
if (this.items[j].diagnostic == spec.diagnostic) {
|
||||
found = j;
|
||||
break;
|
||||
}
|
||||
if (found < 0) {
|
||||
item = new PanelItem(this.view, spec.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 }) => {
|
||||
if (sel.top < panel.top)
|
||||
this.list.scrollTop -= panel.top - sel.top;
|
||||
else if (sel.bottom > panel.bottom)
|
||||
this.list.scrollTop += sel.bottom - panel.bottom;
|
||||
}
|
||||
});
|
||||
}
|
||||
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-diagnosticAction": {
|
||||
font: "inherit",
|
||||
border: "none",
|
||||
padding: "2px 4px",
|
||||
backgroundColor: "#444",
|
||||
color: "white",
|
||||
borderRadius: "3px",
|
||||
marginLeft: "8px"
|
||||
},
|
||||
".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-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-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
|
||||
}
|
||||
}
|
||||
});
|
||||
class LintGutterMarker extends GutterMarker {
|
||||
constructor(diagnostics) {
|
||||
super();
|
||||
this.diagnostics = diagnostics;
|
||||
this.severity = diagnostics.reduce((max, d) => {
|
||||
let s = d.severity;
|
||||
return s == "error" || s == "warning" && max == "info" ? s : max;
|
||||
}, "info");
|
||||
}
|
||||
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);
|
||||
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 /* Margin */ && event.clientX < rect.right + 10 /* Margin */ &&
|
||||
event.clientY > rect.top - 10 /* Margin */ && event.clientY < rect.bottom + 10 /* 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,
|
||||
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),
|
||||
});
|
||||
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 || []);
|
||||
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:before": {
|
||||
content: /*@__PURE__*/svg(`<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>`)
|
||||
},
|
||||
});
|
||||
const lintGutterConfig = /*@__PURE__*/Facet.define({
|
||||
combine(configs) {
|
||||
return combineConfig(configs, {
|
||||
hoverTime: 300 /* 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];
|
||||
}
|
||||
|
||||
export { closeLintPanel, diagnosticCount, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
40
node_modules/@codemirror/lint/package.json
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@codemirror/lint",
|
||||
"version": "6.0.0",
|
||||
"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": "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/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"crelt": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/lint.git"
|
||||
}
|
||||
}
|
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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
174
node_modules/@codemirror/search/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
## 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
|
@ -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.
|
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/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#search) | [**ISSUES**](https://github.com/codemirror/codemirror.next/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/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/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.
|
1150
node_modules/@codemirror/search/dist/index.cjs
generated
vendored
Normal file
329
node_modules/@codemirror/search/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,329 @@
|
|||
import * as _codemirror_state from '@codemirror/state';
|
||||
import { Text, Extension, StateCommand, EditorState } 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 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);
|
||||
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;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
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 to;
|
||||
private iter;
|
||||
private re;
|
||||
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?: {
|
||||
ignoreCase?: boolean;
|
||||
}, 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.
|
||||
|
||||
The dialog can be styled with the `panel.gotoLine` theme
|
||||
selector.
|
||||
*/
|
||||
declare const gotoLine: Command;
|
||||
|
||||
declare 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;
|
||||
/**
|
||||
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.
|
||||
*/
|
||||
createPanel?: (view: EditorView) => Panel;
|
||||
}
|
||||
/**
|
||||
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;
|
||||
/**
|
||||
Then 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;
|
||||
/**
|
||||
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;
|
||||
});
|
||||
/**
|
||||
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 document.
|
||||
*/
|
||||
getCursor(doc: 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;
|
||||
/**
|
||||
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)
|
||||
- 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, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };
|
1125
node_modules/@codemirror/search/dist/index.js
generated
vendored
Normal file
40
node_modules/@codemirror/search/package.json
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@codemirror/search",
|
||||
"version": "6.0.0",
|
||||
"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": "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/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"crelt": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/search.git"
|
||||
}
|
||||
}
|
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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
170
node_modules/@codemirror/state/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,170 @@
|
|||
## 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.
|
||||
|
21
node_modules/@codemirror/state/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.
|
18
node_modules/@codemirror/state/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# @codemirror/state [](https://www.npmjs.org/package/@codemirror/state)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#state) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/state/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the editor state data structures for the
|
||||
[CodeMirror](https://codemirror.net/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/state/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.
|
3888
node_modules/@codemirror/state/dist/index.cjs
generated
vendored
Normal file
1643
node_modules/@codemirror/state/dist/index.d.ts
generated
vendored
Normal file
3856
node_modules/@codemirror/state/dist/index.js
generated
vendored
Normal file
35
node_modules/@codemirror/state/package.json
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "@codemirror/state",
|
||||
"version": "6.0.0",
|
||||
"description": "Editor state data structures for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.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",
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.5"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/state.git"
|
||||
}
|
||||
}
|
16
node_modules/@codemirror/view/.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: codemirror.next
|
||||
owner: codemirror
|
||||
event_type: push
|
873
node_modules/@codemirror/view/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,873 @@
|
|||
## 6.0.0 (2022-06-08)
|
||||
|
||||
### New features
|
||||
|
||||
The new static `EditorView.findFromDOM` method can be used to retrieve an editor instance from its DOM structure.
|
||||
|
||||
Instead of passing a constructed state to the `EditorView` constructor, it is now also possible to inline the configuration options to the state in the view config object.
|
||||
|
||||
## 0.20.7 (2022-05-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue on Chrome Android where the DOM could fail to display the actual document after backspace.
|
||||
|
||||
Avoid an issue on Chrome Android where DOM changes were sometimes inappropriately replace by a backspace key effect due to spurious beforeinput events.
|
||||
|
||||
Fix a problem where the content element's width didn't cover the width of the actual content.
|
||||
|
||||
Work around a bug in Chrome 102 which caused wheel scrolling of the editor to be interrupted every few lines.
|
||||
|
||||
## 0.20.6 (2022-05-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the editor re-measures itself when its attributes are updated.
|
||||
|
||||
## 0.20.5 (2022-05-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where gutter elements without any markers in them would not get the `cm-gutterElement` class assigned.
|
||||
|
||||
Fix an issue where DOM event handlers registered by plugins were retained indefinitely, even after the editor was reconfigured.
|
||||
|
||||
## 0.20.4 (2022-05-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Prevent Mac-style behavior of inserting a period when the user inserts two spaces.
|
||||
|
||||
Fix an issue where the editor would sometimes not restore the DOM selection when refocused with a selection identical to the one it held when it lost focus.
|
||||
|
||||
## 0.20.3 (2022-04-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where the input handling could crash on repeated (or held) backspace presses on Chrome Android.
|
||||
|
||||
## 0.20.2 (2022-04-22)
|
||||
|
||||
### New features
|
||||
|
||||
The new `hideOn` option to `hoverTooltip` allows more fine-grained control over when the tooltip should hide.
|
||||
|
||||
## 0.20.1 (2022-04-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove debug statements that accidentally made it into 0.20.0.
|
||||
|
||||
Fix a regression in `moveVertically`.
|
||||
|
||||
## 0.20.0 (2022-04-20)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The deprecated interfaces `blockAtHeight`, `visualLineAtHeight`, `viewportLines`, `visualLineAt`, `scrollPosIntoView`, `scrollTo`, and `centerOn` were removed from the library.
|
||||
|
||||
All decorations are now provided through `EditorView.decorations`, and are part of a single precedence ordering. Decoration sources that need access to the view are provided as functions.
|
||||
|
||||
Atomic ranges are now specified through a facet (`EditorView.atomicRanges`).
|
||||
|
||||
Scroll margins are now specified through a facet (`EditorView.scrollMargins`).
|
||||
|
||||
Plugin fields no longer exist in the library (and are replaced by facets holding function values).
|
||||
|
||||
This package no longer re-exports the Range type from @codemirror/state.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where zero-length block widgets could cause `viewportLineBlocks` to contain overlapping ranges.
|
||||
|
||||
### New features
|
||||
|
||||
The new `perLineTextDirection` facet configures whether the editor reads text direction per line, or uses a single direction for the entire editor. `EditorView.textDirectionAt` returns the direction around a given position.
|
||||
|
||||
`rectangularSelection` and `crosshairCursor` from @codemirror/rectangular-selection were merged into this package.
|
||||
|
||||
This package now exports the tooltip functionality that used to live in @codemirror/tooltip.
|
||||
|
||||
The exports from the old @codemirror/panel package are now available from this package.
|
||||
|
||||
The exports from the old @codemirror/gutter package are now available from this package.
|
||||
|
||||
## 0.19.48 (2022-03-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where DOM syncing could crash when a DOM node was moved from a parent to a child node (via widgets reusing existing nodes).
|
||||
|
||||
To avoid interfering with things like a vim mode too much, the editor will now only activate the tab-to-move-focus escape hatch after an escape press that wasn't handled by an event handler.
|
||||
|
||||
Make sure the view measures itself before the page is printed.
|
||||
|
||||
Tweak types of view plugin defining functions to avoid TypeScript errors when the plugin value doesn't have any of the interface's properties.
|
||||
|
||||
## 0.19.47 (2022-03-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where block widgets at the start of the viewport could break height computations.
|
||||
|
||||
## 0.19.46 (2022-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where block widgets on the edges of viewports could cause the positioning of content to misalign with the gutter and height computations.
|
||||
|
||||
Improve cursor height next to widgets.
|
||||
|
||||
Fix a bug where mapping positions to screen coordinates could return incorred coordinates during composition.
|
||||
|
||||
## 0.19.45 (2022-02-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the library failed to call `WidgetType.destroy` on the old widget when replacing a widget with a different widget of the same type.
|
||||
|
||||
Fix an issue where the editor would compute DOM positions inside composition contexts incorrectly in some cases, causing the selection to be put in the wrong place and needlessly interrupting compositions.
|
||||
|
||||
Fix leaking of resize event handlers.
|
||||
|
||||
## 0.19.44 (2022-02-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash that occasionally occurred when drag-selecting in a way that scrolled the editor.
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorView.compositionStarted` property indicates whether a composition is starting.
|
||||
|
||||
## 0.19.43 (2022-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix several issues where editing or composition went wrong due to our zero-width space kludge characters ending up in unexpected places.
|
||||
|
||||
Make sure the editor re-measures its dimensions whenever its theme changes.
|
||||
|
||||
Fix an issue where some keys on Android phones could leave the editor DOM unsynced with the actual document.
|
||||
|
||||
## 0.19.42 (2022-02-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression in cursor position determination after making an edit next to a widget.
|
||||
|
||||
## 0.19.41 (2022-02-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the editor's view of its content height could go out of sync with the DOM when a line-wrapping editor had its width changed, causing wrapping to change.
|
||||
|
||||
Fix a bug that caused the editor to draw way too much content when scrolling to a position in an editor (much) taller than the window.
|
||||
|
||||
Report an error when a replace decoration from a plugin crosses a line break, rather than silently ignoring it.
|
||||
|
||||
Fix an issue where reading DOM changes was broken when `lineSeparator` contained more than one character.
|
||||
|
||||
Make ordering of replace and mark decorations with the same extent and inclusivness more predictable by giving replace decorations precedence.
|
||||
|
||||
Fix a bug where, on Chrome, replacement across line boundaries and next to widgets could cause bogus zero-width characters to appear in the content.
|
||||
|
||||
## 0.19.40 (2022-01-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make composition input properly appear at secondary cursors (except when those are in the DOM node with the composition, in which case the browser won't allow us to intervene without aborting the composition).
|
||||
|
||||
Fix a bug that cause the editor to get confused about which content was visible after scrolling something into view.
|
||||
|
||||
Fix a bug where the dummy elements rendered around widgets could end up in a separate set of wrapping marks, and thus become visible.
|
||||
|
||||
`EditorView.moveVertically` now preserves the `assoc` property of the input range.
|
||||
|
||||
Get rid of gaps between selection elements drawn by `drawSelection`.
|
||||
|
||||
Fix an issue where replacing text next to a widget might leak bogus zero-width spaces into the document.
|
||||
|
||||
Avoid browser selection mishandling when a focused view has `setState` called by eagerly refocusing it.
|
||||
|
||||
## 0.19.39 (2022-01-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the editor signals a `geometryChanged` update when its width changes.
|
||||
|
||||
### New features
|
||||
|
||||
`EditorView.darkTheme` can now be queried to figure out whether the editor is using a dark theme.
|
||||
|
||||
## 0.19.38 (2022-01-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused line decorations with a `class` property to suppress all other line decorations for that line.
|
||||
|
||||
Fix a bug that caused scroll effects to be corrupted when further updates came in before they were applied.
|
||||
|
||||
Fix an issue where, depending on which way a floating point rounding error fell, `posAtCoords` (and thus vertical cursor motion) for positions outside of the vertical range of the document might or might not return the start/end of the document.
|
||||
|
||||
## 0.19.37 (2021-12-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix regression where plugin replacing decorations that span to the end of the line are ignored.
|
||||
|
||||
## 0.19.36 (2021-12-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash in `posAtCoords` when the position lies in a block widget that is rendered but scrolled out of view.
|
||||
|
||||
Adding block decorations from a plugin now raises an error. Replacing decorations that cross lines are ignored, when provided by a plugin.
|
||||
|
||||
Fix inverted interpretation of the `precise` argument to `posAtCoords`.
|
||||
|
||||
## 0.19.35 (2021-12-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The editor will now handle double-taps as if they are double-clicks, rather than letting the browser's native behavior happen (because the latter often does the wrong thing).
|
||||
|
||||
Fix an issue where backspacing out a selection on Chrome Android would sometimes only delete the last character due to event order issues.
|
||||
|
||||
`posAtCoords`, without second argument, will no longer return null for positions below or above the document.
|
||||
|
||||
## 0.19.34 (2021-12-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where content line elements would in some cases lose their `cm-line` class.
|
||||
|
||||
## 0.19.33 (2021-12-16)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`EditorView.scrollTo` and `EditorView.centerOn` are deprecated in favor of `EditorView.scrollIntoView`, and will be removed in the next breaking release.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that could cause the editor to unnecessarily interfere with composition (especially visible on macOS Chrome).
|
||||
|
||||
A composition started with multiple lines selected will no longer be interruptd by the editor.
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorView.scrollIntoView` function allows you to do more fine-grained scrolling.
|
||||
|
||||
## 0.19.32 (2021-12-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where CodeMirror's own event handers would run even after a user-supplied handler called `preventDefault` on an event.
|
||||
|
||||
Properly draw selections when negative text-indent is used for soft wrapping.
|
||||
|
||||
Fix an issue where `viewportLineBlocks` could hold inaccurate height information when the vertical scaling changed.
|
||||
|
||||
Fixes drop cursor positioning when the document is scrolled. Force a content measure when the editor comes into view
|
||||
|
||||
Fix a bug that could cause the editor to not measure its layout the first time it came into view.
|
||||
|
||||
## 0.19.31 (2021-12-13)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a `dropCursor` extension that draws a cursor at the current drop position when dragging content over the editor.
|
||||
|
||||
## 0.19.30 (2021-12-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Refine Android key event handling to work properly in a GBoard corner case where pressing Enter fires a bunch of spurious deleteContentBackward events.
|
||||
|
||||
Fix a crash in `drawSelection` for some kinds of selections.
|
||||
|
||||
Prevent a possibility where some content updates causes duplicate text to remain in DOM.
|
||||
|
||||
### New features
|
||||
|
||||
Support a `maxLength` option to `MatchDecorator` that allows user code to control how far it scans into hidden parts of viewport lines.
|
||||
|
||||
## 0.19.29 (2021-12-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that could cause out-of-view editors to get a nonsensical viewport and fail to scroll into view when asked to.
|
||||
|
||||
Fix a bug where would return 0 when clicking below the content if the last line was replaced with a block widget decoration.
|
||||
|
||||
Fix an issue where clicking at the position of the previous cursor in a blurred editor would cause the selection to reset to the start of the document.
|
||||
|
||||
Fix an issue where composition could be interrupted if the browser created a new node inside a mark decoration node.
|
||||
|
||||
## 0.19.28 (2021-12-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where pressing Enter on Chrome Android during composition did not fire key handlers for Enter.
|
||||
|
||||
Avoid a Chrome bug where the virtual keyboard closes when pressing backspace after a widget.
|
||||
|
||||
Fix an issue where the editor could show a horizontal scroll bar even after all lines that caused it had been deleted or changed.
|
||||
|
||||
## 0.19.27 (2021-12-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that could cause `EditorView.plugin` to inappropriately return `null` during plugin initialization.
|
||||
|
||||
Fix a bug where a block widget without `estimatedHeight` at the end of the document could fail to be drawn
|
||||
|
||||
## 0.19.26 (2021-12-03)
|
||||
|
||||
### New features
|
||||
|
||||
Widgets can now define a `destroy` method that is called when they are removed from the view.
|
||||
|
||||
## 0.19.25 (2021-12-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Widgets around replaced ranges are now visible when their side does not point towards the replaced range.
|
||||
|
||||
A replaced line with a line decoration no longer creates an extra empty line block in the editor.
|
||||
|
||||
The `scrollPastEnd` extension will now over-reserve space at the bottom of the editor on startup, to prevent restored scroll positions from being clipped.
|
||||
|
||||
### New features
|
||||
|
||||
`EditorView.editorAttributes` and `contentAttributes` may now hold functions that produce the attributes.
|
||||
|
||||
## 0.19.24 (2021-12-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `lineBlockAt`, for queries inside the viewport, would always return the first line in the viewport.
|
||||
|
||||
## 0.19.23 (2021-11-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where after some kinds of changes, `EditorView.viewportLineBlocks` held an out-of-date set of blocks.
|
||||
|
||||
### New features
|
||||
|
||||
Export `EditorView.documentPadding`, with information about the vertical padding of the document.
|
||||
|
||||
## 0.19.22 (2021-11-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where editors with large vertical padding (for example via `scrollPastEnd`) could sometimes lose their scroll position on Chrome.
|
||||
|
||||
Avoid some unnecessary DOM measuring work by more carefully checking whether it is needed.
|
||||
|
||||
### New features
|
||||
|
||||
The new `elementAtHeight`, `lineBlockAtHeight`, and `lineBlockAt` methods provide a simpler and more efficient replacement for the (now deprecated) `blockAtHeight`, `visualLineAtHeight`, and `visualLineAt` methods.
|
||||
|
||||
The editor view now exports a `documentTop` getter that gives you the vertical position of the top of the document. All height info is queried and reported relative to this top.
|
||||
|
||||
The editor view's new `viewportLineBlocks` property provides an array of in-viewport line blocks, and replaces the (now deprecated) `viewportLines` method.
|
||||
|
||||
## 0.19.21 (2021-11-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a problem where the DOM update would unnecessarily trigger browser relayouts.
|
||||
|
||||
## 0.19.20 (2021-11-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Run a measure cycle when the editor's size spontaneously changes.
|
||||
|
||||
## 0.19.19 (2021-11-17)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused the precedence of `editorAttributes` and `contentAttributes` to be inverted, making lower-precedence extensions override higher-precedence ones.
|
||||
|
||||
## 0.19.18 (2021-11-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the editor wasn't aware it was line-wrapping with its own `lineWrapping` extension enabled.
|
||||
|
||||
## 0.19.17 (2021-11-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid an issue where stretches of whitespace on line wrap points could cause the cursor to be placed outside of the content.
|
||||
|
||||
## 0.19.16 (2021-11-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Block replacement decorations now default to inclusive, because non-inclusive block decorations are rarely what you need.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue that caused block widgets to always have a large side value, making it impossible to show them between to replacement decorations.
|
||||
|
||||
Fix a crash that could happen after some types of viewport changes, due to a bug in the block widget view data structure.
|
||||
|
||||
## 0.19.15 (2021-11-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where the editor would think it was invisible when the document body was given screen height and scroll behavior.
|
||||
|
||||
Fix selection reading inside a shadow root on iOS.
|
||||
|
||||
## 0.19.14 (2021-11-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where typing into a read-only editor would move the selection.
|
||||
|
||||
Fix slowness when backspace is held down on iOS.
|
||||
|
||||
## 0.19.13 (2021-11-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where backspace, enter, and delete would get applied twice on iOS.
|
||||
|
||||
## 0.19.12 (2021-11-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the workaround for the lost virtual keyboard on Chrome Android also works on slower phones. Slight style change in beforeinput handler
|
||||
|
||||
Avoid failure cases in viewport-based rendering of very long lines.
|
||||
|
||||
## 0.19.11 (2021-11-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
`EditorView.scrollPosIntoView` has been deprecated. Use the `EditorView.scrollTo` effect instead.
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorView.centerOn` effect can be used to scroll a given range to the center of the view.
|
||||
|
||||
## 0.19.10 (2021-11-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't crash when `IntersectionObserver` fires its callback without any records. Try to handle some backspace issues on Chrome Android
|
||||
|
||||
Using backspace near uneditable widgets on Chrome Android should now be more reliable.
|
||||
|
||||
Work around a number of browser bugs by always rendering zero-width spaces around in-content widgets, so that browsers will treat the positions near them as valid cursor positions and not try to run composition across widget boundaries.
|
||||
|
||||
Work around bogus composition changes created by Chrome Android after handled backspace presses.
|
||||
|
||||
Work around an issue where tapping on an uneditable node in the editor would sometimes fail to show the virtual keyboard on Chrome Android.
|
||||
|
||||
Prevent translation services from translating the editor content. Show direction override characters as special chars by default
|
||||
|
||||
`specialChars` will now, by default, replace direction override chars, to mitigate https://trojansource.codes/ attacks.
|
||||
|
||||
### New features
|
||||
|
||||
The editor view will, if `parent` is given but `root` is not, derive the root from the parent element.
|
||||
|
||||
Line decorations now accept a `class` property to directly add DOM classes to the line.
|
||||
|
||||
## 0.19.9 (2021-10-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where some kinds of reflows in the surrounding document could move unrendered parts of the editor into view without the editor noticing and updating its viewport.
|
||||
|
||||
Fix an occasional crash in the selection drawing extension.
|
||||
|
||||
## 0.19.8 (2021-09-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that could, on DOM changes near block widgets, insert superfluous line breaks.
|
||||
|
||||
Make interacting with a destroyed editor view do nothing, rather than crash, to avoid tripping people up with pending timeouts and such.
|
||||
|
||||
Make sure `ViewUpdate.viewportChanged` is true whenever `visibleRanges` changes, so that plugins acting only on visible ranges can use it to check when to update.
|
||||
|
||||
Fix line-wise cut on empty lines.
|
||||
|
||||
## 0.19.7 (2021-09-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The view is now aware of the new `EditorState.readOnly` property, and suppresses events that modify the document when it is true.
|
||||
|
||||
## 0.19.6 (2021-09-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Remove a `console.log` that slipped into the previous release.
|
||||
|
||||
## 0.19.5 (2021-09-09)
|
||||
|
||||
### New features
|
||||
|
||||
The new `EditorView.scrollTo` effect can be used to scroll a given range into view.
|
||||
|
||||
## 0.19.4 (2021-09-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where lines containing just a widget decoration wrapped in a mark decoration could be displayed with 0 height.
|
||||
|
||||
## 0.19.3 (2021-08-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a view corruption that could happen in situations involving overlapping mark decorations.
|
||||
|
||||
## 0.19.2 (2021-08-23)
|
||||
|
||||
### New features
|
||||
|
||||
The package now exports a `scrollPastEnd` function, which returns an extension that adds space below the document to allow the last line to be scrolled to the top of the editor.
|
||||
|
||||
## 0.19.1 (2021-08-11)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The view now emits new-style user event annotations for the transactions it generates.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `coordsAtPos` would allow the passed `side` argument to override widget sides, producing incorrect cursor positions.
|
||||
|
||||
Fix a bug that could cause content lines to be misaligned in certain situations involving widgets at the end of lines.
|
||||
|
||||
Fix an issue where, if the browser decided to modify DOM attributes in the content in response to some editing action, the view failed to reset those again.
|
||||
|
||||
## 0.18.19 (2021-07-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression where `EditorView.editable.of(false)` didn't disable editing on Webkit-based browsers.
|
||||
|
||||
## 0.18.18 (2021-07-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused `EditorView.moveVertically` to only move by one line, even when given a custom distance, in some cases.
|
||||
|
||||
Hide Safari's native bold/italic/underline controls for the content.
|
||||
|
||||
Fix a CSS problem that prevented Safari from breaking words longer than the line in line-wrapping mode.
|
||||
|
||||
Avoid a problem where composition would be inappropriately abored on Safari.
|
||||
|
||||
Fix drag-selection that scrolls the content by dragging past the visible viewport.
|
||||
|
||||
### New features
|
||||
|
||||
`posAtCoords` now has an imprecise mode where it'll return an approximate position even for parts of the document that aren't currently rendered.
|
||||
|
||||
## 0.18.17 (2021-06-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `drawSelection` behave properly when lines are split by block widgets.
|
||||
|
||||
Make sure drawn selections that span a single line break don't leave a gap between the lines.
|
||||
|
||||
## 0.18.16 (2021-06-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash that could occur when the document changed during mouse selection.
|
||||
|
||||
Fix a bug where composition inside styled content would sometimes be inappropriately aborted by editor DOM updates.
|
||||
|
||||
### New features
|
||||
|
||||
`MouseSelectionStyle.update` may now return true to indicate it should be queried for a new selection after the update.
|
||||
|
||||
## 0.18.15 (2021-06-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would, in very specific circumstances, cause `posAtCoords` to go into an infinite loop in Safari.
|
||||
|
||||
Fix a bug where some types of IME input on Mobile Safari would drop text.
|
||||
|
||||
## 0.18.14 (2021-05-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the DOM selection was sometimes not properly updated when next to a widget.
|
||||
|
||||
Invert the order in which overlapping decorations are drawn so that higher-precedence decorations are nested inside lower-precedence ones (and thus override their styling).
|
||||
|
||||
Fix a but in `posAtCoords` where it would in some situations return -1 instead of `null`.
|
||||
|
||||
### New features
|
||||
|
||||
A new plugin field, `PluginField.atomicRanges`, can be used to cause cursor motion to skip past some ranges of the document.
|
||||
|
||||
## 0.18.13 (2021-05-20)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would cause the content DOM update to crash in specific circumstances.
|
||||
|
||||
Work around an issue where, after some types of changes, Mobile Safari would ignore Enter presses.
|
||||
|
||||
Make iOS enter and backspace handling more robust, so that platform bugs are less likely to break those keys in the editor.
|
||||
|
||||
Fix a regression where Esc + Tab no longer allowed the user to exit the editor.
|
||||
|
||||
### New features
|
||||
|
||||
You can now drop text files into the editor.
|
||||
|
||||
## 0.18.12 (2021-05-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Work around a Mobile Safari bug where, after backspacing out the last character on a line, Enter didn't work anymore.
|
||||
|
||||
Work around a problem in Mobile Safari where you couldn't tap to put the cursor at the end of a line that ended in a widget.
|
||||
|
||||
## 0.18.11 (2021-04-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Add an attribute to prevent the Grammarly browser extension from messing with the editor content.
|
||||
|
||||
Fix more issues around selection handling a Shadow DOM in Safari.
|
||||
|
||||
## 0.18.10 (2021-04-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where some types of updates wouldn't properly cause marks around the changes to be joined in the DOM.
|
||||
|
||||
Fix an issue where the content and gutters in a fixed-height editor could be smaller than the editor height.
|
||||
|
||||
Fix a crash on Safari when initializing an editor in an unfocused window.
|
||||
|
||||
Fix a bug where the editor would incorrectly conclude it was out of view in some types of absolutely positioned parent elements.
|
||||
|
||||
## 0.18.9 (2021-04-23)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash that occurred when determining DOM coordinates in some specific situations.
|
||||
|
||||
Fix a crash when a DOM change that ended at a zero-width view element (widget) removed that element from the DOM.
|
||||
|
||||
Disable autocorrect and autocapitalize by default, since in most code-editor contexts they get in the way. You can use `EditorView.contentAttributes` to override this.
|
||||
|
||||
Fix a bug that interfered with native touch selection handling on Android.
|
||||
|
||||
Fix an unnecessary DOM update after composition that would disrupt touch selection on Android.
|
||||
|
||||
Add a workaround for Safari's broken selection reporting when the editor is in a shadow DOM tree.
|
||||
|
||||
Fix select-all from the context menu on Safari.
|
||||
|
||||
## 0.18.8 (2021-04-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Handle selection replacements where the inserted text matches the start/end of the replaced text better.
|
||||
|
||||
Fix an issue where the editor would miss scroll events when it was placed in a DOM component slot.
|
||||
|
||||
## 0.18.7 (2021-04-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a crash when drag-selecting out of the editor with editable turned off.
|
||||
|
||||
Backspace and delete now largely work in an editor without a keymap.
|
||||
|
||||
Pressing backspace on iOS should now properly update the virtual keyboard's capitalize and autocorrect state.
|
||||
|
||||
Prevent random line-wrapping in (non-wrapping) editors on Mobile Safari.
|
||||
## 0.18.6 (2021-04-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue in the compiled output that would break the code when minified with terser.
|
||||
|
||||
## 0.18.5 (2021-04-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve handling of bidi text with brackets (conforming to Unicode 13's bidi algorithm).
|
||||
|
||||
Fix the position where `drawSelection` displays the cursor on bidi boundaries.
|
||||
|
||||
## 0.18.4 (2021-04-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the default focus ring gets obscured by the gutters and active line.
|
||||
|
||||
Fix an issue where the editor believed Chrome Android didn't support the CSS `tab-size` style.
|
||||
|
||||
Don't style active lines when there are non-empty selection ranges, so that the active line background doesn't obscure the selection.
|
||||
|
||||
Make iOS autocapitalize update properly when you press Enter.
|
||||
|
||||
## 0.18.3 (2021-03-19)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The outer DOM element now has class `cm-editor` instead of `cm-wrap` (`cm-wrap` will be present as well until 0.19).
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve behavior of `posAtCoords` when the position is near text but not in any character's actual box.
|
||||
|
||||
## 0.18.2 (2021-03-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Triple-clicking now selects the line break after the clicked line (if any).
|
||||
|
||||
Fix an issue where the `drawSelection` plugin would fail to draw the top line of the selection when it started in an empty line.
|
||||
|
||||
Fix an issue where, at the end of a specific type of composition on iOS, the editor read the DOM before the browser was done updating it.
|
||||
|
||||
## 0.18.1 (2021-03-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where, on iOS, some types of IME would cause the composed content to be deleted when confirming a composition.
|
||||
|
||||
## 0.18.0 (2021-03-03)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The `themeClass` function and ``-style selectors in themes are no longer supported (prefixing with `cm-` should be done manually now).
|
||||
|
||||
Themes must now use `&` (instead of an extra `$`) to target the editor wrapper element.
|
||||
|
||||
The editor no longer adds `cm-light` or `cm-dark` classes. Targeting light or dark configurations in base themes should now be done by using a `&light` or `&dark` top-level selector.
|
||||
|
||||
## 0.17.13 (2021-03-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Work around a Firefox bug where it won't draw the cursor when it is between uneditable elements.
|
||||
|
||||
Fix a bug that broke built-in mouse event handling.
|
||||
|
||||
## 0.17.12 (2021-03-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid interfering with touch events, to allow native selection behavior.
|
||||
|
||||
Fix a bug that broke sub-selectors with multiple `&` placeholders in themes.
|
||||
|
||||
## 0.17.11 (2021-02-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix vertical cursor motion on Safari with a larger line-height.
|
||||
|
||||
Fix incorrect selection drawing (with `drawSelection`) when the selection spans to just after a soft wrap point.
|
||||
|
||||
Fix an issue where compositions on Safari were inappropriately aborted in some circumstances.
|
||||
|
||||
The view will now redraw when the `EditorView.phrases` facet changes, to make sure translated text is properly updated.
|
||||
|
||||
## 0.17.10 (2021-02-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Long words without spaces, when line-wrapping is enabled, are now properly broken.
|
||||
|
||||
Fix the horizontal position of selections drawn by `drawSelection` in right-to-left editors with a scrollbar.
|
||||
|
||||
## 0.17.9 (2021-02-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where pasting linewise at the start of a line left the cursor before the inserted content.
|
||||
|
||||
## 0.17.8 (2021-02-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a problem where the DOM selection and the editor state could get out of sync in non-editable mode.
|
||||
|
||||
Fix a crash when the editor was hidden on Safari, due to `getClientRects` returning an empty list.
|
||||
|
||||
Prevent Firefox from making the scrollable element keyboard-focusable.
|
||||
|
||||
## 0.17.7 (2021-01-25)
|
||||
|
||||
### New features
|
||||
|
||||
Add an `EditorView.announce` state effect that can be used to conveniently provide screen reader announcements.
|
||||
|
||||
## 0.17.6 (2021-01-22)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Avoid creating very high scroll containers for large documents so that we don't overflow the DOM's fixed-precision numbers.
|
||||
|
||||
## 0.17.5 (2021-01-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that would create space-filling placeholders with incorrect height when document is very large.
|
||||
|
||||
## 0.17.4 (2021-01-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `drawSelection` extension will now reuse cursor DOM nodes when the number of cursors stays the same, allowing some degree of cursor transition animation.
|
||||
|
||||
Makes highlighted special characters styleable (``) and fix their default look in dark themes to have appropriate contrast.
|
||||
|
||||
### New features
|
||||
|
||||
Adds a new `MatchDecorator` helper class which can be used to easily maintain decorations on content that matches a regular expression.
|
||||
|
||||
## 0.17.3 (2021-01-06)
|
||||
|
||||
### New features
|
||||
|
||||
The package now also exports a CommonJS module.
|
||||
|
||||
## 0.17.2 (2021-01-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Work around Chrome problem where the native shift-enter behavior inserts two line breaks.
|
||||
|
||||
Make bracket closing and bracket pair removing more reliable on Android.
|
||||
|
||||
Fix bad cursor position and superfluous change transactions after pressing enter when in a composition on Android.
|
||||
|
||||
Fix issue where the wrong character was deleted when backspacing out a character before an identical copy of that character on Android.
|
||||
|
||||
## 0.17.1 (2020-12-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that prevented `ViewUpdate.focusChanged` from ever being true.
|
||||
|
||||
## 0.17.0 (2020-12-29)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
First numbered release.
|
||||
|
21
node_modules/@codemirror/view/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.
|
18
node_modules/@codemirror/view/README.md
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# @codemirror/view [](https://www.npmjs.org/package/@codemirror/view)
|
||||
|
||||
[ [**WEBSITE**](https://codemirror.net/6/) | [**DOCS**](https://codemirror.net/6/docs/ref/#view) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/view/blob/main/CHANGELOG.md) ]
|
||||
|
||||
This package implements the DOM view component for the
|
||||
[CodeMirror](https://codemirror.net/6/) code editor.
|
||||
|
||||
The [project page](https://codemirror.net/6/) has more information, a
|
||||
number of [examples](https://codemirror.net/6/examples/) and the
|
||||
[documentation](https://codemirror.net/6/docs/).
|
||||
|
||||
This code is released under an
|
||||
[MIT license](https://github.com/codemirror/view/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.
|
9021
node_modules/@codemirror/view/dist/index.cjs
generated
vendored
Normal file
1793
node_modules/@codemirror/view/dist/index.d.ts
generated
vendored
Normal file
8978
node_modules/@codemirror/view/dist/index.js
generated
vendored
Normal file
40
node_modules/@codemirror/view/package.json
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"name": "@codemirror/view",
|
||||
"version": "6.0.0",
|
||||
"description": "DOM view component for the CodeMirror code editor",
|
||||
"scripts": {
|
||||
"test": "cm-runtests",
|
||||
"prepare": "cm-buildhelper src/index.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/state": "^6.0.0",
|
||||
"style-mod": "^4.0.0",
|
||||
"w3c-keyname": "^2.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@codemirror/buildhelper": "^0.1.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/codemirror/view.git"
|
||||
}
|
||||
}
|
21
node_modules/@lezer/common/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018 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.
|
14
node_modules/@lezer/common/README.md
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# @lezer/common
|
||||
|
||||
[ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://github.com/lezer-parser/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://github.com/lezer-parser/common/blob/master/CHANGELOG.md) ]
|
||||
|
||||
[Lezer](https://lezer.codemirror.net/) is an incremental parser system
|
||||
intended for use in an editor or similar system.
|
||||
|
||||
@lezer/common provides the syntax tree data structure and parser
|
||||
abstractions for Lezer parsers.
|
||||
|
||||
Its programming interface is documented on [the
|
||||
website](https://lezer.codemirror.net/docs/ref/#common).
|
||||
|
||||
This code is licensed under an MIT license.
|
1830
node_modules/@lezer/common/dist/index.cjs
generated
vendored
Normal file
3
node_modules/@lezer/common/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
export { DefaultBufferLength, NodeProp, MountedTree, NodePropSource, NodeType, NodeSet, Tree, TreeBuffer, SyntaxNode, SyntaxNodeRef, TreeCursor, BufferCursor, NodeWeakMap, IterMode } from "./tree";
|
||||
export { ChangedRange, TreeFragment, PartialParse, Parser, Input, ParseWrapper } from "./parse";
|
||||
export { NestedParse, parseMixed } from "./mix";
|
1816
node_modules/@lezer/common/dist/index.es.js
generated
vendored
Normal file
1815
node_modules/@lezer/common/dist/index.js
generated
vendored
Normal file
13
node_modules/@lezer/common/dist/mix.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { SyntaxNodeRef } from "./tree";
|
||||
import { Input, Parser, ParseWrapper } from "./parse";
|
||||
export interface NestedParse {
|
||||
parser: Parser;
|
||||
overlay?: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[] | ((node: SyntaxNodeRef) => {
|
||||
from: number;
|
||||
to: number;
|
||||
} | boolean);
|
||||
}
|
||||
export declare function parseMixed(nest: (node: SyntaxNodeRef, input: Input) => NestedParse | null): ParseWrapper;
|
48
node_modules/@lezer/common/dist/parse.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { Tree } from "./tree";
|
||||
export interface ChangedRange {
|
||||
fromA: number;
|
||||
toA: number;
|
||||
fromB: number;
|
||||
toB: number;
|
||||
}
|
||||
export declare class TreeFragment {
|
||||
readonly from: number;
|
||||
readonly to: number;
|
||||
readonly tree: Tree;
|
||||
readonly offset: number;
|
||||
constructor(from: number, to: number, tree: Tree, offset: number, openStart?: boolean, openEnd?: boolean);
|
||||
get openStart(): boolean;
|
||||
get openEnd(): boolean;
|
||||
static addTree(tree: Tree, fragments?: readonly TreeFragment[], partial?: boolean): TreeFragment[];
|
||||
static applyChanges(fragments: readonly TreeFragment[], changes: readonly ChangedRange[], minGap?: number): readonly TreeFragment[];
|
||||
}
|
||||
export interface PartialParse {
|
||||
advance(): Tree | null;
|
||||
readonly parsedPos: number;
|
||||
stopAt(pos: number): void;
|
||||
readonly stoppedAt: number | null;
|
||||
}
|
||||
export declare abstract class Parser {
|
||||
abstract createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): PartialParse;
|
||||
startParse(input: Input | string, fragments?: readonly TreeFragment[], ranges?: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): PartialParse;
|
||||
parse(input: Input | string, fragments?: readonly TreeFragment[], ranges?: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): Tree;
|
||||
}
|
||||
export interface Input {
|
||||
readonly length: number;
|
||||
chunk(from: number): string;
|
||||
readonly lineChunks: boolean;
|
||||
read(from: number, to: number): string;
|
||||
}
|
||||
export declare type ParseWrapper = (inner: PartialParse, input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]) => PartialParse;
|
262
node_modules/@lezer/common/dist/tree.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
import { Parser } from "./parse";
|
||||
export declare const DefaultBufferLength = 1024;
|
||||
export declare class Range {
|
||||
readonly from: number;
|
||||
readonly to: number;
|
||||
constructor(from: number, to: number);
|
||||
}
|
||||
export declare class NodeProp<T> {
|
||||
perNode: boolean;
|
||||
deserialize: (str: string) => T;
|
||||
constructor(config?: {
|
||||
deserialize?: (str: string) => T;
|
||||
perNode?: boolean;
|
||||
});
|
||||
add(match: {
|
||||
[selector: string]: T;
|
||||
} | ((type: NodeType) => T | undefined)): NodePropSource;
|
||||
static closedBy: NodeProp<readonly string[]>;
|
||||
static openedBy: NodeProp<readonly string[]>;
|
||||
static group: NodeProp<readonly string[]>;
|
||||
static contextHash: NodeProp<number>;
|
||||
static lookAhead: NodeProp<number>;
|
||||
static mounted: NodeProp<MountedTree>;
|
||||
}
|
||||
export declare class MountedTree {
|
||||
readonly tree: Tree;
|
||||
readonly overlay: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[] | null;
|
||||
readonly parser: Parser;
|
||||
constructor(tree: Tree, overlay: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[] | null, parser: Parser);
|
||||
}
|
||||
export declare type NodePropSource = (type: NodeType) => null | [NodeProp<any>, any];
|
||||
export declare class NodeType {
|
||||
readonly name: string;
|
||||
readonly id: number;
|
||||
static define(spec: {
|
||||
id: number;
|
||||
name?: string;
|
||||
props?: readonly ([NodeProp<any>, any] | NodePropSource)[];
|
||||
top?: boolean;
|
||||
error?: boolean;
|
||||
skipped?: boolean;
|
||||
}): NodeType;
|
||||
prop<T>(prop: NodeProp<T>): T | undefined;
|
||||
get isTop(): boolean;
|
||||
get isSkipped(): boolean;
|
||||
get isError(): boolean;
|
||||
get isAnonymous(): boolean;
|
||||
is(name: string | number): boolean;
|
||||
static none: NodeType;
|
||||
static match<T>(map: {
|
||||
[selector: string]: T;
|
||||
}): (node: NodeType) => T | undefined;
|
||||
}
|
||||
export declare class NodeSet {
|
||||
readonly types: readonly NodeType[];
|
||||
constructor(types: readonly NodeType[]);
|
||||
extend(...props: NodePropSource[]): NodeSet;
|
||||
}
|
||||
export declare enum IterMode {
|
||||
ExcludeBuffers = 1,
|
||||
IncludeAnonymous = 2,
|
||||
IgnoreMounts = 4,
|
||||
IgnoreOverlays = 8
|
||||
}
|
||||
export declare class Tree {
|
||||
readonly type: NodeType;
|
||||
readonly children: readonly (Tree | TreeBuffer)[];
|
||||
readonly positions: readonly number[];
|
||||
readonly length: number;
|
||||
constructor(type: NodeType, children: readonly (Tree | TreeBuffer)[], positions: readonly number[], length: number, props?: readonly [NodeProp<any> | number, any][]);
|
||||
static empty: Tree;
|
||||
cursor(mode?: IterMode): TreeCursor;
|
||||
cursorAt(pos: number, side?: -1 | 0 | 1, mode?: IterMode): TreeCursor;
|
||||
get topNode(): SyntaxNode;
|
||||
resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
iterate(spec: {
|
||||
enter(node: SyntaxNodeRef): boolean | void;
|
||||
leave?(node: SyntaxNodeRef): void;
|
||||
from?: number;
|
||||
to?: number;
|
||||
mode?: IterMode;
|
||||
}): void;
|
||||
prop<T>(prop: NodeProp<T>): T | undefined;
|
||||
get propValues(): readonly [NodeProp<any> | number, any][];
|
||||
balance(config?: {
|
||||
makeTree?: (children: readonly (Tree | TreeBuffer)[], positions: readonly number[], length: number) => Tree;
|
||||
}): Tree;
|
||||
static build(data: BuildData): Tree;
|
||||
}
|
||||
declare type BuildData = {
|
||||
buffer: BufferCursor | readonly number[];
|
||||
nodeSet: NodeSet;
|
||||
topID: number;
|
||||
start?: number;
|
||||
bufferStart?: number;
|
||||
length?: number;
|
||||
maxBufferLength?: number;
|
||||
reused?: readonly Tree[];
|
||||
minRepeatType?: number;
|
||||
};
|
||||
export interface BufferCursor {
|
||||
pos: number;
|
||||
id: number;
|
||||
start: number;
|
||||
end: number;
|
||||
size: number;
|
||||
next(): void;
|
||||
fork(): BufferCursor;
|
||||
}
|
||||
export declare class TreeBuffer {
|
||||
readonly buffer: Uint16Array;
|
||||
readonly length: number;
|
||||
readonly set: NodeSet;
|
||||
constructor(buffer: Uint16Array, length: number, set: NodeSet);
|
||||
}
|
||||
export interface SyntaxNodeRef {
|
||||
readonly from: number;
|
||||
readonly to: number;
|
||||
readonly type: NodeType;
|
||||
readonly name: string;
|
||||
readonly tree: Tree | null;
|
||||
readonly node: SyntaxNode;
|
||||
matchContext(context: readonly string[]): boolean;
|
||||
}
|
||||
export interface SyntaxNode extends SyntaxNodeRef {
|
||||
parent: SyntaxNode | null;
|
||||
firstChild: SyntaxNode | null;
|
||||
lastChild: SyntaxNode | null;
|
||||
childAfter(pos: number): SyntaxNode | null;
|
||||
childBefore(pos: number): SyntaxNode | null;
|
||||
enter(pos: number, side: -1 | 0 | 1, mode?: IterMode): SyntaxNode | null;
|
||||
nextSibling: SyntaxNode | null;
|
||||
prevSibling: SyntaxNode | null;
|
||||
cursor(mode?: IterMode): TreeCursor;
|
||||
resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
enterUnfinishedNodesBefore(pos: number): SyntaxNode;
|
||||
toTree(): Tree;
|
||||
getChild(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode | null;
|
||||
getChildren(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode[];
|
||||
matchContext(context: readonly string[]): boolean;
|
||||
}
|
||||
declare const enum Side {
|
||||
Before = -2,
|
||||
AtOrBefore = -1,
|
||||
Around = 0,
|
||||
AtOrAfter = 1,
|
||||
After = 2,
|
||||
DontCare = 4
|
||||
}
|
||||
export declare class TreeNode implements SyntaxNode {
|
||||
readonly _tree: Tree;
|
||||
readonly from: number;
|
||||
readonly index: number;
|
||||
readonly _parent: TreeNode | null;
|
||||
constructor(_tree: Tree, from: number, index: number, _parent: TreeNode | null);
|
||||
get type(): NodeType;
|
||||
get name(): string;
|
||||
get to(): number;
|
||||
nextChild(i: number, dir: 1 | -1, pos: number, side: Side, mode?: IterMode): TreeNode | BufferNode | null;
|
||||
get firstChild(): TreeNode | BufferNode;
|
||||
get lastChild(): TreeNode | BufferNode;
|
||||
childAfter(pos: number): TreeNode | BufferNode;
|
||||
childBefore(pos: number): TreeNode | BufferNode;
|
||||
enter(pos: number, side: -1 | 0 | 1, mode?: number): TreeNode | BufferNode;
|
||||
nextSignificantParent(): TreeNode;
|
||||
get parent(): TreeNode | null;
|
||||
get nextSibling(): SyntaxNode | null;
|
||||
get prevSibling(): SyntaxNode | null;
|
||||
cursor(mode?: IterMode): TreeCursor;
|
||||
get tree(): Tree;
|
||||
toTree(): Tree;
|
||||
resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
enterUnfinishedNodesBefore(pos: number): SyntaxNode;
|
||||
getChild(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode;
|
||||
getChildren(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode[];
|
||||
get node(): this;
|
||||
matchContext(context: readonly string[]): boolean;
|
||||
}
|
||||
declare class BufferContext {
|
||||
readonly parent: TreeNode;
|
||||
readonly buffer: TreeBuffer;
|
||||
readonly index: number;
|
||||
readonly start: number;
|
||||
constructor(parent: TreeNode, buffer: TreeBuffer, index: number, start: number);
|
||||
}
|
||||
declare class BufferNode implements SyntaxNode {
|
||||
readonly context: BufferContext;
|
||||
readonly _parent: BufferNode | null;
|
||||
readonly index: number;
|
||||
type: NodeType;
|
||||
get name(): string;
|
||||
get from(): number;
|
||||
get to(): number;
|
||||
constructor(context: BufferContext, _parent: BufferNode | null, index: number);
|
||||
child(dir: 1 | -1, pos: number, side: Side): BufferNode | null;
|
||||
get firstChild(): BufferNode;
|
||||
get lastChild(): BufferNode;
|
||||
childAfter(pos: number): BufferNode;
|
||||
childBefore(pos: number): BufferNode;
|
||||
enter(pos: number, side: -1 | 0 | 1, mode?: IterMode): BufferNode;
|
||||
get parent(): SyntaxNode | null;
|
||||
externalSibling(dir: 1 | -1): TreeNode | BufferNode;
|
||||
get nextSibling(): SyntaxNode | null;
|
||||
get prevSibling(): SyntaxNode | null;
|
||||
cursor(mode?: IterMode): TreeCursor;
|
||||
get tree(): any;
|
||||
toTree(): Tree;
|
||||
resolve(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
resolveInner(pos: number, side?: -1 | 0 | 1): SyntaxNode;
|
||||
enterUnfinishedNodesBefore(pos: number): SyntaxNode;
|
||||
getChild(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode;
|
||||
getChildren(type: string | number, before?: string | number | null, after?: string | number | null): SyntaxNode[];
|
||||
get node(): this;
|
||||
matchContext(context: readonly string[]): boolean;
|
||||
}
|
||||
export declare class TreeCursor implements SyntaxNodeRef {
|
||||
type: NodeType;
|
||||
get name(): string;
|
||||
from: number;
|
||||
to: number;
|
||||
private stack;
|
||||
private bufferNode;
|
||||
private yieldNode;
|
||||
private yieldBuf;
|
||||
private yield;
|
||||
firstChild(): boolean;
|
||||
lastChild(): boolean;
|
||||
childAfter(pos: number): boolean;
|
||||
childBefore(pos: number): boolean;
|
||||
enter(pos: number, side: -1 | 0 | 1, mode?: IterMode): boolean;
|
||||
parent(): boolean;
|
||||
nextSibling(): boolean;
|
||||
prevSibling(): boolean;
|
||||
private atLastNode;
|
||||
private move;
|
||||
next(enter?: boolean): boolean;
|
||||
prev(enter?: boolean): boolean;
|
||||
moveTo(pos: number, side?: -1 | 0 | 1): this;
|
||||
get node(): SyntaxNode;
|
||||
get tree(): Tree | null;
|
||||
iterate(enter: (node: SyntaxNodeRef) => boolean | void, leave?: (node: SyntaxNodeRef) => void): void;
|
||||
matchContext(context: readonly string[]): boolean;
|
||||
}
|
||||
export declare class NodeWeakMap<T> {
|
||||
private map;
|
||||
private setBuffer;
|
||||
private getBuffer;
|
||||
set(node: SyntaxNode, value: T): void;
|
||||
get(node: SyntaxNode): T | undefined;
|
||||
cursorSet(cursor: TreeCursor, value: T): void;
|
||||
cursorGet(cursor: TreeCursor): T | undefined;
|
||||
}
|
||||
export {};
|
36
node_modules/@lezer/common/package.json
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "@lezer/common",
|
||||
"version": "1.0.0",
|
||||
"description": "Syntax tree data structure and parser interfaces for the lezer parser",
|
||||
"main": "dist/index.cjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"author": "Marijn Haverbeke <marijnh@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"ist": "^1.1.1",
|
||||
"rollup": "^2.52.2",
|
||||
"@rollup/plugin-commonjs": "^15.1.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"typescript": "^4.3.4",
|
||||
"@types/mocha": "^5.2.6",
|
||||
"ts-node": "^10.0.0",
|
||||
"mocha": "^9.0.1"
|
||||
},
|
||||
"files": ["dist"],
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lezer-parser/common.git"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "rollup -w -c rollup.config.js",
|
||||
"prepare": "rollup -c rollup.config.js",
|
||||
"test": "mocha"
|
||||
}
|
||||
}
|
21
node_modules/@lezer/highlight/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018 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.
|
14
node_modules/@lezer/highlight/README.md
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
# @lezer/highlight
|
||||
|
||||
[ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://github.com/lezer-parser/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://github.com/lezer-parser/highlight/blob/master/CHANGELOG.md) ]
|
||||
|
||||
[Lezer](https://lezer.codemirror.net/) is an incremental parser system
|
||||
intended for use in an editor or similar system.
|
||||
|
||||
@lezer/highlight provides a syntax highlighting framework for Lezer
|
||||
parse trees.
|
||||
|
||||
Its programming interface is documented on [the
|
||||
website](https://lezer.codemirror.net/docs/ref/#highlight).
|
||||
|
||||
This code is licensed under an MIT license.
|
108
node_modules/@lezer/highlight/dist/highlight.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
import { Tree, NodeType } from "@lezer/common";
|
||||
export declare class Tag {
|
||||
readonly set: Tag[];
|
||||
static define(parent?: Tag): Tag;
|
||||
static defineModifier(): (tag: Tag) => Tag;
|
||||
}
|
||||
export declare function styleTags(spec: {
|
||||
[selector: string]: Tag | readonly Tag[];
|
||||
}): import("@lezer/common").NodePropSource;
|
||||
export interface Highlighter {
|
||||
style(tags: readonly Tag[]): string | null;
|
||||
scope?(node: NodeType): boolean;
|
||||
}
|
||||
export declare function tagHighlighter(tags: readonly {
|
||||
tag: Tag | readonly Tag[];
|
||||
class: string;
|
||||
}[], options?: {
|
||||
scope?: (node: NodeType) => boolean;
|
||||
all?: string;
|
||||
}): Highlighter;
|
||||
export declare function highlightTree(tree: Tree, highlighter: Highlighter | readonly Highlighter[], putStyle: (from: number, to: number, classes: string) => void, from?: number, to?: number): void;
|
||||
export declare const tags: {
|
||||
comment: Tag;
|
||||
lineComment: Tag;
|
||||
blockComment: Tag;
|
||||
docComment: Tag;
|
||||
name: Tag;
|
||||
variableName: Tag;
|
||||
typeName: Tag;
|
||||
tagName: Tag;
|
||||
propertyName: Tag;
|
||||
attributeName: Tag;
|
||||
className: Tag;
|
||||
labelName: Tag;
|
||||
namespace: Tag;
|
||||
macroName: Tag;
|
||||
literal: Tag;
|
||||
string: Tag;
|
||||
docString: Tag;
|
||||
character: Tag;
|
||||
attributeValue: Tag;
|
||||
number: Tag;
|
||||
integer: Tag;
|
||||
float: Tag;
|
||||
bool: Tag;
|
||||
regexp: Tag;
|
||||
escape: Tag;
|
||||
color: Tag;
|
||||
url: Tag;
|
||||
keyword: Tag;
|
||||
self: Tag;
|
||||
null: Tag;
|
||||
atom: Tag;
|
||||
unit: Tag;
|
||||
modifier: Tag;
|
||||
operatorKeyword: Tag;
|
||||
controlKeyword: Tag;
|
||||
definitionKeyword: Tag;
|
||||
moduleKeyword: Tag;
|
||||
operator: Tag;
|
||||
derefOperator: Tag;
|
||||
arithmeticOperator: Tag;
|
||||
logicOperator: Tag;
|
||||
bitwiseOperator: Tag;
|
||||
compareOperator: Tag;
|
||||
updateOperator: Tag;
|
||||
definitionOperator: Tag;
|
||||
typeOperator: Tag;
|
||||
controlOperator: Tag;
|
||||
punctuation: Tag;
|
||||
separator: Tag;
|
||||
bracket: Tag;
|
||||
angleBracket: Tag;
|
||||
squareBracket: Tag;
|
||||
paren: Tag;
|
||||
brace: Tag;
|
||||
content: Tag;
|
||||
heading: Tag;
|
||||
heading1: Tag;
|
||||
heading2: Tag;
|
||||
heading3: Tag;
|
||||
heading4: Tag;
|
||||
heading5: Tag;
|
||||
heading6: Tag;
|
||||
contentSeparator: Tag;
|
||||
list: Tag;
|
||||
quote: Tag;
|
||||
emphasis: Tag;
|
||||
strong: Tag;
|
||||
link: Tag;
|
||||
monospace: Tag;
|
||||
strikethrough: Tag;
|
||||
inserted: Tag;
|
||||
deleted: Tag;
|
||||
changed: Tag;
|
||||
invalid: Tag;
|
||||
meta: Tag;
|
||||
documentMeta: Tag;
|
||||
annotation: Tag;
|
||||
processingInstruction: Tag;
|
||||
definition: (tag: Tag) => Tag;
|
||||
constant: (tag: Tag) => Tag;
|
||||
function: (tag: Tag) => Tag;
|
||||
standard: (tag: Tag) => Tag;
|
||||
local: (tag: Tag) => Tag;
|
||||
special: (tag: Tag) => Tag;
|
||||
};
|
||||
export declare const classHighlighter: Highlighter;
|
658
node_modules/@lezer/highlight/dist/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,658 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var common = require('@lezer/common');
|
||||
|
||||
let nextTagID = 0;
|
||||
/// Highlighting tags are markers that denote a highlighting category.
|
||||
/// They are [associated](#highlight.styleTags) with parts of a syntax
|
||||
/// tree by a language mode, and then mapped to an actual CSS style by
|
||||
/// a [highlighter](#highlight.Highlighter).
|
||||
///
|
||||
/// Because syntax tree node types and highlight styles have to be
|
||||
/// able to talk the same language, CodeMirror uses a mostly _closed_
|
||||
/// [vocabulary](#highlight.tags) of syntax tags (as opposed to
|
||||
/// traditional open string-based systems, which make it hard for
|
||||
/// highlighting themes to cover all the tokens produced by the
|
||||
/// various languages).
|
||||
///
|
||||
/// It _is_ possible to [define](#highlight.Tag^define) your own
|
||||
/// highlighting tags for system-internal use (where you control both
|
||||
/// the language package and the highlighter), but such tags will not
|
||||
/// be picked up by regular highlighters (though you can derive them
|
||||
/// from standard tags to allow highlighters to fall back to those).
|
||||
class Tag {
|
||||
/// @internal
|
||||
constructor(
|
||||
/// The set of this tag and all its parent tags, starting with
|
||||
/// this one itself and sorted in order of decreasing specificity.
|
||||
set,
|
||||
/// The base unmodified tag that this one is based on, if it's
|
||||
/// modified @internal
|
||||
base,
|
||||
/// The modifiers applied to this.base @internal
|
||||
modified) {
|
||||
this.set = set;
|
||||
this.base = base;
|
||||
this.modified = modified;
|
||||
/// @internal
|
||||
this.id = nextTagID++;
|
||||
}
|
||||
/// Define a new tag. If `parent` is given, the tag is treated as a
|
||||
/// sub-tag of that parent, and
|
||||
/// [highlighters](#highlight.tagHighlighter) that don't mention
|
||||
/// this tag will try to fall back to the parent tag (or grandparent
|
||||
/// tag, etc).
|
||||
static define(parent) {
|
||||
if (parent === null || parent === void 0 ? void 0 : parent.base)
|
||||
throw new Error("Can not derive from a modified tag");
|
||||
let tag = new Tag([], null, []);
|
||||
tag.set.push(tag);
|
||||
if (parent)
|
||||
for (let t of parent.set)
|
||||
tag.set.push(t);
|
||||
return tag;
|
||||
}
|
||||
/// Define a tag _modifier_, which is a function that, given a tag,
|
||||
/// will return a tag that is a subtag of the original. Applying the
|
||||
/// same modifier to a twice tag will return the same value (`m1(t1)
|
||||
/// == m1(t1)`) and applying multiple modifiers will, regardless or
|
||||
/// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
|
||||
///
|
||||
/// When multiple modifiers are applied to a given base tag, each
|
||||
/// smaller set of modifiers is registered as a parent, so that for
|
||||
/// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
|
||||
/// `m1(m3(t1)`, and so on.
|
||||
static defineModifier() {
|
||||
let mod = new Modifier;
|
||||
return (tag) => {
|
||||
if (tag.modified.indexOf(mod) > -1)
|
||||
return tag;
|
||||
return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
|
||||
};
|
||||
}
|
||||
}
|
||||
let nextModifierID = 0;
|
||||
class Modifier {
|
||||
constructor() {
|
||||
this.instances = [];
|
||||
this.id = nextModifierID++;
|
||||
}
|
||||
static get(base, mods) {
|
||||
if (!mods.length)
|
||||
return base;
|
||||
let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));
|
||||
if (exists)
|
||||
return exists;
|
||||
let set = [], tag = new Tag(set, base, mods);
|
||||
for (let m of mods)
|
||||
m.instances.push(tag);
|
||||
let configs = permute(mods);
|
||||
for (let parent of base.set)
|
||||
for (let config of configs)
|
||||
set.push(Modifier.get(parent, config));
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
function sameArray(a, b) {
|
||||
return a.length == b.length && a.every((x, i) => x == b[i]);
|
||||
}
|
||||
function permute(array) {
|
||||
let result = [array];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
|
||||
result.push(a);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// This function is used to add a set of tags to a language syntax
|
||||
/// via [`NodeSet.extend`](#common.NodeSet.extend) or
|
||||
/// [`LRParser.configure`](#lr.LRParser.configure).
|
||||
///
|
||||
/// The argument object maps node selectors to [highlighting
|
||||
/// tags](#highlight.Tag) or arrays of tags.
|
||||
///
|
||||
/// Node selectors may hold one or more (space-separated) node paths.
|
||||
/// Such a path can be a [node name](#common.NodeType.name), or
|
||||
/// multiple node names (or `*` wildcards) separated by slash
|
||||
/// characters, as in `"Block/Declaration/VariableName"`. Such a path
|
||||
/// matches the final node but only if its direct parent nodes are the
|
||||
/// other nodes mentioned. A `*` in such a path matches any parent,
|
||||
/// but only a single level—wildcards that match multiple parents
|
||||
/// aren't supported, both for efficiency reasons and because Lezer
|
||||
/// trees make it rather hard to reason about what they would match.)
|
||||
///
|
||||
/// A path can be ended with `/...` to indicate that the tag assigned
|
||||
/// to the node should also apply to all child nodes, even if they
|
||||
/// match their own style (by default, only the innermost style is
|
||||
/// used).
|
||||
///
|
||||
/// When a path ends in `!`, as in `Attribute!`, no further matching
|
||||
/// happens for the node's child nodes, and the entire node gets the
|
||||
/// given style.
|
||||
///
|
||||
/// In this notation, node names that contain `/`, `!`, `*`, or `...`
|
||||
/// must be quoted as JSON strings.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```javascript
|
||||
/// parser.withProps(
|
||||
/// styleTags({
|
||||
/// // Style Number and BigNumber nodes
|
||||
/// "Number BigNumber": tags.number,
|
||||
/// // Style Escape nodes whose parent is String
|
||||
/// "String/Escape": tags.escape,
|
||||
/// // Style anything inside Attributes nodes
|
||||
/// "Attributes!": tags.meta,
|
||||
/// // Add a style to all content inside Italic nodes
|
||||
/// "Italic/...": tags.emphasis,
|
||||
/// // Style InvalidString nodes as both `string` and `invalid`
|
||||
/// "InvalidString": [tags.string, tags.invalid],
|
||||
/// // Style the node named "/" as punctuation
|
||||
/// '"/"': tags.punctuation
|
||||
/// })
|
||||
/// )
|
||||
/// ```
|
||||
function styleTags(spec) {
|
||||
let byName = Object.create(null);
|
||||
for (let prop in spec) {
|
||||
let tags = spec[prop];
|
||||
if (!Array.isArray(tags))
|
||||
tags = [tags];
|
||||
for (let part of prop.split(" "))
|
||||
if (part) {
|
||||
let pieces = [], mode = 2 /* Normal */, rest = part;
|
||||
for (let pos = 0;;) {
|
||||
if (rest == "..." && pos > 0 && pos + 3 == part.length) {
|
||||
mode = 1 /* Inherit */;
|
||||
break;
|
||||
}
|
||||
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
|
||||
if (!m)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
|
||||
pos += m[0].length;
|
||||
if (pos == part.length)
|
||||
break;
|
||||
let next = part[pos++];
|
||||
if (pos == part.length && next == "!") {
|
||||
mode = 0 /* Opaque */;
|
||||
break;
|
||||
}
|
||||
if (next != "/")
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
rest = part.slice(pos);
|
||||
}
|
||||
let last = pieces.length - 1, inner = pieces[last];
|
||||
if (!inner)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
|
||||
byName[inner] = rule.sort(byName[inner]);
|
||||
}
|
||||
}
|
||||
return ruleNodeProp.add(byName);
|
||||
}
|
||||
const ruleNodeProp = new common.NodeProp();
|
||||
class Rule {
|
||||
constructor(tags, mode, context, next) {
|
||||
this.tags = tags;
|
||||
this.mode = mode;
|
||||
this.context = context;
|
||||
this.next = next;
|
||||
}
|
||||
sort(other) {
|
||||
if (!other || other.depth < this.depth) {
|
||||
this.next = other;
|
||||
return this;
|
||||
}
|
||||
other.next = this.sort(other.next);
|
||||
return other;
|
||||
}
|
||||
get depth() { return this.context ? this.context.length : 0; }
|
||||
}
|
||||
/// Define a [highlighter](#highlight.Highlighter) from an array of
|
||||
/// tag/class pairs. Classes associated with more specific tags will
|
||||
/// take precedence.
|
||||
function tagHighlighter(tags, options) {
|
||||
let map = Object.create(null);
|
||||
for (let style of tags) {
|
||||
if (!Array.isArray(style.tag))
|
||||
map[style.tag.id] = style.class;
|
||||
else
|
||||
for (let tag of style.tag)
|
||||
map[tag.id] = style.class;
|
||||
}
|
||||
let { scope, all = null } = options || {};
|
||||
return {
|
||||
style: (tags) => {
|
||||
let cls = all;
|
||||
for (let tag of tags) {
|
||||
for (let sub of tag.set) {
|
||||
let tagClass = map[sub.id];
|
||||
if (tagClass) {
|
||||
cls = cls ? cls + " " + tagClass : tagClass;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
},
|
||||
scope: scope
|
||||
};
|
||||
}
|
||||
function highlightTags(highlighters, tags) {
|
||||
let result = null;
|
||||
for (let highlighter of highlighters) {
|
||||
let value = highlighter.style(tags);
|
||||
if (value)
|
||||
result = result ? result + " " + value : value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// Highlight the given [tree](#common.Tree) with the given
|
||||
/// [highlighter](#highlight.Highlighter).
|
||||
function highlightTree(tree, highlighter,
|
||||
/// Assign styling to a region of the text. Will be called, in order
|
||||
/// of position, for any ranges where more than zero classes apply.
|
||||
/// `classes` is a space separated string of CSS classes.
|
||||
putStyle,
|
||||
/// The start of the range to highlight.
|
||||
from = 0,
|
||||
/// The end of the range.
|
||||
to = tree.length) {
|
||||
let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
|
||||
builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
|
||||
builder.flush(to);
|
||||
}
|
||||
class HighlightBuilder {
|
||||
constructor(at, highlighters, span) {
|
||||
this.at = at;
|
||||
this.highlighters = highlighters;
|
||||
this.span = span;
|
||||
this.class = "";
|
||||
}
|
||||
startSpan(at, cls) {
|
||||
if (cls != this.class) {
|
||||
this.flush(at);
|
||||
if (at > this.at)
|
||||
this.at = at;
|
||||
this.class = cls;
|
||||
}
|
||||
}
|
||||
flush(to) {
|
||||
if (to > this.at && this.class)
|
||||
this.span(this.at, to, this.class);
|
||||
}
|
||||
highlightRange(cursor, from, to, inheritedClass, highlighters) {
|
||||
let { type, from: start, to: end } = cursor;
|
||||
if (start >= to || end <= from)
|
||||
return;
|
||||
if (type.isTop)
|
||||
highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
|
||||
let cls = inheritedClass;
|
||||
let rule = type.prop(ruleNodeProp), opaque = false;
|
||||
while (rule) {
|
||||
if (!rule.context || cursor.matchContext(rule.context)) {
|
||||
let tagCls = highlightTags(highlighters, rule.tags);
|
||||
if (tagCls) {
|
||||
if (cls)
|
||||
cls += " ";
|
||||
cls += tagCls;
|
||||
if (rule.mode == 1 /* Inherit */)
|
||||
inheritedClass += (inheritedClass ? " " : "") + tagCls;
|
||||
else if (rule.mode == 0 /* Opaque */)
|
||||
opaque = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rule = rule.next;
|
||||
}
|
||||
this.startSpan(cursor.from, cls);
|
||||
if (opaque)
|
||||
return;
|
||||
let mounted = cursor.tree && cursor.tree.prop(common.NodeProp.mounted);
|
||||
if (mounted && mounted.overlay) {
|
||||
let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
|
||||
let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
|
||||
let hasChild = cursor.firstChild();
|
||||
for (let i = 0, pos = start;; i++) {
|
||||
let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
|
||||
let nextPos = next ? next.from + start : end;
|
||||
let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
|
||||
if (rangeFrom < rangeTo && hasChild) {
|
||||
while (cursor.from < rangeTo) {
|
||||
this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
if (cursor.to >= nextPos || !cursor.nextSibling())
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!next || nextPos > to)
|
||||
break;
|
||||
pos = next.to + start;
|
||||
if (pos > from) {
|
||||
this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
|
||||
this.startSpan(pos, cls);
|
||||
}
|
||||
}
|
||||
if (hasChild)
|
||||
cursor.parent();
|
||||
}
|
||||
else if (cursor.firstChild()) {
|
||||
do {
|
||||
if (cursor.to <= from)
|
||||
continue;
|
||||
if (cursor.from >= to)
|
||||
break;
|
||||
this.highlightRange(cursor, from, to, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
} while (cursor.nextSibling());
|
||||
cursor.parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
const t = Tag.define;
|
||||
const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
|
||||
/// The default set of highlighting [tags](#highlight.Tag).
|
||||
///
|
||||
/// This collection is heavily biased towards programming languages,
|
||||
/// and necessarily incomplete. A full ontology of syntactic
|
||||
/// constructs would fill a stack of books, and be impractical to
|
||||
/// write themes for. So try to make do with this set. If all else
|
||||
/// fails, [open an
|
||||
/// issue](https://github.com/codemirror/codemirror.next) to propose a
|
||||
/// new tag, or [define](#highlight.Tag^define) a local custom tag for
|
||||
/// your use case.
|
||||
///
|
||||
/// Note that it is not obligatory to always attach the most specific
|
||||
/// tag possible to an element—if your grammar can't easily
|
||||
/// distinguish a certain type of element (such as a local variable),
|
||||
/// it is okay to style it as its more general variant (a variable).
|
||||
///
|
||||
/// For tags that extend some parent tag, the documentation links to
|
||||
/// the parent.
|
||||
const tags = {
|
||||
/// A comment.
|
||||
comment,
|
||||
/// A line [comment](#highlight.tags.comment).
|
||||
lineComment: t(comment),
|
||||
/// A block [comment](#highlight.tags.comment).
|
||||
blockComment: t(comment),
|
||||
/// A documentation [comment](#highlight.tags.comment).
|
||||
docComment: t(comment),
|
||||
/// Any kind of identifier.
|
||||
name,
|
||||
/// The [name](#highlight.tags.name) of a variable.
|
||||
variableName: t(name),
|
||||
/// A type [name](#highlight.tags.name).
|
||||
typeName: typeName,
|
||||
/// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
||||
tagName: t(typeName),
|
||||
/// A property or field [name](#highlight.tags.name).
|
||||
propertyName: propertyName,
|
||||
/// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
||||
attributeName: t(propertyName),
|
||||
/// The [name](#highlight.tags.name) of a class.
|
||||
className: t(name),
|
||||
/// A label [name](#highlight.tags.name).
|
||||
labelName: t(name),
|
||||
/// A namespace [name](#highlight.tags.name).
|
||||
namespace: t(name),
|
||||
/// The [name](#highlight.tags.name) of a macro.
|
||||
macroName: t(name),
|
||||
/// A literal value.
|
||||
literal,
|
||||
/// A string [literal](#highlight.tags.literal).
|
||||
string,
|
||||
/// A documentation [string](#highlight.tags.string).
|
||||
docString: t(string),
|
||||
/// A character literal (subtag of [string](#highlight.tags.string)).
|
||||
character: t(string),
|
||||
/// An attribute value (subtag of [string](#highlight.tags.string)).
|
||||
attributeValue: t(string),
|
||||
/// A number [literal](#highlight.tags.literal).
|
||||
number,
|
||||
/// An integer [number](#highlight.tags.number) literal.
|
||||
integer: t(number),
|
||||
/// A floating-point [number](#highlight.tags.number) literal.
|
||||
float: t(number),
|
||||
/// A boolean [literal](#highlight.tags.literal).
|
||||
bool: t(literal),
|
||||
/// Regular expression [literal](#highlight.tags.literal).
|
||||
regexp: t(literal),
|
||||
/// An escape [literal](#highlight.tags.literal), for example a
|
||||
/// backslash escape in a string.
|
||||
escape: t(literal),
|
||||
/// A color [literal](#highlight.tags.literal).
|
||||
color: t(literal),
|
||||
/// A URL [literal](#highlight.tags.literal).
|
||||
url: t(literal),
|
||||
/// A language keyword.
|
||||
keyword,
|
||||
/// The [keyword](#highlight.tags.keyword) for the self or this
|
||||
/// object.
|
||||
self: t(keyword),
|
||||
/// The [keyword](#highlight.tags.keyword) for null.
|
||||
null: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) denoting some atomic value.
|
||||
atom: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that represents a unit.
|
||||
unit: t(keyword),
|
||||
/// A modifier [keyword](#highlight.tags.keyword).
|
||||
modifier: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that acts as an operator.
|
||||
operatorKeyword: t(keyword),
|
||||
/// A control-flow related [keyword](#highlight.tags.keyword).
|
||||
controlKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that defines something.
|
||||
definitionKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) related to defining or
|
||||
/// interfacing with modules.
|
||||
moduleKeyword: t(keyword),
|
||||
/// An operator.
|
||||
operator,
|
||||
/// An [operator](#highlight.tags.operator) that defines something.
|
||||
derefOperator: t(operator),
|
||||
/// Arithmetic-related [operator](#highlight.tags.operator).
|
||||
arithmeticOperator: t(operator),
|
||||
/// Logical [operator](#highlight.tags.operator).
|
||||
logicOperator: t(operator),
|
||||
/// Bit [operator](#highlight.tags.operator).
|
||||
bitwiseOperator: t(operator),
|
||||
/// Comparison [operator](#highlight.tags.operator).
|
||||
compareOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that updates its operand.
|
||||
updateOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that defines something.
|
||||
definitionOperator: t(operator),
|
||||
/// Type-related [operator](#highlight.tags.operator).
|
||||
typeOperator: t(operator),
|
||||
/// Control-flow [operator](#highlight.tags.operator).
|
||||
controlOperator: t(operator),
|
||||
/// Program or markup punctuation.
|
||||
punctuation,
|
||||
/// [Punctuation](#highlight.tags.punctuation) that separates
|
||||
/// things.
|
||||
separator: t(punctuation),
|
||||
/// Bracket-style [punctuation](#highlight.tags.punctuation).
|
||||
bracket,
|
||||
/// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
||||
/// tokens).
|
||||
angleBracket: t(bracket),
|
||||
/// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
||||
/// tokens).
|
||||
squareBracket: t(bracket),
|
||||
/// Parentheses (usually `(` and `)` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
paren: t(bracket),
|
||||
/// Braces (usually `{` and `}` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
brace: t(bracket),
|
||||
/// Content, for example plain text in XML or markup documents.
|
||||
content,
|
||||
/// [Content](#highlight.tags.content) that represents a heading.
|
||||
heading,
|
||||
/// A level 1 [heading](#highlight.tags.heading).
|
||||
heading1: t(heading),
|
||||
/// A level 2 [heading](#highlight.tags.heading).
|
||||
heading2: t(heading),
|
||||
/// A level 3 [heading](#highlight.tags.heading).
|
||||
heading3: t(heading),
|
||||
/// A level 4 [heading](#highlight.tags.heading).
|
||||
heading4: t(heading),
|
||||
/// A level 5 [heading](#highlight.tags.heading).
|
||||
heading5: t(heading),
|
||||
/// A level 6 [heading](#highlight.tags.heading).
|
||||
heading6: t(heading),
|
||||
/// A prose separator (such as a horizontal rule).
|
||||
contentSeparator: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a list.
|
||||
list: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a quote.
|
||||
quote: t(content),
|
||||
/// [Content](#highlight.tags.content) that is emphasized.
|
||||
emphasis: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled strong.
|
||||
strong: t(content),
|
||||
/// [Content](#highlight.tags.content) that is part of a link.
|
||||
link: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled as code or
|
||||
/// monospace.
|
||||
monospace: t(content),
|
||||
/// [Content](#highlight.tags.content) that has a strike-through
|
||||
/// style.
|
||||
strikethrough: t(content),
|
||||
/// Inserted text in a change-tracking format.
|
||||
inserted: t(),
|
||||
/// Deleted text.
|
||||
deleted: t(),
|
||||
/// Changed text.
|
||||
changed: t(),
|
||||
/// An invalid or unsyntactic element.
|
||||
invalid: t(),
|
||||
/// Metadata or meta-instruction.
|
||||
meta,
|
||||
/// [Metadata](#highlight.tags.meta) that applies to the entire
|
||||
/// document.
|
||||
documentMeta: t(meta),
|
||||
/// [Metadata](#highlight.tags.meta) that annotates or adds
|
||||
/// attributes to a given syntactic element.
|
||||
annotation: t(meta),
|
||||
/// Processing instruction or preprocessor directive. Subtag of
|
||||
/// [meta](#highlight.tags.meta).
|
||||
processingInstruction: t(meta),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that a
|
||||
/// given element is being defined. Expected to be used with the
|
||||
/// various [name](#highlight.tags.name) tags.
|
||||
definition: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that
|
||||
/// something is constant. Mostly expected to be used with
|
||||
/// [variable names](#highlight.tags.variableName).
|
||||
constant: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) used to indicate that
|
||||
/// a [variable](#highlight.tags.variableName) or [property
|
||||
/// name](#highlight.tags.propertyName) is being called or defined
|
||||
/// as a function.
|
||||
function: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that can be applied to
|
||||
/// [names](#highlight.tags.name) to indicate that they belong to
|
||||
/// the language's standard environment.
|
||||
standard: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates a given
|
||||
/// [names](#highlight.tags.name) is local to some scope.
|
||||
local: Tag.defineModifier(),
|
||||
/// A generic variant [modifier](#highlight.Tag^defineModifier) that
|
||||
/// can be used to tag language-specific alternative variants of
|
||||
/// some common tag. It is recommended for themes to define special
|
||||
/// forms of at least the [string](#highlight.tags.string) and
|
||||
/// [variable name](#highlight.tags.variableName) tags, since those
|
||||
/// come up a lot.
|
||||
special: Tag.defineModifier()
|
||||
};
|
||||
/// This is a highlighter that adds stable, predictable classes to
|
||||
/// tokens, for styling with external CSS.
|
||||
///
|
||||
/// The following tags are mapped to their name prefixed with `"tok-"`
|
||||
/// (for example `"tok-comment"`):
|
||||
///
|
||||
/// * [`link`](#highlight.tags.link)
|
||||
/// * [`heading`](#highlight.tags.heading)
|
||||
/// * [`emphasis`](#highlight.tags.emphasis)
|
||||
/// * [`strong`](#highlight.tags.strong)
|
||||
/// * [`keyword`](#highlight.tags.keyword)
|
||||
/// * [`atom`](#highlight.tags.atom)
|
||||
/// * [`bool`](#highlight.tags.bool)
|
||||
/// * [`url`](#highlight.tags.url)
|
||||
/// * [`labelName`](#highlight.tags.labelName)
|
||||
/// * [`inserted`](#highlight.tags.inserted)
|
||||
/// * [`deleted`](#highlight.tags.deleted)
|
||||
/// * [`literal`](#highlight.tags.literal)
|
||||
/// * [`string`](#highlight.tags.string)
|
||||
/// * [`number`](#highlight.tags.number)
|
||||
/// * [`variableName`](#highlight.tags.variableName)
|
||||
/// * [`typeName`](#highlight.tags.typeName)
|
||||
/// * [`namespace`](#highlight.tags.namespace)
|
||||
/// * [`className`](#highlight.tags.className)
|
||||
/// * [`macroName`](#highlight.tags.macroName)
|
||||
/// * [`propertyName`](#highlight.tags.propertyName)
|
||||
/// * [`operator`](#highlight.tags.operator)
|
||||
/// * [`comment`](#highlight.tags.comment)
|
||||
/// * [`meta`](#highlight.tags.meta)
|
||||
/// * [`punctuation`](#highlight.tags.punctuation)
|
||||
/// * [`invalid`](#highlight.tags.invalid)
|
||||
///
|
||||
/// In addition, these mappings are provided:
|
||||
///
|
||||
/// * [`regexp`](#highlight.tags.regexp),
|
||||
/// [`escape`](#highlight.tags.escape), and
|
||||
/// [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
|
||||
/// are mapped to `"tok-string2"`
|
||||
/// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName2"`
|
||||
/// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-local"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-definition"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
|
||||
/// to `"tok-propertyName tok-definition"`
|
||||
const classHighlighter = tagHighlighter([
|
||||
{ tag: tags.link, class: "tok-link" },
|
||||
{ tag: tags.heading, class: "tok-heading" },
|
||||
{ tag: tags.emphasis, class: "tok-emphasis" },
|
||||
{ tag: tags.strong, class: "tok-strong" },
|
||||
{ tag: tags.keyword, class: "tok-keyword" },
|
||||
{ tag: tags.atom, class: "tok-atom" },
|
||||
{ tag: tags.bool, class: "tok-bool" },
|
||||
{ tag: tags.url, class: "tok-url" },
|
||||
{ tag: tags.labelName, class: "tok-labelName" },
|
||||
{ tag: tags.inserted, class: "tok-inserted" },
|
||||
{ tag: tags.deleted, class: "tok-deleted" },
|
||||
{ tag: tags.literal, class: "tok-literal" },
|
||||
{ tag: tags.string, class: "tok-string" },
|
||||
{ tag: tags.number, class: "tok-number" },
|
||||
{ tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
|
||||
{ tag: tags.variableName, class: "tok-variableName" },
|
||||
{ tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
|
||||
{ tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
|
||||
{ tag: tags.special(tags.variableName), class: "tok-variableName2" },
|
||||
{ tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
|
||||
{ tag: tags.typeName, class: "tok-typeName" },
|
||||
{ tag: tags.namespace, class: "tok-namespace" },
|
||||
{ tag: tags.className, class: "tok-className" },
|
||||
{ tag: tags.macroName, class: "tok-macroName" },
|
||||
{ tag: tags.propertyName, class: "tok-propertyName" },
|
||||
{ tag: tags.operator, class: "tok-operator" },
|
||||
{ tag: tags.comment, class: "tok-comment" },
|
||||
{ tag: tags.meta, class: "tok-meta" },
|
||||
{ tag: tags.invalid, class: "tok-invalid" },
|
||||
{ tag: tags.punctuation, class: "tok-punctuation" }
|
||||
]);
|
||||
|
||||
exports.Tag = Tag;
|
||||
exports.classHighlighter = classHighlighter;
|
||||
exports.highlightTree = highlightTree;
|
||||
exports.styleTags = styleTags;
|
||||
exports.tagHighlighter = tagHighlighter;
|
||||
exports.tags = tags;
|
649
node_modules/@lezer/highlight/dist/index.es.js
generated
vendored
Normal file
|
@ -0,0 +1,649 @@
|
|||
import { NodeProp } from '@lezer/common';
|
||||
|
||||
let nextTagID = 0;
|
||||
/// Highlighting tags are markers that denote a highlighting category.
|
||||
/// They are [associated](#highlight.styleTags) with parts of a syntax
|
||||
/// tree by a language mode, and then mapped to an actual CSS style by
|
||||
/// a [highlighter](#highlight.Highlighter).
|
||||
///
|
||||
/// Because syntax tree node types and highlight styles have to be
|
||||
/// able to talk the same language, CodeMirror uses a mostly _closed_
|
||||
/// [vocabulary](#highlight.tags) of syntax tags (as opposed to
|
||||
/// traditional open string-based systems, which make it hard for
|
||||
/// highlighting themes to cover all the tokens produced by the
|
||||
/// various languages).
|
||||
///
|
||||
/// It _is_ possible to [define](#highlight.Tag^define) your own
|
||||
/// highlighting tags for system-internal use (where you control both
|
||||
/// the language package and the highlighter), but such tags will not
|
||||
/// be picked up by regular highlighters (though you can derive them
|
||||
/// from standard tags to allow highlighters to fall back to those).
|
||||
class Tag {
|
||||
/// @internal
|
||||
constructor(
|
||||
/// The set of this tag and all its parent tags, starting with
|
||||
/// this one itself and sorted in order of decreasing specificity.
|
||||
set,
|
||||
/// The base unmodified tag that this one is based on, if it's
|
||||
/// modified @internal
|
||||
base,
|
||||
/// The modifiers applied to this.base @internal
|
||||
modified) {
|
||||
this.set = set;
|
||||
this.base = base;
|
||||
this.modified = modified;
|
||||
/// @internal
|
||||
this.id = nextTagID++;
|
||||
}
|
||||
/// Define a new tag. If `parent` is given, the tag is treated as a
|
||||
/// sub-tag of that parent, and
|
||||
/// [highlighters](#highlight.tagHighlighter) that don't mention
|
||||
/// this tag will try to fall back to the parent tag (or grandparent
|
||||
/// tag, etc).
|
||||
static define(parent) {
|
||||
if (parent === null || parent === void 0 ? void 0 : parent.base)
|
||||
throw new Error("Can not derive from a modified tag");
|
||||
let tag = new Tag([], null, []);
|
||||
tag.set.push(tag);
|
||||
if (parent)
|
||||
for (let t of parent.set)
|
||||
tag.set.push(t);
|
||||
return tag;
|
||||
}
|
||||
/// Define a tag _modifier_, which is a function that, given a tag,
|
||||
/// will return a tag that is a subtag of the original. Applying the
|
||||
/// same modifier to a twice tag will return the same value (`m1(t1)
|
||||
/// == m1(t1)`) and applying multiple modifiers will, regardless or
|
||||
/// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
|
||||
///
|
||||
/// When multiple modifiers are applied to a given base tag, each
|
||||
/// smaller set of modifiers is registered as a parent, so that for
|
||||
/// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
|
||||
/// `m1(m3(t1)`, and so on.
|
||||
static defineModifier() {
|
||||
let mod = new Modifier;
|
||||
return (tag) => {
|
||||
if (tag.modified.indexOf(mod) > -1)
|
||||
return tag;
|
||||
return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
|
||||
};
|
||||
}
|
||||
}
|
||||
let nextModifierID = 0;
|
||||
class Modifier {
|
||||
constructor() {
|
||||
this.instances = [];
|
||||
this.id = nextModifierID++;
|
||||
}
|
||||
static get(base, mods) {
|
||||
if (!mods.length)
|
||||
return base;
|
||||
let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));
|
||||
if (exists)
|
||||
return exists;
|
||||
let set = [], tag = new Tag(set, base, mods);
|
||||
for (let m of mods)
|
||||
m.instances.push(tag);
|
||||
let configs = permute(mods);
|
||||
for (let parent of base.set)
|
||||
for (let config of configs)
|
||||
set.push(Modifier.get(parent, config));
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
function sameArray(a, b) {
|
||||
return a.length == b.length && a.every((x, i) => x == b[i]);
|
||||
}
|
||||
function permute(array) {
|
||||
let result = [array];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
|
||||
result.push(a);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// This function is used to add a set of tags to a language syntax
|
||||
/// via [`NodeSet.extend`](#common.NodeSet.extend) or
|
||||
/// [`LRParser.configure`](#lr.LRParser.configure).
|
||||
///
|
||||
/// The argument object maps node selectors to [highlighting
|
||||
/// tags](#highlight.Tag) or arrays of tags.
|
||||
///
|
||||
/// Node selectors may hold one or more (space-separated) node paths.
|
||||
/// Such a path can be a [node name](#common.NodeType.name), or
|
||||
/// multiple node names (or `*` wildcards) separated by slash
|
||||
/// characters, as in `"Block/Declaration/VariableName"`. Such a path
|
||||
/// matches the final node but only if its direct parent nodes are the
|
||||
/// other nodes mentioned. A `*` in such a path matches any parent,
|
||||
/// but only a single level—wildcards that match multiple parents
|
||||
/// aren't supported, both for efficiency reasons and because Lezer
|
||||
/// trees make it rather hard to reason about what they would match.)
|
||||
///
|
||||
/// A path can be ended with `/...` to indicate that the tag assigned
|
||||
/// to the node should also apply to all child nodes, even if they
|
||||
/// match their own style (by default, only the innermost style is
|
||||
/// used).
|
||||
///
|
||||
/// When a path ends in `!`, as in `Attribute!`, no further matching
|
||||
/// happens for the node's child nodes, and the entire node gets the
|
||||
/// given style.
|
||||
///
|
||||
/// In this notation, node names that contain `/`, `!`, `*`, or `...`
|
||||
/// must be quoted as JSON strings.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```javascript
|
||||
/// parser.withProps(
|
||||
/// styleTags({
|
||||
/// // Style Number and BigNumber nodes
|
||||
/// "Number BigNumber": tags.number,
|
||||
/// // Style Escape nodes whose parent is String
|
||||
/// "String/Escape": tags.escape,
|
||||
/// // Style anything inside Attributes nodes
|
||||
/// "Attributes!": tags.meta,
|
||||
/// // Add a style to all content inside Italic nodes
|
||||
/// "Italic/...": tags.emphasis,
|
||||
/// // Style InvalidString nodes as both `string` and `invalid`
|
||||
/// "InvalidString": [tags.string, tags.invalid],
|
||||
/// // Style the node named "/" as punctuation
|
||||
/// '"/"': tags.punctuation
|
||||
/// })
|
||||
/// )
|
||||
/// ```
|
||||
function styleTags(spec) {
|
||||
let byName = Object.create(null);
|
||||
for (let prop in spec) {
|
||||
let tags = spec[prop];
|
||||
if (!Array.isArray(tags))
|
||||
tags = [tags];
|
||||
for (let part of prop.split(" "))
|
||||
if (part) {
|
||||
let pieces = [], mode = 2 /* Normal */, rest = part;
|
||||
for (let pos = 0;;) {
|
||||
if (rest == "..." && pos > 0 && pos + 3 == part.length) {
|
||||
mode = 1 /* Inherit */;
|
||||
break;
|
||||
}
|
||||
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
|
||||
if (!m)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
|
||||
pos += m[0].length;
|
||||
if (pos == part.length)
|
||||
break;
|
||||
let next = part[pos++];
|
||||
if (pos == part.length && next == "!") {
|
||||
mode = 0 /* Opaque */;
|
||||
break;
|
||||
}
|
||||
if (next != "/")
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
rest = part.slice(pos);
|
||||
}
|
||||
let last = pieces.length - 1, inner = pieces[last];
|
||||
if (!inner)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
|
||||
byName[inner] = rule.sort(byName[inner]);
|
||||
}
|
||||
}
|
||||
return ruleNodeProp.add(byName);
|
||||
}
|
||||
const ruleNodeProp = new NodeProp();
|
||||
class Rule {
|
||||
constructor(tags, mode, context, next) {
|
||||
this.tags = tags;
|
||||
this.mode = mode;
|
||||
this.context = context;
|
||||
this.next = next;
|
||||
}
|
||||
sort(other) {
|
||||
if (!other || other.depth < this.depth) {
|
||||
this.next = other;
|
||||
return this;
|
||||
}
|
||||
other.next = this.sort(other.next);
|
||||
return other;
|
||||
}
|
||||
get depth() { return this.context ? this.context.length : 0; }
|
||||
}
|
||||
/// Define a [highlighter](#highlight.Highlighter) from an array of
|
||||
/// tag/class pairs. Classes associated with more specific tags will
|
||||
/// take precedence.
|
||||
function tagHighlighter(tags, options) {
|
||||
let map = Object.create(null);
|
||||
for (let style of tags) {
|
||||
if (!Array.isArray(style.tag))
|
||||
map[style.tag.id] = style.class;
|
||||
else
|
||||
for (let tag of style.tag)
|
||||
map[tag.id] = style.class;
|
||||
}
|
||||
let { scope, all = null } = options || {};
|
||||
return {
|
||||
style: (tags) => {
|
||||
let cls = all;
|
||||
for (let tag of tags) {
|
||||
for (let sub of tag.set) {
|
||||
let tagClass = map[sub.id];
|
||||
if (tagClass) {
|
||||
cls = cls ? cls + " " + tagClass : tagClass;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
},
|
||||
scope: scope
|
||||
};
|
||||
}
|
||||
function highlightTags(highlighters, tags) {
|
||||
let result = null;
|
||||
for (let highlighter of highlighters) {
|
||||
let value = highlighter.style(tags);
|
||||
if (value)
|
||||
result = result ? result + " " + value : value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// Highlight the given [tree](#common.Tree) with the given
|
||||
/// [highlighter](#highlight.Highlighter).
|
||||
function highlightTree(tree, highlighter,
|
||||
/// Assign styling to a region of the text. Will be called, in order
|
||||
/// of position, for any ranges where more than zero classes apply.
|
||||
/// `classes` is a space separated string of CSS classes.
|
||||
putStyle,
|
||||
/// The start of the range to highlight.
|
||||
from = 0,
|
||||
/// The end of the range.
|
||||
to = tree.length) {
|
||||
let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
|
||||
builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
|
||||
builder.flush(to);
|
||||
}
|
||||
class HighlightBuilder {
|
||||
constructor(at, highlighters, span) {
|
||||
this.at = at;
|
||||
this.highlighters = highlighters;
|
||||
this.span = span;
|
||||
this.class = "";
|
||||
}
|
||||
startSpan(at, cls) {
|
||||
if (cls != this.class) {
|
||||
this.flush(at);
|
||||
if (at > this.at)
|
||||
this.at = at;
|
||||
this.class = cls;
|
||||
}
|
||||
}
|
||||
flush(to) {
|
||||
if (to > this.at && this.class)
|
||||
this.span(this.at, to, this.class);
|
||||
}
|
||||
highlightRange(cursor, from, to, inheritedClass, highlighters) {
|
||||
let { type, from: start, to: end } = cursor;
|
||||
if (start >= to || end <= from)
|
||||
return;
|
||||
if (type.isTop)
|
||||
highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
|
||||
let cls = inheritedClass;
|
||||
let rule = type.prop(ruleNodeProp), opaque = false;
|
||||
while (rule) {
|
||||
if (!rule.context || cursor.matchContext(rule.context)) {
|
||||
let tagCls = highlightTags(highlighters, rule.tags);
|
||||
if (tagCls) {
|
||||
if (cls)
|
||||
cls += " ";
|
||||
cls += tagCls;
|
||||
if (rule.mode == 1 /* Inherit */)
|
||||
inheritedClass += (inheritedClass ? " " : "") + tagCls;
|
||||
else if (rule.mode == 0 /* Opaque */)
|
||||
opaque = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rule = rule.next;
|
||||
}
|
||||
this.startSpan(cursor.from, cls);
|
||||
if (opaque)
|
||||
return;
|
||||
let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
|
||||
if (mounted && mounted.overlay) {
|
||||
let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
|
||||
let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
|
||||
let hasChild = cursor.firstChild();
|
||||
for (let i = 0, pos = start;; i++) {
|
||||
let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
|
||||
let nextPos = next ? next.from + start : end;
|
||||
let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
|
||||
if (rangeFrom < rangeTo && hasChild) {
|
||||
while (cursor.from < rangeTo) {
|
||||
this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
if (cursor.to >= nextPos || !cursor.nextSibling())
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!next || nextPos > to)
|
||||
break;
|
||||
pos = next.to + start;
|
||||
if (pos > from) {
|
||||
this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
|
||||
this.startSpan(pos, cls);
|
||||
}
|
||||
}
|
||||
if (hasChild)
|
||||
cursor.parent();
|
||||
}
|
||||
else if (cursor.firstChild()) {
|
||||
do {
|
||||
if (cursor.to <= from)
|
||||
continue;
|
||||
if (cursor.from >= to)
|
||||
break;
|
||||
this.highlightRange(cursor, from, to, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
} while (cursor.nextSibling());
|
||||
cursor.parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
const t = Tag.define;
|
||||
const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
|
||||
/// The default set of highlighting [tags](#highlight.Tag).
|
||||
///
|
||||
/// This collection is heavily biased towards programming languages,
|
||||
/// and necessarily incomplete. A full ontology of syntactic
|
||||
/// constructs would fill a stack of books, and be impractical to
|
||||
/// write themes for. So try to make do with this set. If all else
|
||||
/// fails, [open an
|
||||
/// issue](https://github.com/codemirror/codemirror.next) to propose a
|
||||
/// new tag, or [define](#highlight.Tag^define) a local custom tag for
|
||||
/// your use case.
|
||||
///
|
||||
/// Note that it is not obligatory to always attach the most specific
|
||||
/// tag possible to an element—if your grammar can't easily
|
||||
/// distinguish a certain type of element (such as a local variable),
|
||||
/// it is okay to style it as its more general variant (a variable).
|
||||
///
|
||||
/// For tags that extend some parent tag, the documentation links to
|
||||
/// the parent.
|
||||
const tags = {
|
||||
/// A comment.
|
||||
comment,
|
||||
/// A line [comment](#highlight.tags.comment).
|
||||
lineComment: t(comment),
|
||||
/// A block [comment](#highlight.tags.comment).
|
||||
blockComment: t(comment),
|
||||
/// A documentation [comment](#highlight.tags.comment).
|
||||
docComment: t(comment),
|
||||
/// Any kind of identifier.
|
||||
name,
|
||||
/// The [name](#highlight.tags.name) of a variable.
|
||||
variableName: t(name),
|
||||
/// A type [name](#highlight.tags.name).
|
||||
typeName: typeName,
|
||||
/// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
||||
tagName: t(typeName),
|
||||
/// A property or field [name](#highlight.tags.name).
|
||||
propertyName: propertyName,
|
||||
/// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
||||
attributeName: t(propertyName),
|
||||
/// The [name](#highlight.tags.name) of a class.
|
||||
className: t(name),
|
||||
/// A label [name](#highlight.tags.name).
|
||||
labelName: t(name),
|
||||
/// A namespace [name](#highlight.tags.name).
|
||||
namespace: t(name),
|
||||
/// The [name](#highlight.tags.name) of a macro.
|
||||
macroName: t(name),
|
||||
/// A literal value.
|
||||
literal,
|
||||
/// A string [literal](#highlight.tags.literal).
|
||||
string,
|
||||
/// A documentation [string](#highlight.tags.string).
|
||||
docString: t(string),
|
||||
/// A character literal (subtag of [string](#highlight.tags.string)).
|
||||
character: t(string),
|
||||
/// An attribute value (subtag of [string](#highlight.tags.string)).
|
||||
attributeValue: t(string),
|
||||
/// A number [literal](#highlight.tags.literal).
|
||||
number,
|
||||
/// An integer [number](#highlight.tags.number) literal.
|
||||
integer: t(number),
|
||||
/// A floating-point [number](#highlight.tags.number) literal.
|
||||
float: t(number),
|
||||
/// A boolean [literal](#highlight.tags.literal).
|
||||
bool: t(literal),
|
||||
/// Regular expression [literal](#highlight.tags.literal).
|
||||
regexp: t(literal),
|
||||
/// An escape [literal](#highlight.tags.literal), for example a
|
||||
/// backslash escape in a string.
|
||||
escape: t(literal),
|
||||
/// A color [literal](#highlight.tags.literal).
|
||||
color: t(literal),
|
||||
/// A URL [literal](#highlight.tags.literal).
|
||||
url: t(literal),
|
||||
/// A language keyword.
|
||||
keyword,
|
||||
/// The [keyword](#highlight.tags.keyword) for the self or this
|
||||
/// object.
|
||||
self: t(keyword),
|
||||
/// The [keyword](#highlight.tags.keyword) for null.
|
||||
null: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) denoting some atomic value.
|
||||
atom: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that represents a unit.
|
||||
unit: t(keyword),
|
||||
/// A modifier [keyword](#highlight.tags.keyword).
|
||||
modifier: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that acts as an operator.
|
||||
operatorKeyword: t(keyword),
|
||||
/// A control-flow related [keyword](#highlight.tags.keyword).
|
||||
controlKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that defines something.
|
||||
definitionKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) related to defining or
|
||||
/// interfacing with modules.
|
||||
moduleKeyword: t(keyword),
|
||||
/// An operator.
|
||||
operator,
|
||||
/// An [operator](#highlight.tags.operator) that defines something.
|
||||
derefOperator: t(operator),
|
||||
/// Arithmetic-related [operator](#highlight.tags.operator).
|
||||
arithmeticOperator: t(operator),
|
||||
/// Logical [operator](#highlight.tags.operator).
|
||||
logicOperator: t(operator),
|
||||
/// Bit [operator](#highlight.tags.operator).
|
||||
bitwiseOperator: t(operator),
|
||||
/// Comparison [operator](#highlight.tags.operator).
|
||||
compareOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that updates its operand.
|
||||
updateOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that defines something.
|
||||
definitionOperator: t(operator),
|
||||
/// Type-related [operator](#highlight.tags.operator).
|
||||
typeOperator: t(operator),
|
||||
/// Control-flow [operator](#highlight.tags.operator).
|
||||
controlOperator: t(operator),
|
||||
/// Program or markup punctuation.
|
||||
punctuation,
|
||||
/// [Punctuation](#highlight.tags.punctuation) that separates
|
||||
/// things.
|
||||
separator: t(punctuation),
|
||||
/// Bracket-style [punctuation](#highlight.tags.punctuation).
|
||||
bracket,
|
||||
/// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
||||
/// tokens).
|
||||
angleBracket: t(bracket),
|
||||
/// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
||||
/// tokens).
|
||||
squareBracket: t(bracket),
|
||||
/// Parentheses (usually `(` and `)` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
paren: t(bracket),
|
||||
/// Braces (usually `{` and `}` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
brace: t(bracket),
|
||||
/// Content, for example plain text in XML or markup documents.
|
||||
content,
|
||||
/// [Content](#highlight.tags.content) that represents a heading.
|
||||
heading,
|
||||
/// A level 1 [heading](#highlight.tags.heading).
|
||||
heading1: t(heading),
|
||||
/// A level 2 [heading](#highlight.tags.heading).
|
||||
heading2: t(heading),
|
||||
/// A level 3 [heading](#highlight.tags.heading).
|
||||
heading3: t(heading),
|
||||
/// A level 4 [heading](#highlight.tags.heading).
|
||||
heading4: t(heading),
|
||||
/// A level 5 [heading](#highlight.tags.heading).
|
||||
heading5: t(heading),
|
||||
/// A level 6 [heading](#highlight.tags.heading).
|
||||
heading6: t(heading),
|
||||
/// A prose separator (such as a horizontal rule).
|
||||
contentSeparator: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a list.
|
||||
list: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a quote.
|
||||
quote: t(content),
|
||||
/// [Content](#highlight.tags.content) that is emphasized.
|
||||
emphasis: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled strong.
|
||||
strong: t(content),
|
||||
/// [Content](#highlight.tags.content) that is part of a link.
|
||||
link: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled as code or
|
||||
/// monospace.
|
||||
monospace: t(content),
|
||||
/// [Content](#highlight.tags.content) that has a strike-through
|
||||
/// style.
|
||||
strikethrough: t(content),
|
||||
/// Inserted text in a change-tracking format.
|
||||
inserted: t(),
|
||||
/// Deleted text.
|
||||
deleted: t(),
|
||||
/// Changed text.
|
||||
changed: t(),
|
||||
/// An invalid or unsyntactic element.
|
||||
invalid: t(),
|
||||
/// Metadata or meta-instruction.
|
||||
meta,
|
||||
/// [Metadata](#highlight.tags.meta) that applies to the entire
|
||||
/// document.
|
||||
documentMeta: t(meta),
|
||||
/// [Metadata](#highlight.tags.meta) that annotates or adds
|
||||
/// attributes to a given syntactic element.
|
||||
annotation: t(meta),
|
||||
/// Processing instruction or preprocessor directive. Subtag of
|
||||
/// [meta](#highlight.tags.meta).
|
||||
processingInstruction: t(meta),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that a
|
||||
/// given element is being defined. Expected to be used with the
|
||||
/// various [name](#highlight.tags.name) tags.
|
||||
definition: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that
|
||||
/// something is constant. Mostly expected to be used with
|
||||
/// [variable names](#highlight.tags.variableName).
|
||||
constant: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) used to indicate that
|
||||
/// a [variable](#highlight.tags.variableName) or [property
|
||||
/// name](#highlight.tags.propertyName) is being called or defined
|
||||
/// as a function.
|
||||
function: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that can be applied to
|
||||
/// [names](#highlight.tags.name) to indicate that they belong to
|
||||
/// the language's standard environment.
|
||||
standard: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates a given
|
||||
/// [names](#highlight.tags.name) is local to some scope.
|
||||
local: Tag.defineModifier(),
|
||||
/// A generic variant [modifier](#highlight.Tag^defineModifier) that
|
||||
/// can be used to tag language-specific alternative variants of
|
||||
/// some common tag. It is recommended for themes to define special
|
||||
/// forms of at least the [string](#highlight.tags.string) and
|
||||
/// [variable name](#highlight.tags.variableName) tags, since those
|
||||
/// come up a lot.
|
||||
special: Tag.defineModifier()
|
||||
};
|
||||
/// This is a highlighter that adds stable, predictable classes to
|
||||
/// tokens, for styling with external CSS.
|
||||
///
|
||||
/// The following tags are mapped to their name prefixed with `"tok-"`
|
||||
/// (for example `"tok-comment"`):
|
||||
///
|
||||
/// * [`link`](#highlight.tags.link)
|
||||
/// * [`heading`](#highlight.tags.heading)
|
||||
/// * [`emphasis`](#highlight.tags.emphasis)
|
||||
/// * [`strong`](#highlight.tags.strong)
|
||||
/// * [`keyword`](#highlight.tags.keyword)
|
||||
/// * [`atom`](#highlight.tags.atom)
|
||||
/// * [`bool`](#highlight.tags.bool)
|
||||
/// * [`url`](#highlight.tags.url)
|
||||
/// * [`labelName`](#highlight.tags.labelName)
|
||||
/// * [`inserted`](#highlight.tags.inserted)
|
||||
/// * [`deleted`](#highlight.tags.deleted)
|
||||
/// * [`literal`](#highlight.tags.literal)
|
||||
/// * [`string`](#highlight.tags.string)
|
||||
/// * [`number`](#highlight.tags.number)
|
||||
/// * [`variableName`](#highlight.tags.variableName)
|
||||
/// * [`typeName`](#highlight.tags.typeName)
|
||||
/// * [`namespace`](#highlight.tags.namespace)
|
||||
/// * [`className`](#highlight.tags.className)
|
||||
/// * [`macroName`](#highlight.tags.macroName)
|
||||
/// * [`propertyName`](#highlight.tags.propertyName)
|
||||
/// * [`operator`](#highlight.tags.operator)
|
||||
/// * [`comment`](#highlight.tags.comment)
|
||||
/// * [`meta`](#highlight.tags.meta)
|
||||
/// * [`punctuation`](#highlight.tags.punctuation)
|
||||
/// * [`invalid`](#highlight.tags.invalid)
|
||||
///
|
||||
/// In addition, these mappings are provided:
|
||||
///
|
||||
/// * [`regexp`](#highlight.tags.regexp),
|
||||
/// [`escape`](#highlight.tags.escape), and
|
||||
/// [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
|
||||
/// are mapped to `"tok-string2"`
|
||||
/// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName2"`
|
||||
/// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-local"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-definition"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
|
||||
/// to `"tok-propertyName tok-definition"`
|
||||
const classHighlighter = tagHighlighter([
|
||||
{ tag: tags.link, class: "tok-link" },
|
||||
{ tag: tags.heading, class: "tok-heading" },
|
||||
{ tag: tags.emphasis, class: "tok-emphasis" },
|
||||
{ tag: tags.strong, class: "tok-strong" },
|
||||
{ tag: tags.keyword, class: "tok-keyword" },
|
||||
{ tag: tags.atom, class: "tok-atom" },
|
||||
{ tag: tags.bool, class: "tok-bool" },
|
||||
{ tag: tags.url, class: "tok-url" },
|
||||
{ tag: tags.labelName, class: "tok-labelName" },
|
||||
{ tag: tags.inserted, class: "tok-inserted" },
|
||||
{ tag: tags.deleted, class: "tok-deleted" },
|
||||
{ tag: tags.literal, class: "tok-literal" },
|
||||
{ tag: tags.string, class: "tok-string" },
|
||||
{ tag: tags.number, class: "tok-number" },
|
||||
{ tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
|
||||
{ tag: tags.variableName, class: "tok-variableName" },
|
||||
{ tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
|
||||
{ tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
|
||||
{ tag: tags.special(tags.variableName), class: "tok-variableName2" },
|
||||
{ tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
|
||||
{ tag: tags.typeName, class: "tok-typeName" },
|
||||
{ tag: tags.namespace, class: "tok-namespace" },
|
||||
{ tag: tags.className, class: "tok-className" },
|
||||
{ tag: tags.macroName, class: "tok-macroName" },
|
||||
{ tag: tags.propertyName, class: "tok-propertyName" },
|
||||
{ tag: tags.operator, class: "tok-operator" },
|
||||
{ tag: tags.comment, class: "tok-comment" },
|
||||
{ tag: tags.meta, class: "tok-meta" },
|
||||
{ tag: tags.invalid, class: "tok-invalid" },
|
||||
{ tag: tags.punctuation, class: "tok-punctuation" }
|
||||
]);
|
||||
|
||||
export { Tag, classHighlighter, highlightTags, highlightTree, styleTags, tagHighlighter, tags };
|
649
node_modules/@lezer/highlight/dist/index.js
generated
vendored
Normal file
|
@ -0,0 +1,649 @@
|
|||
import { NodeProp } from '@lezer/common';
|
||||
|
||||
let nextTagID = 0;
|
||||
/// Highlighting tags are markers that denote a highlighting category.
|
||||
/// They are [associated](#highlight.styleTags) with parts of a syntax
|
||||
/// tree by a language mode, and then mapped to an actual CSS style by
|
||||
/// a [highlighter](#highlight.Highlighter).
|
||||
///
|
||||
/// Because syntax tree node types and highlight styles have to be
|
||||
/// able to talk the same language, CodeMirror uses a mostly _closed_
|
||||
/// [vocabulary](#highlight.tags) of syntax tags (as opposed to
|
||||
/// traditional open string-based systems, which make it hard for
|
||||
/// highlighting themes to cover all the tokens produced by the
|
||||
/// various languages).
|
||||
///
|
||||
/// It _is_ possible to [define](#highlight.Tag^define) your own
|
||||
/// highlighting tags for system-internal use (where you control both
|
||||
/// the language package and the highlighter), but such tags will not
|
||||
/// be picked up by regular highlighters (though you can derive them
|
||||
/// from standard tags to allow highlighters to fall back to those).
|
||||
class Tag {
|
||||
/// @internal
|
||||
constructor(
|
||||
/// The set of this tag and all its parent tags, starting with
|
||||
/// this one itself and sorted in order of decreasing specificity.
|
||||
set,
|
||||
/// The base unmodified tag that this one is based on, if it's
|
||||
/// modified @internal
|
||||
base,
|
||||
/// The modifiers applied to this.base @internal
|
||||
modified) {
|
||||
this.set = set;
|
||||
this.base = base;
|
||||
this.modified = modified;
|
||||
/// @internal
|
||||
this.id = nextTagID++;
|
||||
}
|
||||
/// Define a new tag. If `parent` is given, the tag is treated as a
|
||||
/// sub-tag of that parent, and
|
||||
/// [highlighters](#highlight.tagHighlighter) that don't mention
|
||||
/// this tag will try to fall back to the parent tag (or grandparent
|
||||
/// tag, etc).
|
||||
static define(parent) {
|
||||
if (parent === null || parent === void 0 ? void 0 : parent.base)
|
||||
throw new Error("Can not derive from a modified tag");
|
||||
let tag = new Tag([], null, []);
|
||||
tag.set.push(tag);
|
||||
if (parent)
|
||||
for (let t of parent.set)
|
||||
tag.set.push(t);
|
||||
return tag;
|
||||
}
|
||||
/// Define a tag _modifier_, which is a function that, given a tag,
|
||||
/// will return a tag that is a subtag of the original. Applying the
|
||||
/// same modifier to a twice tag will return the same value (`m1(t1)
|
||||
/// == m1(t1)`) and applying multiple modifiers will, regardless or
|
||||
/// order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
|
||||
///
|
||||
/// When multiple modifiers are applied to a given base tag, each
|
||||
/// smaller set of modifiers is registered as a parent, so that for
|
||||
/// example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
|
||||
/// `m1(m3(t1)`, and so on.
|
||||
static defineModifier() {
|
||||
let mod = new Modifier;
|
||||
return (tag) => {
|
||||
if (tag.modified.indexOf(mod) > -1)
|
||||
return tag;
|
||||
return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
|
||||
};
|
||||
}
|
||||
}
|
||||
let nextModifierID = 0;
|
||||
class Modifier {
|
||||
constructor() {
|
||||
this.instances = [];
|
||||
this.id = nextModifierID++;
|
||||
}
|
||||
static get(base, mods) {
|
||||
if (!mods.length)
|
||||
return base;
|
||||
let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));
|
||||
if (exists)
|
||||
return exists;
|
||||
let set = [], tag = new Tag(set, base, mods);
|
||||
for (let m of mods)
|
||||
m.instances.push(tag);
|
||||
let configs = permute(mods);
|
||||
for (let parent of base.set)
|
||||
for (let config of configs)
|
||||
set.push(Modifier.get(parent, config));
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
function sameArray(a, b) {
|
||||
return a.length == b.length && a.every((x, i) => x == b[i]);
|
||||
}
|
||||
function permute(array) {
|
||||
let result = [array];
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
for (let a of permute(array.slice(0, i).concat(array.slice(i + 1))))
|
||||
result.push(a);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// This function is used to add a set of tags to a language syntax
|
||||
/// via [`NodeSet.extend`](#common.NodeSet.extend) or
|
||||
/// [`LRParser.configure`](#lr.LRParser.configure).
|
||||
///
|
||||
/// The argument object maps node selectors to [highlighting
|
||||
/// tags](#highlight.Tag) or arrays of tags.
|
||||
///
|
||||
/// Node selectors may hold one or more (space-separated) node paths.
|
||||
/// Such a path can be a [node name](#common.NodeType.name), or
|
||||
/// multiple node names (or `*` wildcards) separated by slash
|
||||
/// characters, as in `"Block/Declaration/VariableName"`. Such a path
|
||||
/// matches the final node but only if its direct parent nodes are the
|
||||
/// other nodes mentioned. A `*` in such a path matches any parent,
|
||||
/// but only a single level—wildcards that match multiple parents
|
||||
/// aren't supported, both for efficiency reasons and because Lezer
|
||||
/// trees make it rather hard to reason about what they would match.)
|
||||
///
|
||||
/// A path can be ended with `/...` to indicate that the tag assigned
|
||||
/// to the node should also apply to all child nodes, even if they
|
||||
/// match their own style (by default, only the innermost style is
|
||||
/// used).
|
||||
///
|
||||
/// When a path ends in `!`, as in `Attribute!`, no further matching
|
||||
/// happens for the node's child nodes, and the entire node gets the
|
||||
/// given style.
|
||||
///
|
||||
/// In this notation, node names that contain `/`, `!`, `*`, or `...`
|
||||
/// must be quoted as JSON strings.
|
||||
///
|
||||
/// For example:
|
||||
///
|
||||
/// ```javascript
|
||||
/// parser.withProps(
|
||||
/// styleTags({
|
||||
/// // Style Number and BigNumber nodes
|
||||
/// "Number BigNumber": tags.number,
|
||||
/// // Style Escape nodes whose parent is String
|
||||
/// "String/Escape": tags.escape,
|
||||
/// // Style anything inside Attributes nodes
|
||||
/// "Attributes!": tags.meta,
|
||||
/// // Add a style to all content inside Italic nodes
|
||||
/// "Italic/...": tags.emphasis,
|
||||
/// // Style InvalidString nodes as both `string` and `invalid`
|
||||
/// "InvalidString": [tags.string, tags.invalid],
|
||||
/// // Style the node named "/" as punctuation
|
||||
/// '"/"': tags.punctuation
|
||||
/// })
|
||||
/// )
|
||||
/// ```
|
||||
function styleTags(spec) {
|
||||
let byName = Object.create(null);
|
||||
for (let prop in spec) {
|
||||
let tags = spec[prop];
|
||||
if (!Array.isArray(tags))
|
||||
tags = [tags];
|
||||
for (let part of prop.split(" "))
|
||||
if (part) {
|
||||
let pieces = [], mode = 2 /* Normal */, rest = part;
|
||||
for (let pos = 0;;) {
|
||||
if (rest == "..." && pos > 0 && pos + 3 == part.length) {
|
||||
mode = 1 /* Inherit */;
|
||||
break;
|
||||
}
|
||||
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
|
||||
if (!m)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
pieces.push(m[0] == "*" ? "" : m[0][0] == '"' ? JSON.parse(m[0]) : m[0]);
|
||||
pos += m[0].length;
|
||||
if (pos == part.length)
|
||||
break;
|
||||
let next = part[pos++];
|
||||
if (pos == part.length && next == "!") {
|
||||
mode = 0 /* Opaque */;
|
||||
break;
|
||||
}
|
||||
if (next != "/")
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
rest = part.slice(pos);
|
||||
}
|
||||
let last = pieces.length - 1, inner = pieces[last];
|
||||
if (!inner)
|
||||
throw new RangeError("Invalid path: " + part);
|
||||
let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);
|
||||
byName[inner] = rule.sort(byName[inner]);
|
||||
}
|
||||
}
|
||||
return ruleNodeProp.add(byName);
|
||||
}
|
||||
const ruleNodeProp = new NodeProp();
|
||||
class Rule {
|
||||
constructor(tags, mode, context, next) {
|
||||
this.tags = tags;
|
||||
this.mode = mode;
|
||||
this.context = context;
|
||||
this.next = next;
|
||||
}
|
||||
sort(other) {
|
||||
if (!other || other.depth < this.depth) {
|
||||
this.next = other;
|
||||
return this;
|
||||
}
|
||||
other.next = this.sort(other.next);
|
||||
return other;
|
||||
}
|
||||
get depth() { return this.context ? this.context.length : 0; }
|
||||
}
|
||||
/// Define a [highlighter](#highlight.Highlighter) from an array of
|
||||
/// tag/class pairs. Classes associated with more specific tags will
|
||||
/// take precedence.
|
||||
function tagHighlighter(tags, options) {
|
||||
let map = Object.create(null);
|
||||
for (let style of tags) {
|
||||
if (!Array.isArray(style.tag))
|
||||
map[style.tag.id] = style.class;
|
||||
else
|
||||
for (let tag of style.tag)
|
||||
map[tag.id] = style.class;
|
||||
}
|
||||
let { scope, all = null } = options || {};
|
||||
return {
|
||||
style: (tags) => {
|
||||
let cls = all;
|
||||
for (let tag of tags) {
|
||||
for (let sub of tag.set) {
|
||||
let tagClass = map[sub.id];
|
||||
if (tagClass) {
|
||||
cls = cls ? cls + " " + tagClass : tagClass;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
},
|
||||
scope: scope
|
||||
};
|
||||
}
|
||||
function highlightTags(highlighters, tags) {
|
||||
let result = null;
|
||||
for (let highlighter of highlighters) {
|
||||
let value = highlighter.style(tags);
|
||||
if (value)
|
||||
result = result ? result + " " + value : value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// Highlight the given [tree](#common.Tree) with the given
|
||||
/// [highlighter](#highlight.Highlighter).
|
||||
function highlightTree(tree, highlighter,
|
||||
/// Assign styling to a region of the text. Will be called, in order
|
||||
/// of position, for any ranges where more than zero classes apply.
|
||||
/// `classes` is a space separated string of CSS classes.
|
||||
putStyle,
|
||||
/// The start of the range to highlight.
|
||||
from = 0,
|
||||
/// The end of the range.
|
||||
to = tree.length) {
|
||||
let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
|
||||
builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
|
||||
builder.flush(to);
|
||||
}
|
||||
class HighlightBuilder {
|
||||
constructor(at, highlighters, span) {
|
||||
this.at = at;
|
||||
this.highlighters = highlighters;
|
||||
this.span = span;
|
||||
this.class = "";
|
||||
}
|
||||
startSpan(at, cls) {
|
||||
if (cls != this.class) {
|
||||
this.flush(at);
|
||||
if (at > this.at)
|
||||
this.at = at;
|
||||
this.class = cls;
|
||||
}
|
||||
}
|
||||
flush(to) {
|
||||
if (to > this.at && this.class)
|
||||
this.span(this.at, to, this.class);
|
||||
}
|
||||
highlightRange(cursor, from, to, inheritedClass, highlighters) {
|
||||
let { type, from: start, to: end } = cursor;
|
||||
if (start >= to || end <= from)
|
||||
return;
|
||||
if (type.isTop)
|
||||
highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));
|
||||
let cls = inheritedClass;
|
||||
let rule = type.prop(ruleNodeProp), opaque = false;
|
||||
while (rule) {
|
||||
if (!rule.context || cursor.matchContext(rule.context)) {
|
||||
let tagCls = highlightTags(highlighters, rule.tags);
|
||||
if (tagCls) {
|
||||
if (cls)
|
||||
cls += " ";
|
||||
cls += tagCls;
|
||||
if (rule.mode == 1 /* Inherit */)
|
||||
inheritedClass += (inheritedClass ? " " : "") + tagCls;
|
||||
else if (rule.mode == 0 /* Opaque */)
|
||||
opaque = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rule = rule.next;
|
||||
}
|
||||
this.startSpan(cursor.from, cls);
|
||||
if (opaque)
|
||||
return;
|
||||
let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
|
||||
if (mounted && mounted.overlay) {
|
||||
let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
|
||||
let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));
|
||||
let hasChild = cursor.firstChild();
|
||||
for (let i = 0, pos = start;; i++) {
|
||||
let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
|
||||
let nextPos = next ? next.from + start : end;
|
||||
let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
|
||||
if (rangeFrom < rangeTo && hasChild) {
|
||||
while (cursor.from < rangeTo) {
|
||||
this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
if (cursor.to >= nextPos || !cursor.nextSibling())
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!next || nextPos > to)
|
||||
break;
|
||||
pos = next.to + start;
|
||||
if (pos > from) {
|
||||
this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), inheritedClass, innerHighlighters);
|
||||
this.startSpan(pos, cls);
|
||||
}
|
||||
}
|
||||
if (hasChild)
|
||||
cursor.parent();
|
||||
}
|
||||
else if (cursor.firstChild()) {
|
||||
do {
|
||||
if (cursor.to <= from)
|
||||
continue;
|
||||
if (cursor.from >= to)
|
||||
break;
|
||||
this.highlightRange(cursor, from, to, inheritedClass, highlighters);
|
||||
this.startSpan(Math.min(to, cursor.to), cls);
|
||||
} while (cursor.nextSibling());
|
||||
cursor.parent();
|
||||
}
|
||||
}
|
||||
}
|
||||
const t = Tag.define;
|
||||
const comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();
|
||||
/// The default set of highlighting [tags](#highlight.Tag).
|
||||
///
|
||||
/// This collection is heavily biased towards programming languages,
|
||||
/// and necessarily incomplete. A full ontology of syntactic
|
||||
/// constructs would fill a stack of books, and be impractical to
|
||||
/// write themes for. So try to make do with this set. If all else
|
||||
/// fails, [open an
|
||||
/// issue](https://github.com/codemirror/codemirror.next) to propose a
|
||||
/// new tag, or [define](#highlight.Tag^define) a local custom tag for
|
||||
/// your use case.
|
||||
///
|
||||
/// Note that it is not obligatory to always attach the most specific
|
||||
/// tag possible to an element—if your grammar can't easily
|
||||
/// distinguish a certain type of element (such as a local variable),
|
||||
/// it is okay to style it as its more general variant (a variable).
|
||||
///
|
||||
/// For tags that extend some parent tag, the documentation links to
|
||||
/// the parent.
|
||||
const tags = {
|
||||
/// A comment.
|
||||
comment,
|
||||
/// A line [comment](#highlight.tags.comment).
|
||||
lineComment: t(comment),
|
||||
/// A block [comment](#highlight.tags.comment).
|
||||
blockComment: t(comment),
|
||||
/// A documentation [comment](#highlight.tags.comment).
|
||||
docComment: t(comment),
|
||||
/// Any kind of identifier.
|
||||
name,
|
||||
/// The [name](#highlight.tags.name) of a variable.
|
||||
variableName: t(name),
|
||||
/// A type [name](#highlight.tags.name).
|
||||
typeName: typeName,
|
||||
/// A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
||||
tagName: t(typeName),
|
||||
/// A property or field [name](#highlight.tags.name).
|
||||
propertyName: propertyName,
|
||||
/// An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
||||
attributeName: t(propertyName),
|
||||
/// The [name](#highlight.tags.name) of a class.
|
||||
className: t(name),
|
||||
/// A label [name](#highlight.tags.name).
|
||||
labelName: t(name),
|
||||
/// A namespace [name](#highlight.tags.name).
|
||||
namespace: t(name),
|
||||
/// The [name](#highlight.tags.name) of a macro.
|
||||
macroName: t(name),
|
||||
/// A literal value.
|
||||
literal,
|
||||
/// A string [literal](#highlight.tags.literal).
|
||||
string,
|
||||
/// A documentation [string](#highlight.tags.string).
|
||||
docString: t(string),
|
||||
/// A character literal (subtag of [string](#highlight.tags.string)).
|
||||
character: t(string),
|
||||
/// An attribute value (subtag of [string](#highlight.tags.string)).
|
||||
attributeValue: t(string),
|
||||
/// A number [literal](#highlight.tags.literal).
|
||||
number,
|
||||
/// An integer [number](#highlight.tags.number) literal.
|
||||
integer: t(number),
|
||||
/// A floating-point [number](#highlight.tags.number) literal.
|
||||
float: t(number),
|
||||
/// A boolean [literal](#highlight.tags.literal).
|
||||
bool: t(literal),
|
||||
/// Regular expression [literal](#highlight.tags.literal).
|
||||
regexp: t(literal),
|
||||
/// An escape [literal](#highlight.tags.literal), for example a
|
||||
/// backslash escape in a string.
|
||||
escape: t(literal),
|
||||
/// A color [literal](#highlight.tags.literal).
|
||||
color: t(literal),
|
||||
/// A URL [literal](#highlight.tags.literal).
|
||||
url: t(literal),
|
||||
/// A language keyword.
|
||||
keyword,
|
||||
/// The [keyword](#highlight.tags.keyword) for the self or this
|
||||
/// object.
|
||||
self: t(keyword),
|
||||
/// The [keyword](#highlight.tags.keyword) for null.
|
||||
null: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) denoting some atomic value.
|
||||
atom: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that represents a unit.
|
||||
unit: t(keyword),
|
||||
/// A modifier [keyword](#highlight.tags.keyword).
|
||||
modifier: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that acts as an operator.
|
||||
operatorKeyword: t(keyword),
|
||||
/// A control-flow related [keyword](#highlight.tags.keyword).
|
||||
controlKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) that defines something.
|
||||
definitionKeyword: t(keyword),
|
||||
/// A [keyword](#highlight.tags.keyword) related to defining or
|
||||
/// interfacing with modules.
|
||||
moduleKeyword: t(keyword),
|
||||
/// An operator.
|
||||
operator,
|
||||
/// An [operator](#highlight.tags.operator) that defines something.
|
||||
derefOperator: t(operator),
|
||||
/// Arithmetic-related [operator](#highlight.tags.operator).
|
||||
arithmeticOperator: t(operator),
|
||||
/// Logical [operator](#highlight.tags.operator).
|
||||
logicOperator: t(operator),
|
||||
/// Bit [operator](#highlight.tags.operator).
|
||||
bitwiseOperator: t(operator),
|
||||
/// Comparison [operator](#highlight.tags.operator).
|
||||
compareOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that updates its operand.
|
||||
updateOperator: t(operator),
|
||||
/// [Operator](#highlight.tags.operator) that defines something.
|
||||
definitionOperator: t(operator),
|
||||
/// Type-related [operator](#highlight.tags.operator).
|
||||
typeOperator: t(operator),
|
||||
/// Control-flow [operator](#highlight.tags.operator).
|
||||
controlOperator: t(operator),
|
||||
/// Program or markup punctuation.
|
||||
punctuation,
|
||||
/// [Punctuation](#highlight.tags.punctuation) that separates
|
||||
/// things.
|
||||
separator: t(punctuation),
|
||||
/// Bracket-style [punctuation](#highlight.tags.punctuation).
|
||||
bracket,
|
||||
/// Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
||||
/// tokens).
|
||||
angleBracket: t(bracket),
|
||||
/// Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
||||
/// tokens).
|
||||
squareBracket: t(bracket),
|
||||
/// Parentheses (usually `(` and `)` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
paren: t(bracket),
|
||||
/// Braces (usually `{` and `}` tokens). Subtag of
|
||||
/// [bracket](#highlight.tags.bracket).
|
||||
brace: t(bracket),
|
||||
/// Content, for example plain text in XML or markup documents.
|
||||
content,
|
||||
/// [Content](#highlight.tags.content) that represents a heading.
|
||||
heading,
|
||||
/// A level 1 [heading](#highlight.tags.heading).
|
||||
heading1: t(heading),
|
||||
/// A level 2 [heading](#highlight.tags.heading).
|
||||
heading2: t(heading),
|
||||
/// A level 3 [heading](#highlight.tags.heading).
|
||||
heading3: t(heading),
|
||||
/// A level 4 [heading](#highlight.tags.heading).
|
||||
heading4: t(heading),
|
||||
/// A level 5 [heading](#highlight.tags.heading).
|
||||
heading5: t(heading),
|
||||
/// A level 6 [heading](#highlight.tags.heading).
|
||||
heading6: t(heading),
|
||||
/// A prose separator (such as a horizontal rule).
|
||||
contentSeparator: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a list.
|
||||
list: t(content),
|
||||
/// [Content](#highlight.tags.content) that represents a quote.
|
||||
quote: t(content),
|
||||
/// [Content](#highlight.tags.content) that is emphasized.
|
||||
emphasis: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled strong.
|
||||
strong: t(content),
|
||||
/// [Content](#highlight.tags.content) that is part of a link.
|
||||
link: t(content),
|
||||
/// [Content](#highlight.tags.content) that is styled as code or
|
||||
/// monospace.
|
||||
monospace: t(content),
|
||||
/// [Content](#highlight.tags.content) that has a strike-through
|
||||
/// style.
|
||||
strikethrough: t(content),
|
||||
/// Inserted text in a change-tracking format.
|
||||
inserted: t(),
|
||||
/// Deleted text.
|
||||
deleted: t(),
|
||||
/// Changed text.
|
||||
changed: t(),
|
||||
/// An invalid or unsyntactic element.
|
||||
invalid: t(),
|
||||
/// Metadata or meta-instruction.
|
||||
meta,
|
||||
/// [Metadata](#highlight.tags.meta) that applies to the entire
|
||||
/// document.
|
||||
documentMeta: t(meta),
|
||||
/// [Metadata](#highlight.tags.meta) that annotates or adds
|
||||
/// attributes to a given syntactic element.
|
||||
annotation: t(meta),
|
||||
/// Processing instruction or preprocessor directive. Subtag of
|
||||
/// [meta](#highlight.tags.meta).
|
||||
processingInstruction: t(meta),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that a
|
||||
/// given element is being defined. Expected to be used with the
|
||||
/// various [name](#highlight.tags.name) tags.
|
||||
definition: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates that
|
||||
/// something is constant. Mostly expected to be used with
|
||||
/// [variable names](#highlight.tags.variableName).
|
||||
constant: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) used to indicate that
|
||||
/// a [variable](#highlight.tags.variableName) or [property
|
||||
/// name](#highlight.tags.propertyName) is being called or defined
|
||||
/// as a function.
|
||||
function: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that can be applied to
|
||||
/// [names](#highlight.tags.name) to indicate that they belong to
|
||||
/// the language's standard environment.
|
||||
standard: Tag.defineModifier(),
|
||||
/// [Modifier](#highlight.Tag^defineModifier) that indicates a given
|
||||
/// [names](#highlight.tags.name) is local to some scope.
|
||||
local: Tag.defineModifier(),
|
||||
/// A generic variant [modifier](#highlight.Tag^defineModifier) that
|
||||
/// can be used to tag language-specific alternative variants of
|
||||
/// some common tag. It is recommended for themes to define special
|
||||
/// forms of at least the [string](#highlight.tags.string) and
|
||||
/// [variable name](#highlight.tags.variableName) tags, since those
|
||||
/// come up a lot.
|
||||
special: Tag.defineModifier()
|
||||
};
|
||||
/// This is a highlighter that adds stable, predictable classes to
|
||||
/// tokens, for styling with external CSS.
|
||||
///
|
||||
/// The following tags are mapped to their name prefixed with `"tok-"`
|
||||
/// (for example `"tok-comment"`):
|
||||
///
|
||||
/// * [`link`](#highlight.tags.link)
|
||||
/// * [`heading`](#highlight.tags.heading)
|
||||
/// * [`emphasis`](#highlight.tags.emphasis)
|
||||
/// * [`strong`](#highlight.tags.strong)
|
||||
/// * [`keyword`](#highlight.tags.keyword)
|
||||
/// * [`atom`](#highlight.tags.atom)
|
||||
/// * [`bool`](#highlight.tags.bool)
|
||||
/// * [`url`](#highlight.tags.url)
|
||||
/// * [`labelName`](#highlight.tags.labelName)
|
||||
/// * [`inserted`](#highlight.tags.inserted)
|
||||
/// * [`deleted`](#highlight.tags.deleted)
|
||||
/// * [`literal`](#highlight.tags.literal)
|
||||
/// * [`string`](#highlight.tags.string)
|
||||
/// * [`number`](#highlight.tags.number)
|
||||
/// * [`variableName`](#highlight.tags.variableName)
|
||||
/// * [`typeName`](#highlight.tags.typeName)
|
||||
/// * [`namespace`](#highlight.tags.namespace)
|
||||
/// * [`className`](#highlight.tags.className)
|
||||
/// * [`macroName`](#highlight.tags.macroName)
|
||||
/// * [`propertyName`](#highlight.tags.propertyName)
|
||||
/// * [`operator`](#highlight.tags.operator)
|
||||
/// * [`comment`](#highlight.tags.comment)
|
||||
/// * [`meta`](#highlight.tags.meta)
|
||||
/// * [`punctuation`](#highlight.tags.punctuation)
|
||||
/// * [`invalid`](#highlight.tags.invalid)
|
||||
///
|
||||
/// In addition, these mappings are provided:
|
||||
///
|
||||
/// * [`regexp`](#highlight.tags.regexp),
|
||||
/// [`escape`](#highlight.tags.escape), and
|
||||
/// [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)
|
||||
/// are mapped to `"tok-string2"`
|
||||
/// * [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName2"`
|
||||
/// * [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-local"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)
|
||||
/// to `"tok-variableName tok-definition"`
|
||||
/// * [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)
|
||||
/// to `"tok-propertyName tok-definition"`
|
||||
const classHighlighter = tagHighlighter([
|
||||
{ tag: tags.link, class: "tok-link" },
|
||||
{ tag: tags.heading, class: "tok-heading" },
|
||||
{ tag: tags.emphasis, class: "tok-emphasis" },
|
||||
{ tag: tags.strong, class: "tok-strong" },
|
||||
{ tag: tags.keyword, class: "tok-keyword" },
|
||||
{ tag: tags.atom, class: "tok-atom" },
|
||||
{ tag: tags.bool, class: "tok-bool" },
|
||||
{ tag: tags.url, class: "tok-url" },
|
||||
{ tag: tags.labelName, class: "tok-labelName" },
|
||||
{ tag: tags.inserted, class: "tok-inserted" },
|
||||
{ tag: tags.deleted, class: "tok-deleted" },
|
||||
{ tag: tags.literal, class: "tok-literal" },
|
||||
{ tag: tags.string, class: "tok-string" },
|
||||
{ tag: tags.number, class: "tok-number" },
|
||||
{ tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: "tok-string2" },
|
||||
{ tag: tags.variableName, class: "tok-variableName" },
|
||||
{ tag: tags.local(tags.variableName), class: "tok-variableName tok-local" },
|
||||
{ tag: tags.definition(tags.variableName), class: "tok-variableName tok-definition" },
|
||||
{ tag: tags.special(tags.variableName), class: "tok-variableName2" },
|
||||
{ tag: tags.definition(tags.propertyName), class: "tok-propertyName tok-definition" },
|
||||
{ tag: tags.typeName, class: "tok-typeName" },
|
||||
{ tag: tags.namespace, class: "tok-namespace" },
|
||||
{ tag: tags.className, class: "tok-className" },
|
||||
{ tag: tags.macroName, class: "tok-macroName" },
|
||||
{ tag: tags.propertyName, class: "tok-propertyName" },
|
||||
{ tag: tags.operator, class: "tok-operator" },
|
||||
{ tag: tags.comment, class: "tok-comment" },
|
||||
{ tag: tags.meta, class: "tok-meta" },
|
||||
{ tag: tags.invalid, class: "tok-invalid" },
|
||||
{ tag: tags.punctuation, class: "tok-punctuation" }
|
||||
]);
|
||||
|
||||
export { Tag, classHighlighter, highlightTree, styleTags, tagHighlighter, tags };
|
34
node_modules/@lezer/highlight/package.json
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "@lezer/highlight",
|
||||
"version": "1.0.0",
|
||||
"description": "Highlighting system for Lezer parse trees",
|
||||
"main": "dist/index.cjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/highlight.d.ts",
|
||||
"author": "Marijn Haverbeke <marijnh@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"rollup": "^2.52.2",
|
||||
"@rollup/plugin-commonjs": "^15.1.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"typescript": "^4.3.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
"files": ["dist"],
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lezer-parser/highlight.git"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "rollup -w -c rollup.config.js",
|
||||
"prepare": "rollup -c rollup.config.js"
|
||||
}
|
||||
}
|
21
node_modules/@lezer/lr/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (C) 2018 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.
|
25
node_modules/@lezer/lr/README.md
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
# @lezer/lr
|
||||
|
||||
[ [**WEBSITE**](http://lezer.codemirror.net) | [**ISSUES**](https://github.com/lezer-parser/lezer/issues) | [**FORUM**](https://discuss.codemirror.net/c/lezer) | [**CHANGELOG**](https://github.com/lezer-parser/lr/blob/master/CHANGELOG.md) ]
|
||||
|
||||
Lezer ("reader" in Dutch, pronounced pretty much as laser) is an
|
||||
incremental GLR parser intended for use in an editor or similar
|
||||
system, which needs to keep a representation of the program current
|
||||
during changes and in the face of syntax errors.
|
||||
|
||||
It prioritizes speed and compactness (both of parser table files and
|
||||
of syntax tree) over having a highly usable parse tree—trees nodes are
|
||||
just blobs with a start, end, tag, and set of child nodes, with no
|
||||
further labeling of child nodes or extra metadata.
|
||||
|
||||
This package contains the run-time LR parser library. It consumes
|
||||
parsers generated by
|
||||
[@lezer/generator](https://github.com/lezer-parser/generator).
|
||||
|
||||
The parser programming interface is documented on [the
|
||||
website](https://lezer.codemirror.net/docs/ref/#lr).
|
||||
|
||||
The code is licensed under an MIT license.
|
||||
|
||||
This project was hugely inspired by
|
||||
[tree-sitter](http://tree-sitter.github.io/tree-sitter/).
|
45
node_modules/@lezer/lr/dist/constants.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
export declare const enum Action {
|
||||
ReduceFlag = 65536,
|
||||
ValueMask = 65535,
|
||||
ReduceDepthShift = 19,
|
||||
RepeatFlag = 131072,
|
||||
GotoFlag = 131072,
|
||||
StayFlag = 262144
|
||||
}
|
||||
export declare const enum StateFlag {
|
||||
Skipped = 1,
|
||||
Accepting = 2
|
||||
}
|
||||
export declare const enum Specialize {
|
||||
Specialize = 0,
|
||||
Extend = 1
|
||||
}
|
||||
export declare const enum Term {
|
||||
Err = 0
|
||||
}
|
||||
export declare const enum Seq {
|
||||
End = 65535,
|
||||
Done = 0,
|
||||
Next = 1,
|
||||
Other = 2
|
||||
}
|
||||
export declare const enum ParseState {
|
||||
Flags = 0,
|
||||
Actions = 1,
|
||||
Skip = 2,
|
||||
TokenizerMask = 3,
|
||||
DefaultReduce = 4,
|
||||
ForcedReduce = 5,
|
||||
Size = 6
|
||||
}
|
||||
export declare const enum Encode {
|
||||
BigValCode = 126,
|
||||
BigVal = 65535,
|
||||
Start = 32,
|
||||
Gap1 = 34,
|
||||
Gap2 = 92,
|
||||
Base = 46
|
||||
}
|
||||
export declare const enum File {
|
||||
Version = 14
|
||||
}
|
5
node_modules/@lezer/lr/dist/decode.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
export declare function decodeArray<T extends {
|
||||
[i: number]: number;
|
||||
} = Uint16Array>(input: string | T, Type?: {
|
||||
new (n: number): T;
|
||||
}): T;
|
1600
node_modules/@lezer/lr/dist/index.cjs
generated
vendored
Normal file
3
node_modules/@lezer/lr/dist/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
export { LRParser, ParserConfig, ContextTracker } from "./parse";
|
||||
export { InputStream, ExternalTokenizer } from "./token";
|
||||
export { Stack } from "./stack";
|
1590
node_modules/@lezer/lr/dist/index.es.js
generated
vendored
Normal file
1592
node_modules/@lezer/lr/dist/index.js
generated
vendored
Normal file
102
node_modules/@lezer/lr/dist/parse.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
import { Tree, TreeFragment, NodeSet, NodeType, NodePropSource, Input, PartialParse, Parser, ParseWrapper } from "@lezer/common";
|
||||
import { Stack } from "./stack";
|
||||
import { Tokenizer, ExternalTokenizer, CachedToken, InputStream } from "./token";
|
||||
declare class FragmentCursor {
|
||||
readonly fragments: readonly TreeFragment[];
|
||||
readonly nodeSet: NodeSet;
|
||||
i: number;
|
||||
fragment: TreeFragment | null;
|
||||
safeFrom: number;
|
||||
safeTo: number;
|
||||
trees: Tree[];
|
||||
start: number[];
|
||||
index: number[];
|
||||
nextStart: number;
|
||||
constructor(fragments: readonly TreeFragment[], nodeSet: NodeSet);
|
||||
nextFragment(): void;
|
||||
nodeAt(pos: number): Tree | null;
|
||||
}
|
||||
declare class TokenCache {
|
||||
readonly stream: InputStream;
|
||||
tokens: CachedToken[];
|
||||
mainToken: CachedToken | null;
|
||||
actions: number[];
|
||||
constructor(parser: LRParser, stream: InputStream);
|
||||
getActions(stack: Stack): number[];
|
||||
getMainToken(stack: Stack): CachedToken;
|
||||
updateCachedToken(token: CachedToken, tokenizer: Tokenizer, stack: Stack): void;
|
||||
putAction(action: number, token: number, end: number, index: number): number;
|
||||
addActions(stack: Stack, token: number, end: number, index: number): number;
|
||||
}
|
||||
export declare class Parse implements PartialParse {
|
||||
readonly parser: LRParser;
|
||||
readonly input: Input;
|
||||
readonly ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[];
|
||||
stacks: Stack[];
|
||||
recovering: number;
|
||||
fragments: FragmentCursor | null;
|
||||
nextStackID: number;
|
||||
minStackPos: number;
|
||||
reused: Tree[];
|
||||
stream: InputStream;
|
||||
tokens: TokenCache;
|
||||
topTerm: number;
|
||||
stoppedAt: null | number;
|
||||
constructor(parser: LRParser, input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]);
|
||||
get parsedPos(): number;
|
||||
advance(): Tree;
|
||||
stopAt(pos: number): void;
|
||||
private advanceStack;
|
||||
private advanceFully;
|
||||
private runRecovery;
|
||||
stackToTree(stack: Stack): Tree;
|
||||
private stackID;
|
||||
}
|
||||
export declare class Dialect {
|
||||
readonly source: string | undefined;
|
||||
readonly flags: readonly boolean[];
|
||||
readonly disabled: null | Uint8Array;
|
||||
constructor(source: string | undefined, flags: readonly boolean[], disabled: null | Uint8Array);
|
||||
allows(term: number): boolean;
|
||||
}
|
||||
export declare class ContextTracker<T> {
|
||||
constructor(spec: {
|
||||
start: T;
|
||||
shift?(context: T, term: number, stack: Stack, input: InputStream): T;
|
||||
reduce?(context: T, term: number, stack: Stack, input: InputStream): T;
|
||||
reuse?(context: T, node: Tree, stack: Stack, input: InputStream): T;
|
||||
hash?(context: T): number;
|
||||
strict?: boolean;
|
||||
});
|
||||
}
|
||||
export interface ParserConfig {
|
||||
props?: readonly NodePropSource[];
|
||||
top?: string;
|
||||
dialect?: string;
|
||||
tokenizers?: {
|
||||
from: ExternalTokenizer;
|
||||
to: ExternalTokenizer;
|
||||
}[];
|
||||
contextTracker?: ContextTracker<any>;
|
||||
strict?: boolean;
|
||||
wrap?: ParseWrapper;
|
||||
bufferLength?: number;
|
||||
}
|
||||
export declare class LRParser extends Parser {
|
||||
readonly nodeSet: NodeSet;
|
||||
createParse(input: Input, fragments: readonly TreeFragment[], ranges: readonly {
|
||||
from: number;
|
||||
to: number;
|
||||
}[]): PartialParse;
|
||||
configure(config: ParserConfig): LRParser;
|
||||
hasWrappers(): boolean;
|
||||
getName(term: number): string;
|
||||
get topNode(): NodeType;
|
||||
}
|
||||
export {};
|
34
node_modules/@lezer/lr/dist/stack.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { BufferCursor } from "@lezer/common";
|
||||
export declare class Stack {
|
||||
pos: number;
|
||||
get context(): any;
|
||||
canShift(term: number): boolean;
|
||||
get parser(): import("./parse").LRParser;
|
||||
dialectEnabled(dialectID: number): boolean;
|
||||
private shiftContext;
|
||||
private reduceContext;
|
||||
private updateContext;
|
||||
}
|
||||
export declare const enum Recover {
|
||||
Insert = 200,
|
||||
Delete = 190,
|
||||
Reduce = 100,
|
||||
MaxNext = 4,
|
||||
MaxInsertStackDepth = 300,
|
||||
DampenInsertStackDepth = 120
|
||||
}
|
||||
export declare class StackBufferCursor implements BufferCursor {
|
||||
stack: Stack;
|
||||
pos: number;
|
||||
index: number;
|
||||
buffer: number[];
|
||||
constructor(stack: Stack, pos: number, index: number);
|
||||
static create(stack: Stack, pos?: number): StackBufferCursor;
|
||||
maybeNext(): void;
|
||||
get id(): number;
|
||||
get start(): number;
|
||||
get end(): number;
|
||||
get size(): number;
|
||||
next(): void;
|
||||
fork(): StackBufferCursor;
|
||||
}
|
35
node_modules/@lezer/lr/dist/token.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { Stack } from "./stack";
|
||||
export declare class CachedToken {
|
||||
start: number;
|
||||
value: number;
|
||||
end: number;
|
||||
extended: number;
|
||||
lookAhead: number;
|
||||
mask: number;
|
||||
context: number;
|
||||
}
|
||||
export declare class InputStream {
|
||||
private chunk2;
|
||||
private chunk2Pos;
|
||||
next: number;
|
||||
pos: number;
|
||||
private rangeIndex;
|
||||
private range;
|
||||
peek(offset: number): any;
|
||||
acceptToken(token: number, endOffset?: number): void;
|
||||
private getChunk;
|
||||
private readNext;
|
||||
advance(n?: number): number;
|
||||
private setDone;
|
||||
}
|
||||
export interface Tokenizer {
|
||||
}
|
||||
interface ExternalOptions {
|
||||
contextual?: boolean;
|
||||
fallback?: boolean;
|
||||
extend?: boolean;
|
||||
}
|
||||
export declare class ExternalTokenizer {
|
||||
constructor(token: (input: InputStream, stack: Stack) => void, options?: ExternalOptions);
|
||||
}
|
||||
export {};
|
35
node_modules/@lezer/lr/package.json
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "@lezer/lr",
|
||||
"version": "1.0.0",
|
||||
"description": "Incremental parser",
|
||||
"main": "dist/index.cjs",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"author": "Marijn Haverbeke <marijnh@gmail.com>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type" : "git",
|
||||
"url" : "https://github.com/lezer-parser/lr.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rollup": "^2.52.2",
|
||||
"@rollup/plugin-commonjs": "^15.1.0",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"typescript": "^4.3.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.0.0"
|
||||
},
|
||||
"files": ["dist"],
|
||||
"scripts": {
|
||||
"test": "echo 'Tests are in @lezer/generator'",
|
||||
"watch": "rollup -w -c rollup.config.js",
|
||||
"prepare": "rollup -c rollup.config.js"
|
||||
}
|
||||
}
|
3
node_modules/@silvermine/videojs-chromecast/.jsdoc
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"plugins": [ "plugins/markdown" ]
|
||||
}
|
1
node_modules/@silvermine/videojs-chromecast/.nvmrc
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
12.22.1
|
16
node_modules/@silvermine/videojs-chromecast/.nycrc.json
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"include": [
|
||||
"src/**/*.js"
|
||||
],
|
||||
"extension": [
|
||||
".js"
|
||||
],
|
||||
"reporter": [
|
||||
"text-summary",
|
||||
"html",
|
||||
"lcov"
|
||||
],
|
||||
"instrument": true,
|
||||
"sourceMap": true,
|
||||
"all": true
|
||||
}
|
20
node_modules/@silvermine/videojs-chromecast/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
Copyright (c) 2017 Jeremy Thomerson
|
||||
|
||||
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.
|
327
node_modules/@silvermine/videojs-chromecast/README.md
generated
vendored
Normal file
|
@ -0,0 +1,327 @@
|
|||
# Silvermine VideoJS Chromecast Plugin
|
||||
|
||||
[](https://travis-ci.org/silvermine/videojs-chromecast)
|
||||
[](https://coveralls.io/github/silvermine/videojs-chromecast?branch=master)
|
||||
[](https://david-dm.org/silvermine/videojs-chromecast)
|
||||
[](https://david-dm.org/silvermine/videojs-chromecast#info=devDependencies&view=table)
|
||||
|
||||
|
||||
## What is it?
|
||||
|
||||
A plugin for [videojs](http://videojs.com/) versions 6+ that adds a button to the control
|
||||
bar which will cast videos to a Chromecast.
|
||||
|
||||
|
||||
## How do I use it?
|
||||
|
||||
The `@silvermine/videojs-chromecast` plugin includes 3 types of assets: javascript, CSS,
|
||||
and images.
|
||||
|
||||
You can either build the plugin locally and use the assets that are output from the build
|
||||
process directly, or you can install the plugin as an npm module, include the
|
||||
javascript and SCSS source in your project using a Common-JS module loader and SASS build
|
||||
process, and copy the images from the image source folder to your project.
|
||||
|
||||
Note that regardless of whether you are using this plugin via the pre-built JS or as a
|
||||
module, the Chromecast framework will need to be included after the plugin. For example:
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/video.js@6.1.0/dist/video.js"></script>
|
||||
<script src="./dist/silvermine-videojs-chromecast.min.js"></script>
|
||||
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
||||
```
|
||||
|
||||
### Building the plugin locally
|
||||
|
||||
1. Either clone this repository or install the `@silvermine/videojs-chromecast` module
|
||||
using `npm install @silvermine/videojs-chromecast`.
|
||||
2. Ensure that `@silvermine/videojs-chromecast`'s `devDependencies` are installed by
|
||||
running `npm install` from within the `videojs-chromecast` folder.
|
||||
3. Run `grunt build` to build and copy the javascript, CSS and image files to the
|
||||
`videojs-chromecast/dist` folder.
|
||||
4. Copy the plugin's files from the `dist` folder into your project as needed.
|
||||
5. Ensure that the images in the `dist/images` folder are accessible at `./images/`,
|
||||
relative to where the plugin's CSS is located. If, for example, your CSS is located
|
||||
at `https://example.com/plugins/silvermine-videojs-chromecast.css`, then the
|
||||
plugin's images should be located at `https://example.com/plugins/images/`.
|
||||
6. Follow the steps in the "Configuration" section below.
|
||||
|
||||
Note: when adding the plugin's javascript to your web page, include the
|
||||
`silvermine-videojs-chromecast.min.js` javascript file in your HTML *after* loading
|
||||
Video.js. The plugin's built javascript file expects there to be a reference to Video.js
|
||||
at `window.videojs` and will throw an error if it does not exist.
|
||||
|
||||
### Initialization options
|
||||
|
||||
* **`preloadWebComponents`** (default: `false`) - The Chromecast framework relies on the
|
||||
`webcomponents.js` polyfill when a browser does not have `document.registerElement` in
|
||||
order to create the `<google-cast-button>` custom component (which is not used by this
|
||||
plugin). If you are using jQuery, this polyfill must be loaded and initialized before
|
||||
jQuery is initialized. Unfortunately, the Chromecast framework loads the
|
||||
`webcomponents.js` polyfill via a dynamically created `<script>` tag. This causes a race
|
||||
condition (see #17). Also, including `webcomponents.js` anywhere on the page will break
|
||||
jQuery's fix for bubbling some events to `document` (e.g. `onchange` events for
|
||||
`<select>`, see #21). Setting `preloadWebComponents` to `true` will "fix" these 2
|
||||
problems by (1) making this plugin add the `webcomponents` polyfill synchronously when
|
||||
the polyfill is needed and (2) using the `webcomponents-lite.js` version as it does not
|
||||
include the shadow DOM polyfills, but still provides the `registerElement` polyfill that
|
||||
the Chromecast framework needs. If you use the `preloadWebComponents: true` option, you
|
||||
should make sure that this plugin is loaded before jQuery. Then include the Chromecast
|
||||
framework after this plugin as you normally would.
|
||||
|
||||
**Note:** There is a caveat to using the `preloadWebComponents` setting.
|
||||
Because the Chromecast plugin uses the shadow DOM to create the
|
||||
`<google-cast-button>` custom component, **the `<google-cast-button>` custom
|
||||
component may partly render, but it will not be functional**. This tag is not
|
||||
used by this plugin. However if you must use this tag elsewhere, you should
|
||||
not use the `preloadWebComponents` flag.
|
||||
|
||||
tl;dr: if you use jQuery, you should use the `preloadWebComponents: true` option in
|
||||
this plugin.
|
||||
|
||||
#### Providing initialization options via `require()`
|
||||
|
||||
If requiring this plugin via NPM, any desired initialization options can be supplied to
|
||||
the constructor function exported by the module. For example:
|
||||
|
||||
```js
|
||||
require('@silvermine/videojs-chromecast')(videojs, { preloadWebComponents: true });
|
||||
```
|
||||
|
||||
#### Providing initialization options via `<script>`
|
||||
|
||||
If using the prebuilt JS, the initialization options can be provided via
|
||||
`window.SILVERMINE_VIDEOJS_CHROMECAST_CONFIG`. Note that these options need to be set
|
||||
before the `<script>` tag to include the plugin.
|
||||
|
||||
```html
|
||||
<script>
|
||||
window.SILVERMINE_VIDEOJS_CHROMECAST_CONFIG = {
|
||||
preloadWebComponents: true,
|
||||
};
|
||||
</script>
|
||||
<script src="path/to/silvermine-videojs-chromecast.js"></script>
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
Once the plugin has been loaded and registered, configure it and add it to your Video.js
|
||||
player using Video.js' plugin configuration option (see the section under the heading
|
||||
"Setting up a Plugin" on [Video.js' plugin documentation page][videojs-docs].
|
||||
|
||||
**Important: In addition to defining plugin configuration, you are required to define the
|
||||
player's `techOrder` option, setting `'chromecast'` as the first Tech in the list.** Below
|
||||
is an example of the minimum required configuration for the Chromecast plugin to function:
|
||||
|
||||
```js
|
||||
var options;
|
||||
|
||||
options = {
|
||||
controls: true,
|
||||
techOrder: [ 'chromecast', 'html5' ], // You may have more Tech, such as Flash or HLS
|
||||
plugins: {
|
||||
chromecast: {}
|
||||
}
|
||||
};
|
||||
|
||||
videojs(document.getElementById('myVideoElement'), options);
|
||||
```
|
||||
|
||||
Please note that even if you choose not to use any of the configuration options, you must
|
||||
either provide a `chromecast` entry in the `plugins` option for Video.js to initialize the
|
||||
plugin for you:
|
||||
|
||||
```js
|
||||
options = {
|
||||
plugins: {
|
||||
chromecast: {}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
or you must initialize the plugin manually:
|
||||
|
||||
```js
|
||||
var player = videojs(document.getElementById('myVideoElement'));
|
||||
|
||||
player.chromecast(); // initializes the Chromecast plugin
|
||||
```
|
||||
|
||||
#### Configuration options
|
||||
|
||||
##### Plugin configuration
|
||||
* **`plugins.chromecast.receiverAppID`** - the string ID of a custom [Chromecast receiver
|
||||
app][cast-receiver] to use. Defaults to the [default Media Receiver ID][def-cast-id].
|
||||
* **`plugins.chromecast.addButtonToControlBar`** - a `boolean` flag that tells the plugin
|
||||
whether or not it should automatically add the Chromecast button to the Video.js
|
||||
player's control bar component. Defaults to `true`.
|
||||
* **`plugins.chromecast.buttonPositionIndex`** - a zero-based number specifying the index
|
||||
of the Chromecast button among the control bar's child components (if
|
||||
`addButtonToControlBar` is set to `true`). By default the Chromecast Button is added as
|
||||
the last child of the control bar. A value less than 0 puts the button at the specified
|
||||
position from the end of the control bar. Note that it's likely not all child components
|
||||
of the control bar are visible.
|
||||
|
||||
##### Chromecast Tech configuration
|
||||
* **`chromecast.requestTitleFn`** - a function that this plugin calls when it needs a
|
||||
string that will be the title shown in the UI that is shown when a Chromecast session is
|
||||
active and connected. When the this plugin calls the `requestTitleFn`, it passes it the
|
||||
[current `source` object][player-source] and expects a string in return. If nothing is
|
||||
returned or if this option is not defined, no title will be shown.
|
||||
* **`chromecast.requestSubtitleFn`** - a function that this plugin calls when it needs a
|
||||
string that will be the sub-title shown in the UI that is shown when a Chromecast
|
||||
session is active and connected. When the this plugin calls the `requestSubtitleFn`, it
|
||||
passes it the [current `source` object][player-source] and expects a string in return.
|
||||
If nothing is returned or if this option is not defined, no sub-title will be shown.
|
||||
* **`chromecast.requestCustomDataFn`** - a function that this plugin calls when it needs an
|
||||
object that contains custom information necessary for a Chromecast receiver app when a
|
||||
session is active and connected. When the this plugin calls the `requestCustomDataFn`, it
|
||||
passes it the [current `source` object][player-source] and expects an object in return.
|
||||
If nothing is returned or if this option is not defined, no custom data will be sent.
|
||||
This option is intended to be used with a [custom receiver][custom-receiver] application
|
||||
to extend its default capabilities.
|
||||
|
||||
Here is an example configuration object that makes full use of all required and optional
|
||||
configuration:
|
||||
|
||||
```js
|
||||
var titles, subtitles, customData, options;
|
||||
|
||||
titles = {
|
||||
'https://example.com/videos/video-1.mp4': 'Example Title',
|
||||
'https://example.com/videos/video-2.mp4': 'Example Title2',
|
||||
};
|
||||
|
||||
subtitles = {
|
||||
'https://example.com/videos/video-1.mp4': 'Subtitle',
|
||||
'https://example.com/videos/video-2.mp4': 'Subtitle2',
|
||||
};
|
||||
|
||||
customData = {
|
||||
'https://example.com/videos/video-1.mp4': { 'customColor': '#0099ee' },
|
||||
'https://example.com/videos/video-2.mp4': { 'customColor': '#000080' },
|
||||
};
|
||||
|
||||
options = {
|
||||
// Must specify the 'chromecast' Tech first
|
||||
techOrder: [ 'chromecast', 'html5' ], // Required
|
||||
// Configuration for the Chromecast Tech
|
||||
chromecast: {
|
||||
requestTitleFn: function(source) { // Not required
|
||||
return titles[source.url];
|
||||
},
|
||||
requestSubtitleFn: function(source) { // Not required
|
||||
return subtitles[source.url];
|
||||
},
|
||||
requestCustomDataFn: function(source) { // Not required
|
||||
return customData[source.url];
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
chromecast: {
|
||||
receiverAppID: '1234' // Not required
|
||||
addButtonToControlBar: false, // Defaults to true
|
||||
},
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
##### Localization
|
||||
|
||||
The `ChromecastButton` component has one translated string: "Open Chromecast menu". The
|
||||
"Open Chromecast menu" string appears in both of the standard places for Button component
|
||||
accessibility text: inside the `.vjs-control-text` span and as the `<button>` element's
|
||||
`title` attribute.
|
||||
|
||||
To localize the Chromecast button text, follow the steps in the
|
||||
[Video.js Languages tutorial][videojs-translation] to add an `"Open Chromecast menu"` key
|
||||
to the map of translation strings.
|
||||
|
||||
### Using the npm module
|
||||
|
||||
If you are using a module loader such as Browserify or Webpack, first install
|
||||
`@silvermine/videojs-chromecast` using `npm install`. Then, use
|
||||
`require('@silvermine/videojs-chromecast')` to require `@silvermine/videojs-chromecast`
|
||||
into your project's source code. `require('@silvermine/videojs-chromecast')` returns a
|
||||
function that you can use to register the plugin with videojs by passing in a reference to
|
||||
`videojs`:
|
||||
|
||||
```js
|
||||
var videojs = require('video.js');
|
||||
|
||||
// Initialize the Chromecast plugin
|
||||
require('@silvermine/videojs-chromecast')(videojs);
|
||||
```
|
||||
|
||||
Then, follow the steps in the "Configuration" section above.
|
||||
|
||||
### Using the CSS and images
|
||||
|
||||
If you are using SCSS in your project, you can simply reference the plugin's main SCSS
|
||||
file in your project's SCSS:
|
||||
|
||||
```scss
|
||||
@import "path/to/node_modules/@silvermine/videojs-chromecast/src/scss/videojs-chromecast";
|
||||
```
|
||||
|
||||
Optionally, you can override the SCSS variables that contain the paths to the icon
|
||||
image files:
|
||||
|
||||
* **`$icon-chromecast--default`** - the path to the icon image that is displayed when the
|
||||
Chromecast button is in its normal, default state. Defaults to
|
||||
`"images/ic_cast_white_24dp.png"`.
|
||||
* **`$icon-chromecast--hover`** - the path to the icon image that is displayed when the
|
||||
user hovers over the Chromecast button when it is in its normal, default state. Defaults
|
||||
to `"images/ic_cast_white_24dp.png"`.
|
||||
* **`$icon-chromecast-casting`** - the path to the icon image that is displayed when the
|
||||
Chromecast button is in the "casting" state (when a Chromecast session is active and
|
||||
connected). Defaults to `"images/ic_cast_connected_white_24dp.png"`.
|
||||
* **`$icon-chromecast-casting--hover`** - the path to the icon image that is displayed
|
||||
when the user hovers over the Chromecast button when it is in the "casting" state (when
|
||||
a Chromecast session is active and connected). Defaults to
|
||||
`"images/ic_cast_connected_white_24dp.png"`.
|
||||
* **`$chromecast-icon-size`** - the width and height of the icon (the button and icon is a
|
||||
square). Defaults to `12px`.
|
||||
* **`$chromecast-title-font-size`** - the font size of the title on the screen that is
|
||||
shown while a Chromecast session is active and connected. Defaults to `22px`.
|
||||
* **`$chromecast-subtitle-font-size`** - the font size of the sub-title on the screen
|
||||
that is shown while a Chromecast session is active and connected. Defaults to `18px`.
|
||||
* **`$chromecast-poster-width`** - the width of the poster image on the screen that that
|
||||
is shown while a Chromecast session is active and connected. Defaults to `100px`.
|
||||
* **`$chromecast-poster-max-height`** - the maximum height of the poster image on the
|
||||
screen that is shown while a Chromecast session is active and connected. Defaults to
|
||||
`180px`.
|
||||
|
||||
|
||||
#### Images
|
||||
|
||||
The plugin's images are located at `videojs-chromecast/src/images`. If you have
|
||||
not overridden the icon image path variables in the SCSS, then copy the images from the
|
||||
`src/images` folder to a folder that is accessible at `./images/`, relative to where the
|
||||
plugin's CSS is located. If, for example, your CSS is located at
|
||||
`https://example.com/plugins/silvermine-videojs-chromecast.css`, then the plugin's images
|
||||
should be located at `https://example.com/plugins/images/`.
|
||||
|
||||
In addition the the `ic_cast_white_24dp.png` icon image that is used as the default icon for
|
||||
all four button states ("default", "default + hover", "casting", "casting + hover"), the `images`
|
||||
folder contains grey, black, and blue versions of the icons.
|
||||
|
||||
|
||||
## How do I contribute?
|
||||
|
||||
We genuinely appreciate external contributions. See [our extensive
|
||||
documentation][contributing] on how to contribute.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the MIT license. See [the license file](LICENSE) for more
|
||||
details.
|
||||
|
||||
[videojs-docs]: http://docs.videojs.com/tutorial-plugins.html
|
||||
[videojs-translation]: http://docs.videojs.com/tutorial-languages.html
|
||||
[cast-receiver]: https://developers.google.com/cast/docs/receiver_apps
|
||||
[def-cast-id]: https://developers.google.com/cast/docs/receiver_apps#default
|
||||
[player-source]: http://docs.videojs.com/Player.html#currentSource
|
||||
[custom-receiver]: https://developers.google.com/cast/docs/custom_receiver
|
||||
[contributing]: https://github.com/silvermine/silvermine-info#contributing
|
5
node_modules/@silvermine/videojs-chromecast/commitlint.config.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
extends: [ '@silvermine/standardization/commitlint.js' ],
|
||||
};
|
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_black_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 736 B |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_blue_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_connected_black_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 892 B |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_connected_blue_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_connected_grey_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 1,009 B |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_connected_white_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 981 B |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_grey_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 876 B |
BIN
node_modules/@silvermine/videojs-chromecast/dist/images/ic_cast_white_24dp.png
generated
vendored
Normal file
After Width: | Height: | Size: 824 B |
1
node_modules/@silvermine/videojs-chromecast/dist/silvermine-videojs-chromecast.css
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.vjs-chromecast-button .vjs-icon-placeholder{background:url("images/ic_cast_white_24dp.png") center center no-repeat;background-size:contain;display:inline-block;width:12px;height:12px}.vjs-chromecast-button:hover{cursor:pointer}.vjs-chromecast-button:hover .vjs-icon-placeholder{background-image:url("images/ic_cast_white_24dp.png")}.vjs-chromecast-button.vjs-chromecast-casting-state .vjs-icon-placeholder{background-image:url("images/ic_cast_connected_white_24dp.png")}.vjs-chromecast-button.vjs-chromecast-casting-state:hover .vjs-icon-placeholder{background-image:url("images/ic_cast_connected_white_24dp.png")}.vjs-tech-chromecast{display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;align-items:center;overflow:hidden}.vjs-tech-chromecast .vjs-tech-chromecast-poster::after{content:' ';display:block;height:2px;width:100px;background-color:#ccc;position:absolute;left:-webkit-calc(50% - 50px);left:calc(50% - 50px)}.vjs-tech-chromecast .vjs-tech-chromecast-poster-img{max-height:180px;width:auto;border:2px solid #ccc}.vjs-tech-chromecast .vjs-tech-chromecast-poster-img.vjs-tech-chromecast-poster-img-empty{width:160px;height:90px}.vjs-tech-chromecast .vjs-tech-chromecast-title-container{position:absolute;bottom:50%;margin-bottom:100px;color:#ccc;text-align:center}.vjs-tech-chromecast .vjs-tech-chromecast-title{font-size:22px}.vjs-tech-chromecast .vjs-tech-chromecast-title.vjs-tech-chromecast-title-empty{display:none}.vjs-tech-chromecast .vjs-tech-chromecast-subtitle{font-size:18px;padding-top:0.5em}.vjs-tech-chromecast .vjs-tech-chromecast-subtitle.vjs-tech-chromecast-subtitle-empty{display:none}
|