@rcarls/rc-textarea 0.1.0 → 0.3.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/README.md +173 -1176
- package/dist/custom-elements.json +168 -72
- package/dist/{line-actions-controller-BsM6DJ0b.js → line-actions-controller-ChmbiQ-G.js} +573 -532
- package/dist/line-actions-controller-ChmbiQ-G.js.map +1 -0
- package/dist/rc-textarea-define.js +2 -2
- package/dist/rc-textarea.js +1 -1
- package/dist/types/packages/rc-textarea/src/blots.d.ts +7 -7
- package/dist/types/packages/rc-textarea/src/decoration.d.ts +5 -2
- package/dist/types/packages/rc-textarea/src/document.d.ts +7 -9
- package/dist/types/packages/rc-textarea/src/line-actions-controller.d.ts +12 -9
- package/dist/types/packages/rc-textarea/src/line-decorator.d.ts +9 -8
- package/dist/types/packages/rc-textarea/src/pattern-matcher.d.ts +4 -2
- package/dist/types/packages/rc-textarea/src/rc-textarea.d.ts +101 -32
- package/dist/types/packages/rc-textarea/src/selection.d.ts +17 -13
- package/dist/types/packages/rc-textarea/src/test-helpers.d.ts +6 -4
- package/dist/types/packages/rc-textarea/src/types.d.ts +119 -40
- package/package.json +7 -8
- package/dist/demo.css +0 -85
- package/dist/demo.js +0 -40
- package/dist/line-actions-controller-BsM6DJ0b.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Registry, ScrollBlot, BlockBlot, InlineBlot, EmbedBlot } from 'parchment';
|
|
2
2
|
import { MarkDecoration } from './types.ts';
|
|
3
3
|
export { Registry };
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class RCScrollBlot extends ScrollBlot {
|
|
5
5
|
static blotName: string;
|
|
6
6
|
constructor(registry: Registry, domNode: HTMLDivElement);
|
|
7
7
|
update(_mutations: MutationRecord[], _context: Record<string, unknown>): void;
|
|
@@ -12,25 +12,25 @@ export declare class V2ScrollBlot extends ScrollBlot {
|
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}): void;
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class RCBlockBlot extends BlockBlot {
|
|
16
16
|
static blotName: string;
|
|
17
17
|
static tagName: string;
|
|
18
18
|
static className: string;
|
|
19
19
|
}
|
|
20
20
|
type InlineFormats = Pick<MarkDecoration, 'className' | 'bold' | 'italic' | 'color' | 'background' | 'underline' | 'underlineColor'>;
|
|
21
|
-
export declare class
|
|
21
|
+
export declare class RCInlineBlot extends InlineBlot {
|
|
22
22
|
static blotName: string;
|
|
23
23
|
static tagName: string;
|
|
24
24
|
static className: string;
|
|
25
25
|
static create(formats?: InlineFormats): HTMLElement;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Apply `MarkDecoration` style properties to a `.
|
|
29
|
-
* inline styles and extra CSS classes. Called by `
|
|
28
|
+
* Apply `MarkDecoration` style properties to a `.mark` span element as
|
|
29
|
+
* inline styles and extra CSS classes. Called by `RCInlineBlot.create()` and
|
|
30
30
|
* by external code that needs to style a span to match a decoration.
|
|
31
31
|
*/
|
|
32
|
-
export declare function applyInlineFormats(el: HTMLSpanElement, formats: InlineFormats): void;
|
|
33
|
-
export declare class
|
|
32
|
+
export declare function applyInlineFormats($el: HTMLSpanElement, formats: InlineFormats): void;
|
|
33
|
+
export declare class RCWidgetBlot extends EmbedBlot {
|
|
34
34
|
static blotName: string;
|
|
35
35
|
static tagName: string;
|
|
36
36
|
static className: string;
|
|
@@ -20,6 +20,8 @@ interface Edit {
|
|
|
20
20
|
* This is a heuristic ("longest common prefix/suffix"), not a full LCS diff.
|
|
21
21
|
* It assumes the browser makes one contiguous edit per input event, which holds
|
|
22
22
|
* true for normal typing, deletion, and paste.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link http://www.xmailserver.org/diff2.pdf Myers 1986 — An O(ND) Difference Algorithm and Its Variations}
|
|
23
25
|
*/
|
|
24
26
|
export declare function findEdit(oldValue: string, newValue: string): Edit;
|
|
25
27
|
/**
|
|
@@ -51,10 +53,11 @@ export declare function isLargeChange(oldValue: string, edit: Edit): boolean;
|
|
|
51
53
|
*
|
|
52
54
|
* This is the primary entry point used by the component on each input event.
|
|
53
55
|
*/
|
|
54
|
-
export declare function
|
|
56
|
+
export declare function remapDecorations(decorations: Decoration[], oldValue: string, newValue: string): Decoration[];
|
|
55
57
|
/**
|
|
56
58
|
* Add a single decoration to `map`, assigning it a fresh UUID as its `id`.
|
|
57
|
-
*
|
|
59
|
+
*
|
|
60
|
+
* @returns the assigned `id`, used to remove or look up the decoration later
|
|
58
61
|
*/
|
|
59
62
|
export declare function addDecoration(map: Map<string, Decoration>, input: DecorationInput): string;
|
|
60
63
|
/**
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { Decoration } from './types.ts';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class RCDocument {
|
|
3
3
|
private readonly scroll;
|
|
4
|
-
constructor(
|
|
4
|
+
constructor($documentRoot: HTMLDivElement);
|
|
5
5
|
/**
|
|
6
|
-
* Rebuild the document tree
|
|
7
|
-
*
|
|
6
|
+
* Rebuild the document tree.
|
|
7
|
+
*
|
|
8
|
+
* Reuses existing `.line` elements in place to preserve DOM identity
|
|
8
9
|
* across renders (fixes DevTools node tracking and mouse gesture continuity).
|
|
9
|
-
* Only the children of each line are replaced; the line element itself survives.
|
|
10
10
|
*/
|
|
11
11
|
build(value: string, decorations: Decoration[]): void;
|
|
12
12
|
destroy(): void;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Extracts plain text directly from the
|
|
16
|
-
* Handles our structured .v2-line divs as well as browser-inserted markup
|
|
17
|
-
* from edits that happen between render frames.
|
|
15
|
+
* Extracts plain text directly from the contenteditable DOM.
|
|
18
16
|
*/
|
|
19
|
-
export declare function
|
|
17
|
+
export declare function getText($editorEl: HTMLElement): string;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { RCTextareaPluginAPI, DecorationInput } from './types.ts';
|
|
2
2
|
export interface LineAction {
|
|
3
|
+
/** Stable identifier used for action-set change detection. */
|
|
3
4
|
id: string;
|
|
5
|
+
/** Human-readable label; used as button text and accessible name. */
|
|
4
6
|
label: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
+
/** Icon name passed to `LineActionsOptions.createIcon`, e.g. `'mdi-lock-outline'`. */
|
|
8
|
+
iconName?: string;
|
|
9
|
+
/** Called when the action button is activated. */
|
|
7
10
|
onClick: () => void;
|
|
8
11
|
}
|
|
9
12
|
export interface LineActionsOptions {
|
|
10
|
-
/** Where to place the inline widget. Default: 'append'
|
|
13
|
+
/** Where to place the inline widget. Default: `'append'`. */
|
|
11
14
|
position?: 'append';
|
|
12
15
|
/**
|
|
13
|
-
* Create and return a DOM element for the given icon name (e.g. 'mdi-lock-outline').
|
|
14
|
-
* Called when `action.
|
|
16
|
+
* Create and return a DOM element for the given icon name (e.g. `'mdi-lock-outline'`).
|
|
17
|
+
* Called when `action.iconName` is set. Return `null` to fall back to text label.
|
|
15
18
|
*
|
|
16
|
-
* @example
|
|
19
|
+
* @example
|
|
17
20
|
* ```ts
|
|
18
21
|
* createIcon: (name) => {
|
|
19
|
-
* const
|
|
20
|
-
*
|
|
21
|
-
* return
|
|
22
|
+
* const $icon = document.createElement('iconify-icon');
|
|
23
|
+
* $icon.setAttribute('icon', name);
|
|
24
|
+
* return $icon;
|
|
22
25
|
* }
|
|
23
26
|
* ```
|
|
24
27
|
*/
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { DecorationInput, LineDecoratorPlugin, RCTextareaPlugin } from './types.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Options for `createLineDecoratorPlugin`.
|
|
4
|
-
*/
|
|
5
2
|
export interface LineDecoratorPluginOptions {
|
|
6
3
|
/**
|
|
7
|
-
* An array of subscriber setup functions
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* An array of subscriber setup functions for (e.g., reactive
|
|
5
|
+
* signals).
|
|
6
|
+
*
|
|
7
|
+
* Each function receives a callback and should call it whenever an external
|
|
8
|
+
* value changes . It may return an optional cleanup/unsubscribe function
|
|
9
|
+
* called on plugin destroy.
|
|
11
10
|
*
|
|
12
11
|
* This is intentionally framework-agnostic. For Solid.js signals:
|
|
13
12
|
* ```ts
|
|
@@ -19,8 +18,9 @@ export interface LineDecoratorPluginOptions {
|
|
|
19
18
|
watch?: Array<(onChange: () => void) => (() => void) | void>;
|
|
20
19
|
/**
|
|
21
20
|
* Called once per update pass **after** all per-line decorations are built.
|
|
21
|
+
*
|
|
22
22
|
* Use this to merge in decorations that require the full document value
|
|
23
|
-
* (e.g
|
|
23
|
+
* (e.g., diagnostics from a whole-document parser).
|
|
24
24
|
*/
|
|
25
25
|
extraDecorations?: (value: string) => DecorationInput[];
|
|
26
26
|
}
|
|
@@ -28,6 +28,7 @@ export interface LineDecoratorPluginOptions {
|
|
|
28
28
|
* Factory that wraps a `LineDecoratorPlugin` in a full `RCTextareaPlugin`.
|
|
29
29
|
*
|
|
30
30
|
* Handles the boilerplate that every per-line decorator needs:
|
|
31
|
+
*
|
|
31
32
|
* - CSS injection via `api.adoptStyleSheet` on mount
|
|
32
33
|
* - `lineStart` offset bookkeeping when converting line-relative offsets to
|
|
33
34
|
* absolute document offsets
|
|
@@ -4,8 +4,9 @@ export type { TextPattern };
|
|
|
4
4
|
* Run all `patterns` against `value` and collect every match as decorations.
|
|
5
5
|
*
|
|
6
6
|
* For each pattern:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
*
|
|
8
|
+
* - If `captureGroups` is set, one `MarkDecoration` is emitted per named
|
|
9
|
+
* capture group instead of one for the whole match. Unmatched optional
|
|
9
10
|
* groups are silently skipped. The `d` flag (match indices) is added to
|
|
10
11
|
* the regex automatically.
|
|
11
12
|
* - Otherwise, one `MarkDecoration` covering the entire match is emitted,
|
|
@@ -15,6 +16,7 @@ export type { TextPattern };
|
|
|
15
16
|
*
|
|
16
17
|
* The global flag is added automatically if missing to ensure all occurrences
|
|
17
18
|
* are found and to avoid stateful `lastIndex` bugs on the caller's regex.
|
|
19
|
+
*
|
|
18
20
|
* Zero-length matches are skipped to prevent infinite loops.
|
|
19
21
|
*/
|
|
20
22
|
export declare function matchPatternResults(value: string, patterns: TextPattern[]): {
|
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
import { LitElement, CSSResultGroup } from 'lit';
|
|
2
2
|
import { SavedSelection } from './selection.ts';
|
|
3
3
|
import { Decoration, DecorationInput, RCTextareaPlugin, RCTextareaPluginAPI, TextPattern } from './types.ts';
|
|
4
|
+
declare global {
|
|
5
|
+
interface HTMLElementTagNameMap {
|
|
6
|
+
'rc-textarea': RCTextarea;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
|
-
*
|
|
10
|
+
* Textarea wrapper with line decorations, gutter rendering, inline widgets, and plugin hooks.
|
|
11
|
+
*
|
|
12
|
+
* Provide a native `<textarea>` as the direct child when the component is
|
|
13
|
+
* editable. Read-only displays may be driven from `value` or `defaultValue`.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-textarea rc-textarea docs}
|
|
16
|
+
*
|
|
17
|
+
* @example Basic usage
|
|
18
|
+
* ```html
|
|
19
|
+
* <label for="editor">Source</label>
|
|
20
|
+
* <rc-textarea>
|
|
21
|
+
* <textarea id="editor" name="source"></textarea>
|
|
22
|
+
* </rc-textarea>
|
|
23
|
+
* ```
|
|
6
24
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
25
|
+
* @example Controlled value (JavaScript)
|
|
26
|
+
* ```js
|
|
27
|
+
* const editor = document.querySelector('rc-textarea');
|
|
28
|
+
* editor.value = 'hello world';
|
|
29
|
+
* editor.addEventListener('rc-textarea-change', (e) => {
|
|
30
|
+
* console.log(e.target.value);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @slot - Accepts a native `<textarea>` element for form wiring.
|
|
35
|
+
*
|
|
36
|
+
* @fires rc-textarea-change - Fired when the field value changes
|
|
37
|
+
* @fires rc-textarea-blur - Fired when the field loses focus
|
|
38
|
+
*
|
|
39
|
+
* @cssprop [--rc-textarea-border=1px solid ButtonBorder] - Border around the field
|
|
40
|
+
* @cssprop [--rc-textarea-border-radius=2px] - Border radius of the field
|
|
41
|
+
* @cssprop [--rc-textarea-background=Field] - Background color of the field
|
|
13
42
|
* @cssprop [--rc-textarea-color=FieldText] - Text color; falls back through --rc-text
|
|
14
43
|
* @cssprop [--rc-textarea-font-family=monospace] - Font family
|
|
15
44
|
* @cssprop [--rc-textarea-font-size=1em] - Font size
|
|
16
45
|
* @cssprop [--rc-textarea-line-height=1.5] - Line height
|
|
17
|
-
* @cssprop [--rc-textarea-padding=0.5em] - Padding inside the
|
|
46
|
+
* @cssprop [--rc-textarea-padding=0.5em] - Padding inside the field area
|
|
18
47
|
* @cssprop [--rc-textarea-focus-outline=2px solid Highlight] - Focus ring outline
|
|
19
48
|
* @cssprop [--rc-textarea-caret-color=FieldText] - Caret color
|
|
20
49
|
* @cssprop [--rc-textarea-active-line-bg=transparent] - Active line highlight color
|
|
@@ -32,21 +61,42 @@ export declare class RCTextarea extends LitElement {
|
|
|
32
61
|
serializable?: boolean;
|
|
33
62
|
slotAssignment?: SlotAssignmentMode;
|
|
34
63
|
};
|
|
64
|
+
/** Show sequential line numbers in the gutter. Enables the gutter implicitly. */
|
|
35
65
|
lineNumbers: boolean;
|
|
36
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use a plugin with `LineDecoration.gutterContent` to implement
|
|
68
|
+
* sparse line numbering. This property will be removed before v1.0.
|
|
69
|
+
*/
|
|
70
|
+
get listNumbers(): boolean;
|
|
71
|
+
set listNumbers(value: boolean);
|
|
72
|
+
private _listNumbers;
|
|
73
|
+
/**
|
|
74
|
+
* Enable the gutter column without any built-in content.
|
|
75
|
+
*
|
|
76
|
+
* Plugins can populate individual cells via `LineDecoration.gutterContent`.
|
|
77
|
+
* For sequential line numbers use `lineNumbers` / `line-numbers` instead.
|
|
78
|
+
*/
|
|
37
79
|
gutter: boolean;
|
|
80
|
+
/** Wrap long lines within the field to prevent horizontal overflow. */
|
|
38
81
|
wordWrap: boolean;
|
|
82
|
+
/** Allow the field to grow vertically with content to prevent vertical overflow. */
|
|
39
83
|
autoGrow: boolean;
|
|
84
|
+
/** Disable editing. The field renders as a styled read-only display. */
|
|
40
85
|
readOnly: boolean;
|
|
41
|
-
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Set `aria-label` on the slotted `<textarea>` instead, or
|
|
88
|
+
* associate a `<label>` element via its `for`/`id` pair. This property
|
|
89
|
+
* will be removed before v1.0.
|
|
90
|
+
*/
|
|
91
|
+
get label(): string | null;
|
|
92
|
+
set label(value: string | null);
|
|
93
|
+
private _label;
|
|
42
94
|
/** Declarative plugin hook for framework integrations. */
|
|
43
95
|
get plugin(): RCTextareaPlugin | null;
|
|
44
96
|
/** Declarative plugin hook for framework integrations. */
|
|
45
97
|
set plugin(plugin: RCTextareaPlugin | null);
|
|
46
98
|
/**
|
|
47
|
-
*
|
|
48
|
-
* Ideal for reactive frameworks (Solid, React 19+, Vue 3) where decorations are
|
|
49
|
-
* computed as reactive state and passed directly as a property:
|
|
99
|
+
* Imperatively set an external layer of decorations. Ideal for reactive frameworks.
|
|
50
100
|
*
|
|
51
101
|
* ```tsx
|
|
52
102
|
* // Solid
|
|
@@ -62,17 +112,21 @@ export declare class RCTextarea extends LitElement {
|
|
|
62
112
|
*/
|
|
63
113
|
get decorations(): DecorationInput[];
|
|
64
114
|
set decorations(value: DecorationInput[] | undefined);
|
|
115
|
+
protected _$editor: HTMLElement;
|
|
116
|
+
protected _$gutterCells: HTMLElement;
|
|
117
|
+
protected _$slot: HTMLSlotElement;
|
|
65
118
|
private _value;
|
|
66
119
|
private _defaultValue;
|
|
67
120
|
private _initialValueResolved;
|
|
68
121
|
private _valueSetByHost;
|
|
69
122
|
private _document;
|
|
70
|
-
private
|
|
71
|
-
|
|
123
|
+
private _$textareaRef;
|
|
124
|
+
private readonly _textareaController;
|
|
125
|
+
/** Plugin-owned decorations */
|
|
72
126
|
protected _pluginDecorations: Map<string, Decoration>;
|
|
73
127
|
/** Pattern-generated decorations (rebuilt on each value change). */
|
|
74
128
|
private _patternDecorations;
|
|
75
|
-
/**
|
|
129
|
+
/** Imperative decorations (set directly via the `decorations` property) */
|
|
76
130
|
private _externalDecorations;
|
|
77
131
|
/** Registered patterns. */
|
|
78
132
|
private _patterns;
|
|
@@ -87,29 +141,37 @@ export declare class RCTextarea extends LitElement {
|
|
|
87
141
|
private _rafHandle;
|
|
88
142
|
private _composing;
|
|
89
143
|
private _isRendering;
|
|
90
|
-
/** The currently highlighted `.
|
|
91
|
-
private
|
|
144
|
+
/** The currently highlighted `.line` element (active line). */
|
|
145
|
+
private _$activeLine;
|
|
92
146
|
/** Callbacks registered via PluginAPI.onCursorMove(). */
|
|
93
147
|
private _cursorCallbacks;
|
|
94
148
|
private _docSelectionChangeHandler;
|
|
95
|
-
/**
|
|
149
|
+
/** Synthetic undo/redo stack (DOM rebuilds invalidate native undo) */
|
|
96
150
|
private _undoStack;
|
|
97
151
|
private _undoIndex;
|
|
98
152
|
private _resizeObserver;
|
|
99
153
|
/** Cached per-line gutter labels from the last render — reused by ResizeObserver. */
|
|
100
154
|
private _gutterLabels;
|
|
155
|
+
/**
|
|
156
|
+
* The current field value.
|
|
157
|
+
*
|
|
158
|
+
* Setting this property puts the component into
|
|
159
|
+
* controlled mode (host owns the value, changes are reflected
|
|
160
|
+
* immediately, no change events dispatched)
|
|
161
|
+
*/
|
|
101
162
|
get value(): string;
|
|
102
|
-
set value(
|
|
103
|
-
/** Initial uncontrolled
|
|
163
|
+
set value(val: string);
|
|
164
|
+
/** Initial uncontrolled value. */
|
|
104
165
|
get defaultValue(): string | undefined;
|
|
105
|
-
|
|
106
|
-
set defaultValue(v: string | undefined);
|
|
166
|
+
set defaultValue(val: string | undefined);
|
|
107
167
|
connectedCallback(): void;
|
|
108
168
|
disconnectedCallback(): void;
|
|
109
169
|
firstUpdated(): void;
|
|
110
170
|
updated(changed: Map<string, unknown>): void;
|
|
111
171
|
render(): import('lit').TemplateResult<1>;
|
|
112
172
|
private _onSlotChange;
|
|
173
|
+
private _setupTextarea;
|
|
174
|
+
private _onTextareaInvalid;
|
|
113
175
|
private _bindEditorEvents;
|
|
114
176
|
private _onInputEvent;
|
|
115
177
|
private _onInput;
|
|
@@ -134,13 +196,19 @@ export declare class RCTextarea extends LitElement {
|
|
|
134
196
|
*/
|
|
135
197
|
replaceSelection(text: string): void;
|
|
136
198
|
private _onPaste;
|
|
137
|
-
/** Reset the undo/redo history. Call when the
|
|
199
|
+
/** Reset the undo/redo history. Call when the field receives entirely new content. */
|
|
138
200
|
clearHistory(): void;
|
|
139
201
|
protected _pushUndo(sel: SavedSelection | null): void;
|
|
140
202
|
private _undo;
|
|
141
203
|
private _redo;
|
|
142
204
|
private _applyUndoEntry;
|
|
205
|
+
/**
|
|
206
|
+
* Register and mount a plugin imperatively.
|
|
207
|
+
* Replaces any currently active plugin. Prefer the `plugin` property for
|
|
208
|
+
* reactive-framework integrations.
|
|
209
|
+
*/
|
|
143
210
|
usePlugin(plugin: RCTextareaPlugin): void;
|
|
211
|
+
/** Unmount the active plugin, clear its decorations, and release its stylesheets. */
|
|
144
212
|
removePlugin(): void;
|
|
145
213
|
/**
|
|
146
214
|
* Build the `RCTextareaPluginAPI` object passed to the active plugin's
|
|
@@ -149,14 +217,20 @@ export declare class RCTextarea extends LitElement {
|
|
|
149
217
|
*/
|
|
150
218
|
private _buildPluginApi;
|
|
151
219
|
private _clearPluginSheets;
|
|
220
|
+
/**
|
|
221
|
+
* Register a text pattern that generates decorations on every render pass.
|
|
222
|
+
* Returns the pattern ID, which can be passed to `removePattern` to unregister it.
|
|
223
|
+
*/
|
|
152
224
|
addPattern(pattern: Omit<TextPattern, 'id'>): string;
|
|
225
|
+
/** Remove a previously registered pattern by the ID returned from `addPattern`. */
|
|
153
226
|
removePattern(id: string): void;
|
|
227
|
+
/** Remove all registered patterns and trigger a re-render. */
|
|
154
228
|
clearPatterns(): void;
|
|
155
229
|
protected _scheduleRender(): void;
|
|
156
230
|
private _performRender;
|
|
157
231
|
/**
|
|
158
232
|
* Compute the label string for each gutter cell based on the current gutter
|
|
159
|
-
* mode (`lineNumbers`, `listNumbers
|
|
233
|
+
* mode (`lineNumbers`, `listNumbers` (deprecated), `gutter`) and any
|
|
160
234
|
* `LineDecoration.gutterContent` overrides in `allDecorations`.
|
|
161
235
|
*
|
|
162
236
|
* Returns one entry per line (same length as `value.split('\n')`):
|
|
@@ -166,7 +240,7 @@ export declare class RCTextarea extends LitElement {
|
|
|
166
240
|
private _computeGutterLabels;
|
|
167
241
|
/**
|
|
168
242
|
* Synchronize the pixel height of each gutter cell to match the
|
|
169
|
-
* corresponding `.
|
|
243
|
+
* corresponding `.line` element in the editor.
|
|
170
244
|
*
|
|
171
245
|
* In non-word-wrap mode the gutter uses a uniform `line-height` mirrored
|
|
172
246
|
* from the editor's first line. In word-wrap mode each cell gets an explicit
|
|
@@ -182,13 +256,8 @@ export declare class RCTextarea extends LitElement {
|
|
|
182
256
|
* (called by the `ResizeObserver` without a new render pass).
|
|
183
257
|
*/
|
|
184
258
|
private _syncGutter;
|
|
259
|
+
private _syncLabel;
|
|
185
260
|
private _syncTypography;
|
|
186
261
|
protected _syncTextareaValue(fromUser?: boolean): void;
|
|
187
262
|
protected _dispatchChange(value: string): void;
|
|
188
|
-
private _getEditorEl;
|
|
189
|
-
}
|
|
190
|
-
declare global {
|
|
191
|
-
interface HTMLElementTagNameMap {
|
|
192
|
-
'rc-textarea': RCTextarea;
|
|
193
|
-
}
|
|
194
263
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Cursor save/restore for rc-textarea's contenteditable editor.
|
|
3
3
|
*
|
|
4
4
|
* The text model is a plain string with \n line separators.
|
|
5
|
-
*
|
|
6
|
-
* the text model (not part
|
|
7
|
-
* <br> elements (used to make empty lines editable) count
|
|
5
|
+
*
|
|
6
|
+
* WidgetDecoration spans (.widget) are zero-width in the text model (not part
|
|
7
|
+
* of the value string). <br> elements (used to make empty lines editable) count
|
|
8
|
+
* as 0 characters.
|
|
8
9
|
*/
|
|
9
10
|
export interface SavedSelection {
|
|
10
11
|
/** Anchor position as a character offset into the plain text value. */
|
|
@@ -13,27 +14,30 @@ export interface SavedSelection {
|
|
|
13
14
|
focusOffset: number;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
|
-
* Converts a DOM (node, nodeOffset) pair inside
|
|
17
|
-
* Returns -
|
|
17
|
+
* Converts a DOM (node, nodeOffset) pair inside `$root` to a plain-text offset.
|
|
18
|
+
* Returns the end-of-content offset if the target was not found inside `$root`.
|
|
18
19
|
*/
|
|
19
|
-
export declare function domToTextOffset(root: Element, targetNode: Node, targetNodeOffset: number): number;
|
|
20
|
+
export declare function domToTextOffset($root: Element, $targetNode: Node, targetNodeOffset: number): number;
|
|
20
21
|
interface DomPosition {
|
|
21
22
|
node: Node;
|
|
22
23
|
offset: number;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
|
-
* Converts a plain-text offset to a (node, nodeOffset) DOM position inside
|
|
26
|
+
* Converts a plain-text offset to a (node, nodeOffset) DOM position inside `$root`.
|
|
27
|
+
*
|
|
26
28
|
* Returns null if offset is out of range.
|
|
27
29
|
*/
|
|
28
|
-
export declare function textOffsetToDom(root: Element, targetOffset: number): DomPosition | null;
|
|
30
|
+
export declare function textOffsetToDom($root: Element, targetOffset: number): DomPosition | null;
|
|
29
31
|
/**
|
|
30
|
-
* Captures the current browser selection as plain-text offsets relative to
|
|
31
|
-
*
|
|
32
|
+
* Captures the current browser selection as plain-text offsets relative to `$root`.
|
|
33
|
+
*
|
|
34
|
+
* Returns null if there is no selection or the selection is outside `$root`.
|
|
32
35
|
*/
|
|
33
|
-
export declare function saveSelection(root: Element): SavedSelection | null;
|
|
36
|
+
export declare function saveSelection($root: Element): SavedSelection | null;
|
|
34
37
|
/**
|
|
35
|
-
* Restores a previously saved selection inside
|
|
38
|
+
* Restores a previously saved selection inside `$root`.
|
|
39
|
+
*
|
|
36
40
|
* Silently does nothing if the saved offsets are out of range.
|
|
37
41
|
*/
|
|
38
|
-
export declare function restoreSelection(root: Element, saved: SavedSelection): void;
|
|
42
|
+
export declare function restoreSelection($root: Element, saved: SavedSelection): void;
|
|
39
43
|
export {};
|
|
@@ -8,11 +8,13 @@ export declare function getSlottedTextarea(host: RCTextarea): HTMLTextAreaElemen
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function waitRender(): Promise<void>;
|
|
10
10
|
/**
|
|
11
|
-
* Dispatches a synthetic paste event carrying plain text onto
|
|
11
|
+
* Dispatches a synthetic paste event carrying plain text onto `$editor`.
|
|
12
12
|
*
|
|
13
13
|
* Using a plain Event + manual clipboardData override because `new ClipboardEvent`
|
|
14
14
|
* with a DataTransfer in the init dict is not reliable across browsers (Firefox
|
|
15
|
-
* ignores the init's clipboardData).
|
|
16
|
-
*
|
|
15
|
+
* ignores the init's clipboardData).
|
|
16
|
+
*
|
|
17
|
+
* The paste handler only calls `e.clipboardData?.getData('text/plain')`, so
|
|
18
|
+
* a minimal duck-typed mock is enough.
|
|
17
19
|
*/
|
|
18
|
-
export declare function simulatePaste(editor: HTMLElement, text: string): void;
|
|
20
|
+
export declare function simulatePaste($editor: HTMLElement, text: string): void;
|