Premier commit déjà bien avancé

This commit is contained in:
2025-11-10 18:33:24 +01:00
commit db4f0508cb
652 changed files with 440521 additions and 0 deletions

View 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

168
frontend/node_modules/@codemirror/commands/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,168 @@
## 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
frontend/node_modules/@codemirror/commands/LICENSE generated vendored Normal file
View 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
frontend/node_modules/@codemirror/commands/README.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
# @codemirror/commands [![NPM version](https://img.shields.io/npm/v/@codemirror/commands.svg)](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.

1629
frontend/node_modules/@codemirror/commands/dist/index.cjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

View 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 };

1532
frontend/node_modules/@codemirror/commands/dist/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View 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

View File

@@ -0,0 +1,188 @@
## 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.

View 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.

View File

@@ -0,0 +1,18 @@
# @codemirror/language [![NPM version](https://img.shields.io/npm/v/@codemirror/language.svg)](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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
{
"name": "@codemirror/language",
"version": "0.20.2",
"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": "^0.20.0",
"@codemirror/view": "^0.20.0",
"@lezer/common": "^0.16.0",
"@lezer/highlight": "^0.16.0",
"@lezer/lr": "^0.16.0",
"style-mod": "^4.0.0"
},
"devDependencies": {
"@codemirror/buildhelper": "^0.1.5",
"@lezer/javascript": "^0.16.0"
},
"repository": {
"type": "git",
"url": "https://github.com/codemirror/language.git"
}
}

View 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

View File

@@ -0,0 +1,164 @@
## 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.

View 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.

View File

@@ -0,0 +1,18 @@
# @codemirror/state [![NPM version](https://img.shields.io/npm/v/@codemirror/state.svg)](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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
{
"name": "@codemirror/state",
"version": "0.20.1",
"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"
}
}

View 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

View File

@@ -0,0 +1,865 @@
## 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.

View 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.

View File

@@ -0,0 +1,18 @@
# @codemirror/view [![NPM version](https://img.shields.io/npm/v/@codemirror/view.svg)](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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
{
"name": "@codemirror/view",
"version": "0.20.7",
"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": "^0.20.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"
}
}

View 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.

View 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.

File diff suppressed because it is too large Load Diff

View 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";

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View 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;

View 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;

View 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 {};

View File

@@ -0,0 +1,36 @@
{
"name": "@lezer/common",
"version": "0.16.1",
"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"
}
}

View 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.

View 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.

View File

@@ -0,0 +1,109 @@
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 highlightTags(highlighters: readonly Highlighter[], tags: readonly Tag[]): string | null;
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;

View 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.highlightTags = highlightTags;
exports.highlightTree = highlightTree;
exports.styleTags = styleTags;
exports.tagHighlighter = tagHighlighter;
exports.tags = tags;

View File

@@ -0,0 +1,648 @@
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 };

View File

@@ -0,0 +1,34 @@
{
"name": "@lezer/highlight",
"version": "0.16.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": "^0.16.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"
}
}

View 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.

View 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/).

View 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
}

View File

@@ -0,0 +1,5 @@
export declare function decodeArray<T extends {
[i: number]: number;
} = Uint16Array>(input: string | T, Type?: {
new (n: number): T;
}): T;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
export { LRParser, ParserConfig, ContextTracker } from "./parse";
export { InputStream, ExternalTokenizer } from "./token";
export { Stack } from "./stack";

File diff suppressed because it is too large Load Diff

View 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 {};

View 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;
}

View File

@@ -0,0 +1,36 @@
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;
resolveOffset(offset: number, assoc: -1 | 1): number;
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 implements Tokenizer {
constructor(token: (input: InputStream, stack: Stack) => void, options?: ExternalOptions);
}
export {};

View File

@@ -0,0 +1,35 @@
{
"name": "@lezer/lr",
"version": "0.16.3",
"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": "^0.16.0"
},
"files": ["dist"],
"scripts": {
"test": "echo 'Tests are in @lezer/generator'",
"watch": "rollup -w -c rollup.config.js",
"prepare": "rollup -c rollup.config.js"
}
}

View File

@@ -0,0 +1,42 @@
{
"name": "@codemirror/commands",
"version": "0.20.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": "^0.20.0",
"@codemirror/state": "^0.20.0",
"@codemirror/view": "^0.20.0",
"@lezer/common": "^0.16.0"
},
"devDependencies": {
"@codemirror/buildhelper": "^0.1.5",
"@codemirror/lang-javascript": "^0.20.0"
},
"repository": {
"type": "git",
"url": "https://github.com/codemirror/commands.git"
}
}