@citisen/litearea 0.1.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/LICENSE +21 -0
- package/README.md +514 -0
- package/README.zh.md +362 -0
- package/dist/grammars.cjs +1228 -0
- package/dist/grammars.cjs.map +1 -0
- package/dist/grammars.js +1213 -0
- package/dist/grammars.js.map +1 -0
- package/dist/index.cjs +3103 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +3040 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +3032 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.js +3010 -0
- package/dist/react.js.map +1 -0
- package/dist/styles.cjs +453 -0
- package/dist/styles.cjs.map +1 -0
- package/dist/styles.css +432 -0
- package/dist/styles.js +447 -0
- package/dist/styles.js.map +1 -0
- package/dist/types/core/complete.d.ts +70 -0
- package/dist/types/core/complete.d.ts.map +1 -0
- package/dist/types/core/format.d.ts +34 -0
- package/dist/types/core/format.d.ts.map +1 -0
- package/dist/types/core/grammar.d.ts +14 -0
- package/dist/types/core/grammar.d.ts.map +1 -0
- package/dist/types/core/hover.d.ts +23 -0
- package/dist/types/core/hover.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +12 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/inspect.d.ts +34 -0
- package/dist/types/core/inspect.d.ts.map +1 -0
- package/dist/types/core/rank.d.ts +82 -0
- package/dist/types/core/rank.d.ts.map +1 -0
- package/dist/types/core/scan.d.ts +51 -0
- package/dist/types/core/scan.d.ts.map +1 -0
- package/dist/types/core/segments.d.ts +44 -0
- package/dist/types/core/segments.d.ts.map +1 -0
- package/dist/types/core/text.d.ts +113 -0
- package/dist/types/core/text.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +604 -0
- package/dist/types/core/types.d.ts.map +1 -0
- package/dist/types/core/vocabulary.d.ts +82 -0
- package/dist/types/core/vocabulary.d.ts.map +1 -0
- package/dist/types/dom/create.d.ts +17 -0
- package/dist/types/dom/create.d.ts.map +1 -0
- package/dist/types/dom/editing.d.ts +89 -0
- package/dist/types/dom/editing.d.ts.map +1 -0
- package/dist/types/dom/editor.d.ts +366 -0
- package/dist/types/dom/editor.d.ts.map +1 -0
- package/dist/types/dom/index.d.ts +9 -0
- package/dist/types/dom/index.d.ts.map +1 -0
- package/dist/types/dom/mirror.d.ts +107 -0
- package/dist/types/dom/mirror.d.ts.map +1 -0
- package/dist/types/dom/overlay.d.ts +52 -0
- package/dist/types/dom/overlay.d.ts.map +1 -0
- package/dist/types/dom/popup.d.ts +95 -0
- package/dist/types/dom/popup.d.ts.map +1 -0
- package/dist/types/dom/support.d.ts +41 -0
- package/dist/types/dom/support.d.ts.map +1 -0
- package/dist/types/dom/tooltip.d.ts +39 -0
- package/dist/types/dom/tooltip.d.ts.map +1 -0
- package/dist/types/grammars/dshFont.d.ts +127 -0
- package/dist/types/grammars/dshFont.d.ts.map +1 -0
- package/dist/types/grammars/dshSentry.d.ts +84 -0
- package/dist/types/grammars/dshSentry.d.ts.map +1 -0
- package/dist/types/grammars/index.d.ts +3 -0
- package/dist/types/grammars/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +91 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/styles.d.ts +29 -0
- package/dist/types/styles.d.ts.map +1 -0
- package/docs/architecture.md +316 -0
- package/docs/completion.md +320 -0
- package/docs/grammar.md +823 -0
- package/package.json +105 -0
- package/scripts/browser-check.mjs +838 -0
- package/scripts/build-css.mjs +35 -0
- package/scripts/release.mjs +91 -0
- package/scripts/verify-package.mjs +253 -0
- package/src/core/complete.ts +286 -0
- package/src/core/format.ts +71 -0
- package/src/core/grammar.ts +40 -0
- package/src/core/hover.ts +129 -0
- package/src/core/index.ts +98 -0
- package/src/core/inspect.ts +198 -0
- package/src/core/rank.ts +317 -0
- package/src/core/scan.ts +720 -0
- package/src/core/segments.ts +185 -0
- package/src/core/text.ts +238 -0
- package/src/core/types.ts +681 -0
- package/src/core/vocabulary.ts +196 -0
- package/src/dom/create.ts +31 -0
- package/src/dom/editing.ts +213 -0
- package/src/dom/editor.ts +1143 -0
- package/src/dom/index.ts +46 -0
- package/src/dom/mirror.ts +305 -0
- package/src/dom/overlay.ts +106 -0
- package/src/dom/popup.ts +323 -0
- package/src/dom/support.ts +88 -0
- package/src/dom/tooltip.ts +112 -0
- package/src/grammars/dshFont.ts +1004 -0
- package/src/grammars/dshSentry.ts +742 -0
- package/src/grammars/index.ts +57 -0
- package/src/index.ts +122 -0
- package/src/react/index.tsx +248 -0
- package/src/styles.ts +529 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ResolvedVocabulary, Scope, Severity, VocabularyContext, VocabularyEntry, WordsSource } from './types.js';
|
|
2
|
+
/** What a vocabulary is told about the document it is being resolved for. */
|
|
3
|
+
export interface VocabularySpec<State = unknown> {
|
|
4
|
+
/** A stable id, used in the diagnostic code and for debugging. */
|
|
5
|
+
id: string;
|
|
6
|
+
/**
|
|
7
|
+
* The members.
|
|
8
|
+
*
|
|
9
|
+
* A function is how a set that lives outside the document reaches the grammar
|
|
10
|
+
* without the grammar holding mutable state: the installed fonts, the states
|
|
11
|
+
* the host actually has. It is called once per scan.
|
|
12
|
+
*/
|
|
13
|
+
words: readonly string[] | ((context: VocabularyContext<State>) => readonly string[]);
|
|
14
|
+
/** The scope a member is painted with. Defaults to `vocabulary:<id>`. */
|
|
15
|
+
scope?: Scope | ((word: string) => Scope);
|
|
16
|
+
/** The scope a rejected word is painted with. Defaults to `'invalid'`. */
|
|
17
|
+
unknownScope?: Scope;
|
|
18
|
+
/**
|
|
19
|
+
* The message a rejected word earns.
|
|
20
|
+
*
|
|
21
|
+
* Present, a word-shaped token outside the set is reported; absent, it is
|
|
22
|
+
* reported by nobody and the grammar is the poorer for it. `{word}` and
|
|
23
|
+
* `{allowed}` are substituted, the latter as a readable list.
|
|
24
|
+
*/
|
|
25
|
+
unknownMessage?: string | ((word: string, allowed: readonly string[]) => string);
|
|
26
|
+
/** How loudly a rejected word complains. Default `'error'`. */
|
|
27
|
+
unknownSeverity?: Severity;
|
|
28
|
+
/** A stable code for the rejection. Defaults to `vocabulary:<id>`. */
|
|
29
|
+
unknownCode?: string;
|
|
30
|
+
/**
|
|
31
|
+
* What each member explains about itself, for hover. A bare string is taken as
|
|
32
|
+
* the body.
|
|
33
|
+
*/
|
|
34
|
+
docs?: Readonly<Record<string, string | VocabularyEntry>>;
|
|
35
|
+
/** A dimmed line shown beside a member in the completion list. */
|
|
36
|
+
detail?: (word: string) => string | undefined;
|
|
37
|
+
/** Whether membership is case-sensitive. Default `false`. */
|
|
38
|
+
caseSensitive?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* How a member is written into the document when it is accepted.
|
|
41
|
+
*
|
|
42
|
+
* Separate from the word itself because a member is not always insertable as
|
|
43
|
+
* typed: a font family containing a space has to be quoted, even though the
|
|
44
|
+
* vocabulary calls it `IBM Plex Mono`.
|
|
45
|
+
*/
|
|
46
|
+
format?: (word: string) => string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build a vocabulary: the set, its colour, its rejection, and its documentation.
|
|
50
|
+
* @param spec - the declaration.
|
|
51
|
+
* @returns a resolved vocabulary, ready for a `words` rule.
|
|
52
|
+
*/
|
|
53
|
+
export declare function defineVocabulary<State = unknown>(spec: VocabularySpec<State>): ResolvedVocabulary<State>;
|
|
54
|
+
/**
|
|
55
|
+
* The members of a vocabulary, resolved for a document.
|
|
56
|
+
*
|
|
57
|
+
* A helper for the common case of a caller that has a vocabulary and wants its
|
|
58
|
+
* words, without reaching through to `resolve` and re-supplying the context.
|
|
59
|
+
* @param vocabulary - a resolved vocabulary.
|
|
60
|
+
* @param context - the document it is being resolved for.
|
|
61
|
+
* @returns the members, in declaration order.
|
|
62
|
+
*/
|
|
63
|
+
export declare function vocabularyWords<State>(vocabulary: ResolvedVocabulary<State>, context: VocabularyContext<State>): readonly string[];
|
|
64
|
+
/**
|
|
65
|
+
* Recognize a vocabulary among the shapes a `WordsSource` may take.
|
|
66
|
+
*
|
|
67
|
+
* The test is structural rather than `instanceof`, so a grammar may hand over its
|
|
68
|
+
* own object as long as it carries the four facts — which is what lets a host
|
|
69
|
+
* wrap a vocabulary in logging, caching, or a translation layer without the
|
|
70
|
+
* engine needing to know.
|
|
71
|
+
* @param source - a words source.
|
|
72
|
+
* @returns the vocabulary, or undefined when the source is a bare list or function.
|
|
73
|
+
*/
|
|
74
|
+
export declare function asResolvedVocabulary<State>(source: WordsSource<State>): ResolvedVocabulary<State> | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* The members any words source stands for, whichever shape it took.
|
|
77
|
+
* @param source - a bare list, a vocabulary, or a function.
|
|
78
|
+
* @param context - the document it is being resolved for.
|
|
79
|
+
* @returns the members, or an empty list when the source resolved to nothing.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveWordsSource<State>(source: WordsSource<State>, context: VocabularyContext<State>): readonly string[];
|
|
82
|
+
//# sourceMappingURL=vocabulary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocabulary.d.ts","sourceRoot":"","sources":["../../../src/core/vocabulary.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,kBAAkB,EAClB,KAAK,EACL,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,WAAW,EACZ,MAAM,YAAY,CAAA;AAGnB,6EAA6E;AAC7E,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,OAAO;IAC7C,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,CAAC,CAAA;IACrF,yEAAyE;IACzE,KAAK,CAAC,EAAE,KAAK,GAAG,C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W,CAAC,KAAK,CAAC,EAC1B,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,GAChC,SAAS,MAAM,EAAE,CASnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LiteArea, type LiteAreaOptions } from './editor.js';
|
|
2
|
+
/**
|
|
3
|
+
* Build an editor and put it in an element.
|
|
4
|
+
*
|
|
5
|
+
* The `refresh` after mounting is not a formality. A textarea that is not in the
|
|
6
|
+
* document has no layout, so it has no width, so nothing can be measured against it
|
|
7
|
+
* — and a measurement taken then is not merely imprecise, it wraps the text at every
|
|
8
|
+
* character and comes back several times too tall. The editor's own
|
|
9
|
+
* `ResizeObserver` would correct it on the next frame, which means one frame of a box
|
|
10
|
+
* at the wrong height. Measuring again here, synchronously, means the first frame is
|
|
11
|
+
* already right.
|
|
12
|
+
* @param target - where to mount it. Its contents are appended to, not replaced.
|
|
13
|
+
* @param options - the grammar, the initial text, and the behaviour to use.
|
|
14
|
+
* @returns the editor, so the caller can drive it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createEditor<State = unknown>(target: Element, options: LiteAreaOptions<State>): LiteArea<State>;
|
|
17
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/dom/create.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAA;AAE5D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,KAAK,GAAG,OAAO,EAC1C,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,eAAe,CAAC,KAAK,CAAC,GAC9B,QAAQ,CAAC,KAAK,CAAC,CAKjB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** A caret or selection, as offsets into the value. */
|
|
2
|
+
export interface TextSelection {
|
|
3
|
+
/** The anchor end. Equal to `end` for a caret. */
|
|
4
|
+
start: number;
|
|
5
|
+
/** The moving end. */
|
|
6
|
+
end: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* How an edit reached the document.
|
|
10
|
+
*
|
|
11
|
+
* `pipeline` means the browser recorded it and Ctrl+Z will undo it. `direct` means
|
|
12
|
+
* the text changed and the history did not, which only happens where
|
|
13
|
+
* `document.execCommand` is unavailable — a test environment, or a browser that
|
|
14
|
+
* has finally removed it.
|
|
15
|
+
*/
|
|
16
|
+
export type EditOutcome = 'pipeline' | 'direct' | 'unchanged';
|
|
17
|
+
/** Read the caret or selection out of a field. */
|
|
18
|
+
export declare function readSelection(field: HTMLTextAreaElement): TextSelection;
|
|
19
|
+
/**
|
|
20
|
+
* Put a caret or selection into a field.
|
|
21
|
+
*
|
|
22
|
+
* Setting a selection moves the caret and nothing else: it does not touch the
|
|
23
|
+
* value, so it cannot disturb the undo stack. This is what the editor uses instead
|
|
24
|
+
* of re-rendering text to reposition the caret — the re-render was the bug.
|
|
25
|
+
*
|
|
26
|
+
* A range given the wrong way round is ordered rather than collapsed. `start` and
|
|
27
|
+
* `end` are named for a caret and a selection, and a caller that computes them from a
|
|
28
|
+
* backwards drag has still asked for that text to be selected; quietly selecting
|
|
29
|
+
* nothing at the far end would be a silent wrong answer.
|
|
30
|
+
* @param field - the textarea.
|
|
31
|
+
* @param start - the anchor offset.
|
|
32
|
+
* @param end - the moving offset; defaults to `start`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function writeSelection(field: HTMLTextAreaElement, start: number, end?: number): void;
|
|
35
|
+
/** The line height in force on a field, falling back to the computed font size. */
|
|
36
|
+
export declare function fieldLineHeight(field: HTMLTextAreaElement): number;
|
|
37
|
+
/**
|
|
38
|
+
* Replace a range through the browser's editing pipeline, so it can be undone.
|
|
39
|
+
*
|
|
40
|
+
* The field is focused first because the pipeline only runs on the focused
|
|
41
|
+
* element, and a completion accepted by mouse click would otherwise arrive after
|
|
42
|
+
* the click had already blurred the field.
|
|
43
|
+
* @param field - the textarea.
|
|
44
|
+
* @param from - the first offset to replace.
|
|
45
|
+
* @param to - the offset after the last.
|
|
46
|
+
* @param text - what to put there. The empty string deletes.
|
|
47
|
+
* @returns how the edit landed.
|
|
48
|
+
*/
|
|
49
|
+
export declare function replaceThroughPipeline(field: HTMLTextAreaElement, from: number, to: number, text: string): EditOutcome;
|
|
50
|
+
/**
|
|
51
|
+
* Fire the event the browser would have fired, for the direct path only.
|
|
52
|
+
*
|
|
53
|
+
* The pipeline path needs no help: the browser dispatches `input` itself, which is
|
|
54
|
+
* exactly why the editor can treat both paths the same way downstream.
|
|
55
|
+
* @param field - the textarea.
|
|
56
|
+
* @param text - what was written.
|
|
57
|
+
*/
|
|
58
|
+
export declare function dispatchInput(field: HTMLTextAreaElement, text: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Undo, through the browser's own history.
|
|
61
|
+
*
|
|
62
|
+
* Exposed so a host can offer a button without reimplementing a stack, and so the
|
|
63
|
+
* browser harness can drive the same path a keyboard shortcut drives.
|
|
64
|
+
* @param field - the textarea.
|
|
65
|
+
* @returns whether the call was possible at all. It cannot report whether anything
|
|
66
|
+
* was actually undone, because no browser exposes that.
|
|
67
|
+
*/
|
|
68
|
+
export declare function undoField(field: HTMLTextAreaElement): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Redo, through the browser's own history.
|
|
71
|
+
* @param field - the textarea.
|
|
72
|
+
* @returns whether the call was possible at all.
|
|
73
|
+
*/
|
|
74
|
+
export declare function redoField(field: HTMLTextAreaElement): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Write a whole document into a field.
|
|
77
|
+
*
|
|
78
|
+
* Two paths, and the difference matters. `preserveHistory` selects everything and
|
|
79
|
+
* inserts through the pipeline, so the replacement is one undoable edit and Ctrl+Z
|
|
80
|
+
* brings the previous text back — the right behaviour for a Reset button. Without
|
|
81
|
+
* it the value property is assigned, which is faster and clears the history, which
|
|
82
|
+
* is the right behaviour when a host is loading a different document entirely.
|
|
83
|
+
* @param field - the textarea.
|
|
84
|
+
* @param next - the new text.
|
|
85
|
+
* @param preserveHistory - whether the change should be undoable.
|
|
86
|
+
* @returns how the write landed.
|
|
87
|
+
*/
|
|
88
|
+
export declare function writeDocument(field: HTMLTextAreaElement, next: string, preserveHistory?: boolean): EditOutcome;
|
|
89
|
+
//# sourceMappingURL=editing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editing.d.ts","sourceRoot":"","sources":["../../../src/dom/editing.ts"],"names":[],"mappings":"AA6BA,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE7D,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EAAE,mBAAmB,GAAG,aAAa,CAIvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,MAAM,EACb,GAAG,GAAE,MAAc,GAClB,IAAI,CAKN;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAOlE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GACX,WAAW,CA0Bb;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAU5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAQ7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,mBAAmB,EAC1B,IAAI,EAAE,MAAM,EACZ,eAAe,UAAQ,GACtB,WAAW,CAMb"}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import type { Completion, Decoration, Diagnostic, Grammar, HoverInfo, Range, Severity } from '../core/types.js';
|
|
2
|
+
import type { Inspection } from '../core/inspect.js';
|
|
3
|
+
import { type ResolvedGrammar } from '../core/scan.js';
|
|
4
|
+
import { type EditOutcome, type TextSelection } from './editing.js';
|
|
5
|
+
/** How the box follows its content. */
|
|
6
|
+
export interface LiteAreaSizing {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the height follows the content, so that no scrollbar is shown while
|
|
9
|
+
* the content fits. Default `true`.
|
|
10
|
+
*/
|
|
11
|
+
autoGrow?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The fewest lines to show, written to the textarea's own `rows` attribute.
|
|
14
|
+
*
|
|
15
|
+
* The native attribute is set rather than only a pixel minimum, so the box has
|
|
16
|
+
* the right height on the very first frame — before any measurement, and in a
|
|
17
|
+
* document where the script never runs at all. Default 1.
|
|
18
|
+
*/
|
|
19
|
+
minRows?: number;
|
|
20
|
+
/** The most lines to show before a scrollbar appears. */
|
|
21
|
+
maxRows?: number;
|
|
22
|
+
/** A minimum height in pixels, in addition to `minRows`. */
|
|
23
|
+
minHeight?: number;
|
|
24
|
+
/** A maximum height in pixels, in addition to `maxRows`. */
|
|
25
|
+
maxHeight?: number;
|
|
26
|
+
}
|
|
27
|
+
/** How the completion list behaves. */
|
|
28
|
+
export interface LiteAreaCompletion {
|
|
29
|
+
/** Whether suggestions appear while typing. Default `true`. */
|
|
30
|
+
auto?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Characters that open the list in addition to word characters.
|
|
33
|
+
*
|
|
34
|
+
* Default `' '`, and that default is doing real work: both reference languages
|
|
35
|
+
* put a value after a name, so a space is exactly where the next word becomes
|
|
36
|
+
* guessable.
|
|
37
|
+
*/
|
|
38
|
+
triggerCharacters?: string;
|
|
39
|
+
/** The most rows to offer. Default 100. */
|
|
40
|
+
limit?: number;
|
|
41
|
+
/** Whether the documentation panel is shown. Default `true`. */
|
|
42
|
+
showDocumentation?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** How the hover tooltip behaves. */
|
|
45
|
+
export interface LiteAreaHover {
|
|
46
|
+
/** Whether tooltips appear at all. Default `true`. */
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
/** How long the pointer must rest, in milliseconds. Default 140. */
|
|
49
|
+
delay?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Everything a host may configure. */
|
|
52
|
+
export interface LiteAreaOptions<State = unknown> {
|
|
53
|
+
/** The language. Nothing else in this library knows anything about syntax. */
|
|
54
|
+
grammar: Grammar<State> | ResolvedGrammar<State>;
|
|
55
|
+
/** The initial text. */
|
|
56
|
+
value?: string;
|
|
57
|
+
/** Shown while the box is empty. */
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
/** Whether the user may edit. */
|
|
60
|
+
readOnly?: boolean;
|
|
61
|
+
/** Whether the browser may spell-check. Default `false`, because a DSL is not prose. */
|
|
62
|
+
spellCheck?: boolean;
|
|
63
|
+
/** The accessible name. */
|
|
64
|
+
ariaLabel?: string;
|
|
65
|
+
/** An extra class on the wrapper. */
|
|
66
|
+
className?: string;
|
|
67
|
+
/**
|
|
68
|
+
* CSS custom properties for THIS instance, for per-instance theming.
|
|
69
|
+
*
|
|
70
|
+
* A key may be written `font`, `--litearea-font`, or any other `--…` name; the first two
|
|
71
|
+
* forms mean the same thing, and a key that already starts with `--` is used verbatim so a
|
|
72
|
+
* host's own properties work too. The value is used as written, so `'13px'`,
|
|
73
|
+
* `'var(--my-ui-font)'`, and `'1.6'` are all fine.
|
|
74
|
+
*
|
|
75
|
+
* createEditor(target, {
|
|
76
|
+
* grammar,
|
|
77
|
+
* variables: { font: '"Fira Code", monospace', 'font-size': '14px', accent: '#c2410c' },
|
|
78
|
+
* })
|
|
79
|
+
*
|
|
80
|
+
* CSS stays the theme language on purpose — the editor's whole appearance is already
|
|
81
|
+
* described by custom properties, and a second vocabulary for the same facts would mean two
|
|
82
|
+
* places to keep in step. This exists only so that ONE instance can be themed without a host
|
|
83
|
+
* writing a stylesheet rule for it, and so that two editors on a page can differ.
|
|
84
|
+
*/
|
|
85
|
+
variables?: Record<string, string>;
|
|
86
|
+
/** How the box follows its content. */
|
|
87
|
+
sizing?: LiteAreaSizing;
|
|
88
|
+
/** How the list behaves, or `false` to switch completions off entirely. */
|
|
89
|
+
completion?: LiteAreaCompletion | false;
|
|
90
|
+
/** How tooltips behave, or `false` to switch them off entirely. */
|
|
91
|
+
hover?: LiteAreaHover | false;
|
|
92
|
+
/** Whether semantic decorations are painted. Default `true`. */
|
|
93
|
+
decorations?: boolean;
|
|
94
|
+
/** Whether to inject the stylesheet. Default `true`. */
|
|
95
|
+
injectStyles?: boolean;
|
|
96
|
+
/** A CSP nonce for the injected stylesheet. */
|
|
97
|
+
styleNonce?: string;
|
|
98
|
+
/** Called after a user edit, with the new text. Not called for programmatic writes. */
|
|
99
|
+
onChange?: (value: string) => void;
|
|
100
|
+
/** Called when the caret or selection moves. */
|
|
101
|
+
onSelectionChange?: (selection: TextSelection) => void;
|
|
102
|
+
/** Called when the problem list changes. */
|
|
103
|
+
onDiagnostics?: (diagnostics: readonly Diagnostic[]) => void;
|
|
104
|
+
/** Called when the list opens, filters, or closes. */
|
|
105
|
+
onCompletion?: (completion: Completion | undefined) => void;
|
|
106
|
+
/** Called when a tooltip appears or goes away. */
|
|
107
|
+
onHover?: (info: HoverInfo | undefined) => void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A code editor over a textarea.
|
|
111
|
+
*
|
|
112
|
+
* The tree it builds:
|
|
113
|
+
*
|
|
114
|
+
* div.litearea ← the positioning container, and this.element
|
|
115
|
+
* div.litearea-box ← the border, the radius, and the focus ring
|
|
116
|
+
* div.litearea-layer ← the painted text, behind and inert
|
|
117
|
+
* textarea ← the real field: transparent text, visible caret
|
|
118
|
+
* div.litearea-popup ← the completion list
|
|
119
|
+
* div.litearea-tooltip ← the hover tooltip
|
|
120
|
+
*
|
|
121
|
+
* The layer is inside the box while the floating elements are outside it, because
|
|
122
|
+
* the box clips nothing and a list that had to fit inside a rounded border would be
|
|
123
|
+
* cut off at the bottom.
|
|
124
|
+
*/
|
|
125
|
+
export declare class LiteArea<State = unknown> {
|
|
126
|
+
/** The positioning container. Put this in the page. */
|
|
127
|
+
readonly element: HTMLDivElement;
|
|
128
|
+
/** The real field. Exposed for a host that needs the element itself. */
|
|
129
|
+
readonly input: HTMLTextAreaElement;
|
|
130
|
+
private readonly document;
|
|
131
|
+
private readonly view;
|
|
132
|
+
/**
|
|
133
|
+
* The grammar as the host declared it, kept so {@link refresh} can re-resolve it.
|
|
134
|
+
*
|
|
135
|
+
* Mutable on purpose, and it is what lets a host pass a live object — a proxy
|
|
136
|
+
* reading the newest props, say — without the editor having to be rebuilt when the
|
|
137
|
+
* language changes. A rebuild would throw away the undo history, which is the one
|
|
138
|
+
* thing this library must not do, so re-resolving is the only acceptable answer.
|
|
139
|
+
*/
|
|
140
|
+
private declaredGrammar;
|
|
141
|
+
/** The grammar the engine is currently running, with its defaults filled in. */
|
|
142
|
+
private grammar;
|
|
143
|
+
private readonly box;
|
|
144
|
+
private readonly overlay;
|
|
145
|
+
private readonly popup;
|
|
146
|
+
private readonly tooltip;
|
|
147
|
+
private readonly mirror;
|
|
148
|
+
private readonly sizing;
|
|
149
|
+
private readonly completion;
|
|
150
|
+
private readonly hover;
|
|
151
|
+
private readonly paintDecorations;
|
|
152
|
+
private readonly handlers;
|
|
153
|
+
private readonly injectedStyle;
|
|
154
|
+
private readonly instanceId;
|
|
155
|
+
private readonly fontsReady;
|
|
156
|
+
/** The current inspection, and the text it was computed from. */
|
|
157
|
+
private current;
|
|
158
|
+
private currentText;
|
|
159
|
+
/** Bumped whenever the inspection changes, so the painter can skip work. */
|
|
160
|
+
private revision;
|
|
161
|
+
/** The list on screen, with the range frozen when it opened. */
|
|
162
|
+
private completionState;
|
|
163
|
+
/** True during an IME composition, when no completion may run. */
|
|
164
|
+
private composing;
|
|
165
|
+
/** True while the editor itself is writing, so its own edit does not re-open the list. */
|
|
166
|
+
private applying;
|
|
167
|
+
/** The height and overflow last written, so unchanged values are not rewritten. */
|
|
168
|
+
private appliedHeight;
|
|
169
|
+
private appliedOverflow;
|
|
170
|
+
private appliedScrollbar;
|
|
171
|
+
/** The offset the tooltip last described, so a resting pointer does not re-query. */
|
|
172
|
+
private hoverOffset;
|
|
173
|
+
/** The custom properties this instance set, so one that disappears can be removed. */
|
|
174
|
+
private appliedVariables;
|
|
175
|
+
private hoverTimer;
|
|
176
|
+
/** Watches for a width change, which invalidates wrapping and the box height. */
|
|
177
|
+
private resizeObserver;
|
|
178
|
+
private observedWidth;
|
|
179
|
+
/**
|
|
180
|
+
* A signature of the last announced problem list, so the host is told once.
|
|
181
|
+
*
|
|
182
|
+
* Starts as `undefined` rather than as the empty string, because "no problems" is a
|
|
183
|
+
* real signature and a host waiting to be told that the list is clear would otherwise
|
|
184
|
+
* never hear it — it would keep whatever it was showing before the editor existed.
|
|
185
|
+
*/
|
|
186
|
+
private announced;
|
|
187
|
+
private destroyed;
|
|
188
|
+
/**
|
|
189
|
+
* @param options - the grammar, the initial text, and the behaviour to use.
|
|
190
|
+
*/
|
|
191
|
+
constructor(options: LiteAreaOptions<State>);
|
|
192
|
+
/** The current text. */
|
|
193
|
+
get value(): string;
|
|
194
|
+
/** The caret or selection. */
|
|
195
|
+
get selection(): TextSelection;
|
|
196
|
+
/** The last inspection, or undefined before the first one. */
|
|
197
|
+
get inspection(): Inspection<State> | undefined;
|
|
198
|
+
/** The problems the grammar found. */
|
|
199
|
+
get diagnostics(): readonly Diagnostic[];
|
|
200
|
+
/** The list on screen, when one is. */
|
|
201
|
+
get currentCompletion(): Completion | undefined;
|
|
202
|
+
/** Whether the editor has focus. */
|
|
203
|
+
get focused(): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Replace the text.
|
|
206
|
+
*
|
|
207
|
+
* `preserveHistory` writes through the editing pipeline, so the replacement is
|
|
208
|
+
* one undoable edit and Ctrl+Z brings the old text back — what a Reset button
|
|
209
|
+
* wants. Without it the value property is assigned, which is faster and clears
|
|
210
|
+
* the history, which is what loading a different document wants.
|
|
211
|
+
*
|
|
212
|
+
* This is the only path that writes the text, and it is never used for an edit
|
|
213
|
+
* the user could have made.
|
|
214
|
+
* @param next - the new text.
|
|
215
|
+
* @param preserveHistory - whether Ctrl+Z should be able to undo it.
|
|
216
|
+
* @returns how the write landed.
|
|
217
|
+
*/
|
|
218
|
+
setValue(next: string, preserveHistory?: boolean): EditOutcome;
|
|
219
|
+
/**
|
|
220
|
+
* Put the caret somewhere.
|
|
221
|
+
* @param start - the anchor offset.
|
|
222
|
+
* @param end - the moving offset; defaults to `start`.
|
|
223
|
+
*/
|
|
224
|
+
setSelection(start: number, end?: number): void;
|
|
225
|
+
/** Move the caret into the field. */
|
|
226
|
+
focus(): void;
|
|
227
|
+
/** Undo, through the browser's history. */
|
|
228
|
+
undo(): boolean;
|
|
229
|
+
/** Redo, through the browser's history. */
|
|
230
|
+
redo(): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Set CSS custom properties on the wrapper, replacing whatever this method set last time.
|
|
233
|
+
*
|
|
234
|
+
* A property that has disappeared from the record is removed rather than left behind, so a
|
|
235
|
+
* host can un-theme by passing a smaller object. Properties set by other means — a stylesheet,
|
|
236
|
+
* or the wrapper's inline style directly — are not touched, and a removed one falls back to
|
|
237
|
+
* whatever CSS says.
|
|
238
|
+
*
|
|
239
|
+
* Safe to call at any time after construction. The constructor uses the private write-only
|
|
240
|
+
* half, because re-measuring needs the field, the mirror, and the overlay, none of which exist
|
|
241
|
+
* until it has finished.
|
|
242
|
+
* @param next - the properties, keyed as {@link LiteAreaOptions.variables} describes.
|
|
243
|
+
*/
|
|
244
|
+
setVariables(next: Readonly<Record<string, string>>): void;
|
|
245
|
+
/** Write the properties, and forget the ones that are gone. No re-measure. */
|
|
246
|
+
private applyVariables;
|
|
247
|
+
/**
|
|
248
|
+
* Re-read the document with the same text.
|
|
249
|
+
*
|
|
250
|
+
* For a host whose grammar depends on something outside it — an installed font
|
|
251
|
+
* list that has just been re-read, a palette that changed — and for the moment a
|
|
252
|
+
* web font finishes loading.
|
|
253
|
+
*
|
|
254
|
+
* The grammar is re-resolved here, which is what makes a live grammar object
|
|
255
|
+
* work: a host that rebuilds its rules on every render can call `refresh()` and
|
|
256
|
+
* the editor picks the new ones up without being rebuilt, so the undo history
|
|
257
|
+
* survives a language change.
|
|
258
|
+
*/
|
|
259
|
+
refresh(): void;
|
|
260
|
+
/** Open the completion list on demand, as Ctrl+Space does. */
|
|
261
|
+
showCompletions(): void;
|
|
262
|
+
/** Close the completion list. */
|
|
263
|
+
hideCompletions(): void;
|
|
264
|
+
/** Remove the editor and every listener it owns. */
|
|
265
|
+
destroy(): void;
|
|
266
|
+
/**
|
|
267
|
+
* Bring everything up to date with the field.
|
|
268
|
+
*
|
|
269
|
+
* The inspection is cached on the text, so moving the caret or scrolling costs
|
|
270
|
+
* nothing beyond the paint — and the paint itself is skipped when neither the
|
|
271
|
+
* text nor the analysis changed.
|
|
272
|
+
*/
|
|
273
|
+
private sync;
|
|
274
|
+
/** Paint the layer, and mark the box when a problem is an error. */
|
|
275
|
+
private paint;
|
|
276
|
+
/** Tell the host, once, when the problem list actually changed. */
|
|
277
|
+
private announceDiagnostics;
|
|
278
|
+
/**
|
|
279
|
+
* Size the box to its content.
|
|
280
|
+
*
|
|
281
|
+
* The mirror has no scrollbar, so its measurement is the height the content wants
|
|
282
|
+
* with the full width available — which is exactly the number that decides whether
|
|
283
|
+
* a scrollbar is needed at all. If it fits under the maximum, the height becomes
|
|
284
|
+
* the content height and the overflow stays hidden, which is the promise of "grow
|
|
285
|
+
* and shrink so no scrollbar is ever shown". If it does not fit, the height is
|
|
286
|
+
* clamped and the overflow becomes `auto`.
|
|
287
|
+
*
|
|
288
|
+
* Clamping introduces a second problem that is easy to miss: a scrollbar narrows
|
|
289
|
+
* the text, so the field rewraps, so the PAINT no longer wraps the same way and
|
|
290
|
+
* every coloured span slides off its character. The measured scrollbar width is
|
|
291
|
+
* therefore published as a custom property, and the stylesheet adds it to the
|
|
292
|
+
* layer's own right padding so the two keep wrapping identically.
|
|
293
|
+
*
|
|
294
|
+
* An UNMOUNTED field is skipped rather than measured. Before the element is in the
|
|
295
|
+
* document it has no layout, so its `clientWidth` is zero, the mirror wraps at every
|
|
296
|
+
* character, and the measurement comes back several times too tall — a wrong height
|
|
297
|
+
* that then has to be corrected on the next keystroke, which is what a box that
|
|
298
|
+
* jumps on first focus actually is. The `ResizeObserver` installed at construction
|
|
299
|
+
* does the first real measurement as soon as there is a width to measure against.
|
|
300
|
+
* @param text - the current text.
|
|
301
|
+
*/
|
|
302
|
+
private resize;
|
|
303
|
+
/** The caret's offset, clamped into the text. */
|
|
304
|
+
private caret;
|
|
305
|
+
/** Resolve and show a list for the caret. */
|
|
306
|
+
private openCompletion;
|
|
307
|
+
/** Close the list and tell the host. */
|
|
308
|
+
private closeCompletion;
|
|
309
|
+
/** Keep the field's `aria-activedescendant` pointing at the active row. */
|
|
310
|
+
private syncActiveDescendant;
|
|
311
|
+
/** Put the list under the caret. */
|
|
312
|
+
private placePopup;
|
|
313
|
+
/**
|
|
314
|
+
* Take the active row.
|
|
315
|
+
* @param index - the row to take.
|
|
316
|
+
* @param commitCharacter - a character typed to trigger the pick, written after
|
|
317
|
+
* the completion so the keystroke is not swallowed.
|
|
318
|
+
*/
|
|
319
|
+
private acceptCompletion;
|
|
320
|
+
/** Decide what an edit does to the list. */
|
|
321
|
+
private updateCompletionAfterInput;
|
|
322
|
+
/** Whether a keystroke is a reason to offer suggestions. */
|
|
323
|
+
private shouldAutoOpen;
|
|
324
|
+
/** Close a list the caret has left. */
|
|
325
|
+
private updateCompletionForCaret;
|
|
326
|
+
/** Start, or restart, the timer that shows a tooltip. */
|
|
327
|
+
private queueHover;
|
|
328
|
+
/** Resolve and show a tooltip. */
|
|
329
|
+
private showHover;
|
|
330
|
+
/** Hide the tooltip and forget what it described. */
|
|
331
|
+
private hideTooltip;
|
|
332
|
+
/** Attach every listener. */
|
|
333
|
+
private bind;
|
|
334
|
+
/** Detach every listener. */
|
|
335
|
+
private unbind;
|
|
336
|
+
private readonly onInput;
|
|
337
|
+
private readonly onKeyDown;
|
|
338
|
+
/**
|
|
339
|
+
* Whether a keystroke is a commit character for the active row.
|
|
340
|
+
*
|
|
341
|
+
* Typing `=` at the end of `shape` takes the `shape=` row and keeps the
|
|
342
|
+
* character, rather than either swallowing the keystroke or leaving the row to be
|
|
343
|
+
* clicked. A row opts in; nothing has a commit character by default.
|
|
344
|
+
* @param event - the key event.
|
|
345
|
+
* @returns whether the keystroke was consumed.
|
|
346
|
+
*/
|
|
347
|
+
private commitCharacter;
|
|
348
|
+
/** Make a row active and keep the ARIA pointer in step. */
|
|
349
|
+
private setActive;
|
|
350
|
+
private readonly onScroll;
|
|
351
|
+
private readonly onCaretMoved;
|
|
352
|
+
private readonly onKeyUp;
|
|
353
|
+
private readonly onSelectionChange;
|
|
354
|
+
private readonly onBlur;
|
|
355
|
+
private readonly onMouseMove;
|
|
356
|
+
private readonly onMouseLeave;
|
|
357
|
+
private readonly onCompositionStart;
|
|
358
|
+
private readonly onCompositionEnd;
|
|
359
|
+
}
|
|
360
|
+
/** A severity, re-exported so a host can narrow a diagnostic without importing core. */
|
|
361
|
+
export type EditorSeverity = Severity;
|
|
362
|
+
/** A range, re-exported for the same reason. */
|
|
363
|
+
export type EditorRange = Range;
|
|
364
|
+
/** A decoration, re-exported for the same reason. */
|
|
365
|
+
export type EditorDecoration = Decoration;
|
|
366
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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YAAY,CAG5B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO,CAOvB;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAGjC;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAKtB;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAY3B;IAED,OAAO,CAAC,QAAQ,CAAC,YAAY,CAG5B;IAED,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAGlC;IAED,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAGhC;CACF;AA4CD,wFAAwF;AACxF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAA;AAErC,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,KAAK,CAAA;AAE/B,qDAAqD;AACrD,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { LiteArea, type EditorDecoration, type EditorRange, type EditorSeverity, type LiteAreaCompletion, type LiteAreaHover, type LiteAreaOptions, type LiteAreaSizing, } from './editor.js';
|
|
2
|
+
export { createEditor } from './create.js';
|
|
3
|
+
export { dispatchInput, fieldLineHeight, readSelection, redoField, replaceThroughPipeline, undoField, writeDocument, writeSelection, type EditOutcome, type TextSelection, } from './editing.js';
|
|
4
|
+
export { TextMirror, type CaretBox } from './mirror.js';
|
|
5
|
+
export { Overlay, type OverlayClassNames } from './overlay.js';
|
|
6
|
+
export { Popup, type AnchorBox, type PopupHandlers } from './popup.js';
|
|
7
|
+
export { Tooltip, type TooltipAnchor } from './tooltip.js';
|
|
8
|
+
export { canEditThroughPipeline, hasCaretHitTest, hasDocument, offsetFromPoint, withDefaults, } from './support.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dom/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,SAAS,EACT,aAAa,EACb,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAE9D,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAEtE,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAE1D,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAA"}
|