@codemirror/language 6.6.0 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 6.7.0 (2023-05-19)
2
+
3
+ ### New features
4
+
5
+ Export `DocInput` class for feeding editor documents to a Lezer parser.
6
+
1
7
  ## 6.6.0 (2023-02-13)
2
8
 
3
9
  ### New features
package/dist/index.cjs CHANGED
@@ -28,7 +28,7 @@ function defineLanguageFacet(baseData) {
28
28
  });
29
29
  }
30
30
  /**
31
- Syntax node prop used to register sublangauges. Should be added to
31
+ Syntax node prop used to register sublanguages. Should be added to
32
32
  the top level node type for the language.
33
33
  */
34
34
  const sublanguageProp = new common.NodeProp();
@@ -244,8 +244,15 @@ function syntaxParserRunning(view) {
244
244
  var _a;
245
245
  return ((_a = view.plugin(parseWorker)) === null || _a === void 0 ? void 0 : _a.isWorking()) || false;
246
246
  }
247
- // Lezer-style Input object for a Text document.
247
+ /**
248
+ Lezer-style
249
+ [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
250
+ object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
251
+ */
248
252
  class DocInput {
253
+ /**
254
+ Create an input object for the given document.
255
+ */
249
256
  constructor(doc) {
250
257
  this.doc = doc;
251
258
  this.cursorPos = 0;
@@ -2480,6 +2487,7 @@ function docID(data) {
2480
2487
  return type;
2481
2488
  }
2482
2489
 
2490
+ exports.DocInput = DocInput;
2483
2491
  exports.HighlightStyle = HighlightStyle;
2484
2492
  exports.IndentContext = IndentContext;
2485
2493
  exports.LRLanguage = LRLanguage;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { NodeProp, SyntaxNode, Parser, Tree, TreeFragment, NodeType } from '@lezer/common';
1
+ import { NodeProp, SyntaxNode, Parser, Tree, Input, TreeFragment, NodeType } from '@lezer/common';
2
2
  import { LRParser, ParserConfig } from '@lezer/lr';
3
3
  import * as _codemirror_state from '@codemirror/state';
4
- import { Facet, EditorState, Extension, StateField, Range } from '@codemirror/state';
4
+ import { Facet, EditorState, Extension, Text, StateField, Range } from '@codemirror/state';
5
5
  import { EditorView, DecorationSet, Command, KeyBinding, ViewUpdate, BlockInfo, Decoration } from '@codemirror/view';
6
6
  import { Highlighter, Tag } from '@lezer/highlight';
7
7
  import { StyleModule, StyleSpec } from 'style-mod';
@@ -64,7 +64,7 @@ interface Sublanguage {
64
64
  }>;
65
65
  }
66
66
  /**
67
- Syntax node prop used to register sublangauges. Should be added to
67
+ Syntax node prop used to register sublanguages. Should be added to
68
68
  the top level node type for the language.
69
69
  */
70
70
  declare const sublanguageProp: NodeProp<Sublanguage[]>;
@@ -212,6 +212,26 @@ is no language parser enabled.
212
212
  */
213
213
  declare function syntaxParserRunning(view: EditorView): boolean;
214
214
  /**
215
+ Lezer-style
216
+ [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
217
+ object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
218
+ */
219
+ declare class DocInput implements Input {
220
+ readonly doc: Text;
221
+ private cursor;
222
+ private cursorPos;
223
+ private string;
224
+ /**
225
+ Create an input object for the given document.
226
+ */
227
+ constructor(doc: Text);
228
+ get length(): number;
229
+ private syncTo;
230
+ chunk(pos: number): string;
231
+ get lineChunks(): boolean;
232
+ read(from: number, to: number): string;
233
+ }
234
+ /**
215
235
  A parse context provided to parsers working on the editor content.
216
236
  */
217
237
  declare class ParseContext {
@@ -664,7 +684,7 @@ declare function foldable(state: EditorState, lineStart: number, lineEnd: number
664
684
  from: number;
665
685
  to: number;
666
686
  } | null;
667
- declare type DocRange = {
687
+ type DocRange = {
668
688
  from: number;
669
689
  to: number;
670
690
  };
@@ -752,7 +772,7 @@ interface FoldConfig {
752
772
  Create an extension that configures code folding.
753
773
  */
754
774
  declare function codeFolding(config?: FoldConfig): Extension;
755
- declare type Handlers = {
775
+ type Handlers = {
756
776
  [event: string]: (view: EditorView, line: BlockInfo, event: Event) => boolean;
757
777
  };
758
778
  interface FoldGutterConfig {
@@ -1157,4 +1177,4 @@ declare class StreamLanguage<State> extends Language {
1157
1177
  get allowsNesting(): boolean;
1158
1178
  }
1159
1179
 
1160
- export { Config, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, MatchResult, ParseContext, StreamLanguage, StreamParser, StringStream, Sublanguage, TagStyle, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };
1180
+ export { Config, DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, MatchResult, ParseContext, StreamLanguage, StreamParser, StringStream, Sublanguage, TagStyle, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ function defineLanguageFacet(baseData) {
24
24
  });
25
25
  }
26
26
  /**
27
- Syntax node prop used to register sublangauges. Should be added to
27
+ Syntax node prop used to register sublanguages. Should be added to
28
28
  the top level node type for the language.
29
29
  */
30
30
  const sublanguageProp = /*@__PURE__*/new NodeProp();
@@ -240,8 +240,15 @@ function syntaxParserRunning(view) {
240
240
  var _a;
241
241
  return ((_a = view.plugin(parseWorker)) === null || _a === void 0 ? void 0 : _a.isWorking()) || false;
242
242
  }
243
- // Lezer-style Input object for a Text document.
243
+ /**
244
+ Lezer-style
245
+ [`Input`](https://lezer.codemirror.net/docs/ref#common.Input)
246
+ object for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.
247
+ */
244
248
  class DocInput {
249
+ /**
250
+ Create an input object for the given document.
251
+ */
245
252
  constructor(doc) {
246
253
  this.doc = doc;
247
254
  this.cursorPos = 0;
@@ -2476,4 +2483,4 @@ function docID(data) {
2476
2483
  return type;
2477
2484
  }
2478
2485
 
2479
- export { HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, StreamLanguage, StringStream, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };
2486
+ export { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, StreamLanguage, StringStream, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/language",
3
- "version": "6.6.0",
3
+ "version": "6.7.0",
4
4
  "description": "Language support infrastructure for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",