@rcarls/rc-textarea 0.3.1 → 0.4.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 +19 -18
- package/dist/custom-elements.json +89 -48
- package/dist/{line-actions-controller-x4P2Yjd4.js → line-actions-controller-TP6g5HYk.js} +346 -323
- package/dist/line-actions-controller-TP6g5HYk.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/rc-textarea.d.ts +75 -39
- package/package.json +1 -1
- package/dist/line-actions-controller-x4P2Yjd4.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { LitElement, CSSResultGroup } from 'lit';
|
|
2
|
+
import { NativeChildController } from '@rcarls/rc-common';
|
|
3
|
+
import { RCDocument } from './document.ts';
|
|
2
4
|
import { SavedSelection } from './selection.ts';
|
|
3
5
|
import { Decoration, DecorationInput, RCTextareaPlugin, RCTextareaPluginAPI, TextPattern } from './types.ts';
|
|
4
6
|
declare global {
|
|
@@ -6,6 +8,11 @@ declare global {
|
|
|
6
8
|
'rc-textarea': RCTextarea;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
11
|
+
interface UndoEntry {
|
|
12
|
+
value: string;
|
|
13
|
+
anchorOffset: number;
|
|
14
|
+
focusOffset: number;
|
|
15
|
+
}
|
|
9
16
|
/**
|
|
10
17
|
* Textarea wrapper with line decorations, gutter rendering, inline widgets, and plugin hooks.
|
|
11
18
|
*
|
|
@@ -36,6 +43,22 @@ declare global {
|
|
|
36
43
|
* @fires rc-textarea-change - Fired when the field value changes
|
|
37
44
|
* @fires rc-textarea-blur - Fired when the field loses focus
|
|
38
45
|
*
|
|
46
|
+
* @csspart root - The outer flex container wrapping the gutter and editor area.
|
|
47
|
+
* @csspart gutter - The gutter column container.
|
|
48
|
+
* @csspart gutter-cells - The gutter's line-label list.
|
|
49
|
+
* @csspart editor-area - The container positioning the editor over the slotted textarea.
|
|
50
|
+
* @csspart editor - The contenteditable field surface.
|
|
51
|
+
*
|
|
52
|
+
* @attr line-numbers - Show sequential line numbers in the gutter. Enables the gutter implicitly.
|
|
53
|
+
* @attr list-numbers - Deprecated alias for sparse line numbering; removed before v1.0.
|
|
54
|
+
* @attr gutter - Enable the gutter column without any built-in content.
|
|
55
|
+
* @attr word-wrap - Wrap long lines within the field to prevent horizontal overflow.
|
|
56
|
+
* @attr auto-grow - Allow the field to grow vertically with content to prevent vertical overflow.
|
|
57
|
+
* @attr read-only - Disable editing. The field renders as a styled read-only display.
|
|
58
|
+
* @attr label - Deprecated accessible-name override; removed before v1.0.
|
|
59
|
+
* @attr value - Current field value.
|
|
60
|
+
* @attr default-value - Initial uncontrolled value.
|
|
61
|
+
*
|
|
39
62
|
* @cssprop [--rc-textarea-border=1px solid ButtonBorder] - Border around the field
|
|
40
63
|
* @cssprop [--rc-textarea-border-radius=2px] - Border radius of the field
|
|
41
64
|
* @cssprop [--rc-textarea-background=Field] - Background color of the field
|
|
@@ -50,6 +73,8 @@ declare global {
|
|
|
50
73
|
* @cssprop [--rc-textarea-gutter-bg=Canvas] - Gutter background color
|
|
51
74
|
* @cssprop [--rc-textarea-gutter-color=GrayText] - Gutter text color
|
|
52
75
|
* @cssprop [--rc-textarea-gutter-border=1px solid ButtonBorder] - Gutter right border
|
|
76
|
+
* @cssprop [--rc-textarea-gutter-font-family=var(--rc-textarea-font-family, monospace)] - Gutter font family
|
|
77
|
+
* @cssprop [--rc-textarea-gutter-padding-inline-end=0.75em] - Space between gutter labels and text
|
|
53
78
|
*/
|
|
54
79
|
export declare class RCTextarea extends LitElement {
|
|
55
80
|
static styles: CSSResultGroup;
|
|
@@ -64,6 +89,8 @@ export declare class RCTextarea extends LitElement {
|
|
|
64
89
|
/** Show sequential line numbers in the gutter. Enables the gutter implicitly. */
|
|
65
90
|
lineNumbers: boolean;
|
|
66
91
|
/**
|
|
92
|
+
* Legacy alias for sparse (non-blank-line) list-style numbering.
|
|
93
|
+
*
|
|
67
94
|
* @deprecated Use a plugin with `LineDecoration.gutterContent` to implement
|
|
68
95
|
* sparse line numbering. This property will be removed before v1.0.
|
|
69
96
|
*/
|
|
@@ -84,6 +111,8 @@ export declare class RCTextarea extends LitElement {
|
|
|
84
111
|
/** Disable editing. The field renders as a styled read-only display. */
|
|
85
112
|
readOnly: boolean;
|
|
86
113
|
/**
|
|
114
|
+
* Accessible-name override, applied to the editor's `aria-label`.
|
|
115
|
+
*
|
|
87
116
|
* @deprecated Set `aria-label` on the slotted `<textarea>` instead, or
|
|
88
117
|
* associate a `<label>` element via its `for`/`id` pair. This property
|
|
89
118
|
* will be removed before v1.0.
|
|
@@ -119,39 +148,39 @@ export declare class RCTextarea extends LitElement {
|
|
|
119
148
|
private _defaultValue;
|
|
120
149
|
private _initialValueResolved;
|
|
121
150
|
private _valueSetByHost;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
151
|
+
protected _document: RCDocument | null;
|
|
152
|
+
protected _$textareaRef: WeakRef<HTMLTextAreaElement> | null;
|
|
153
|
+
protected readonly _textareaController: NativeChildController<HTMLTextAreaElement>;
|
|
125
154
|
/** Plugin-owned decorations */
|
|
126
155
|
protected _pluginDecorations: Map<string, Decoration>;
|
|
127
156
|
/** Pattern-generated decorations (rebuilt on each value change). */
|
|
128
|
-
|
|
157
|
+
protected _patternDecorations: Decoration[];
|
|
129
158
|
/** Imperative decorations (set directly via the `decorations` property) */
|
|
130
159
|
private _externalDecorations;
|
|
131
160
|
/** Registered patterns. */
|
|
132
|
-
|
|
161
|
+
protected _patterns: Map<string, TextPattern>;
|
|
133
162
|
protected _plugin: RCTextareaPlugin | null;
|
|
134
163
|
private _pluginProperty;
|
|
135
164
|
protected _pluginApi: RCTextareaPluginAPI | null;
|
|
136
165
|
/** Sequence counter for async plugin safety (discard stale results). */
|
|
137
|
-
|
|
166
|
+
protected _pluginSeq: number;
|
|
138
167
|
/** Stylesheets adopted into the shadow root by the active plugin. */
|
|
139
|
-
|
|
168
|
+
protected _pluginSheets: Set<CSSStyleSheet>;
|
|
140
169
|
protected _savedSelection: SavedSelection | null;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
170
|
+
protected _rafHandle: number | null;
|
|
171
|
+
protected _composing: boolean;
|
|
172
|
+
protected _isRendering: boolean;
|
|
144
173
|
/** The currently highlighted `.line` element (active line). */
|
|
145
|
-
|
|
174
|
+
protected _$activeLine: HTMLElement | null;
|
|
146
175
|
/** Callbacks registered via PluginAPI.onCursorMove(). */
|
|
147
|
-
|
|
148
|
-
|
|
176
|
+
protected _cursorCallbacks: Set<(start: number, end: number) => void>;
|
|
177
|
+
protected _docSelectionChangeHandler: () => void;
|
|
149
178
|
/** Synthetic undo/redo stack (DOM rebuilds invalidate native undo) */
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
179
|
+
protected _undoStack: UndoEntry[];
|
|
180
|
+
protected _undoIndex: number;
|
|
181
|
+
protected _resizeObserver: ResizeObserver | null;
|
|
153
182
|
/** Cached per-line gutter labels from the last render — reused by ResizeObserver. */
|
|
154
|
-
|
|
183
|
+
protected _gutterLabels: (string | null)[];
|
|
155
184
|
/**
|
|
156
185
|
* The current field value.
|
|
157
186
|
*
|
|
@@ -169,16 +198,17 @@ export declare class RCTextarea extends LitElement {
|
|
|
169
198
|
firstUpdated(): void;
|
|
170
199
|
updated(changed: Map<string, unknown>): void;
|
|
171
200
|
render(): import('lit').TemplateResult<1>;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
201
|
+
protected _onSlotChange(): void;
|
|
202
|
+
protected _setupTextarea($textarea: HTMLTextAreaElement | null, $previousTextarea?: HTMLTextAreaElement | null): void;
|
|
203
|
+
protected _onTextareaInvalid: () => void;
|
|
204
|
+
protected _bindEditorEvents($editor: HTMLElement): void;
|
|
205
|
+
protected _onInputEvent: () => void;
|
|
206
|
+
protected _onBeforeInput: (event: InputEvent) => void;
|
|
207
|
+
protected _onInput(): void;
|
|
208
|
+
protected _onSelectionChange: () => void;
|
|
209
|
+
protected _updateActiveLine(): void;
|
|
210
|
+
protected _updateActiveGutterCell(): void;
|
|
211
|
+
protected _onKeyDown: (e: KeyboardEvent) => void;
|
|
182
212
|
protected _insertText(text: string): void;
|
|
183
213
|
/**
|
|
184
214
|
* Wrap the current selection with `prefix` and `suffix`.
|
|
@@ -195,13 +225,13 @@ export declare class RCTextarea extends LitElement {
|
|
|
195
225
|
* When the selection is collapsed this is equivalent to `insertText`.
|
|
196
226
|
*/
|
|
197
227
|
replaceSelection(text: string): void;
|
|
198
|
-
|
|
228
|
+
protected _onPaste: (e: ClipboardEvent) => void;
|
|
199
229
|
/** Reset the undo/redo history. Call when the field receives entirely new content. */
|
|
200
230
|
clearHistory(): void;
|
|
201
231
|
protected _pushUndo(sel: SavedSelection | null): void;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
232
|
+
protected _undo(): void;
|
|
233
|
+
protected _redo(): void;
|
|
234
|
+
protected _applyUndoEntry(entry: UndoEntry): void;
|
|
205
235
|
/**
|
|
206
236
|
* Register and mount a plugin imperatively.
|
|
207
237
|
* Replaces any currently active plugin. Prefer the `plugin` property for
|
|
@@ -215,11 +245,16 @@ export declare class RCTextarea extends LitElement {
|
|
|
215
245
|
* `mount()` call. Each getter delegates to the component's live state so the
|
|
216
246
|
* API stays accurate across render frames without needing to be rebuilt.
|
|
217
247
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
248
|
+
protected _buildPluginApi(): RCTextareaPluginAPI;
|
|
249
|
+
protected _clearPluginSheets(): void;
|
|
220
250
|
/**
|
|
221
251
|
* Register a text pattern that generates decorations on every render pass.
|
|
222
252
|
* Returns the pattern ID, which can be passed to `removePattern` to unregister it.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* const id = editor.addPattern({ pattern: /TODO/g, className: 'highlight-todo' });
|
|
256
|
+
* // Later:
|
|
257
|
+
* editor.removePattern(id);
|
|
223
258
|
*/
|
|
224
259
|
addPattern(pattern: Omit<TextPattern, 'id'>): string;
|
|
225
260
|
/** Remove a previously registered pattern by the ID returned from `addPattern`. */
|
|
@@ -227,7 +262,7 @@ export declare class RCTextarea extends LitElement {
|
|
|
227
262
|
/** Remove all registered patterns and trigger a re-render. */
|
|
228
263
|
clearPatterns(): void;
|
|
229
264
|
protected _scheduleRender(): void;
|
|
230
|
-
|
|
265
|
+
protected _performRender(): Promise<void>;
|
|
231
266
|
/**
|
|
232
267
|
* Compute the label string for each gutter cell based on the current gutter
|
|
233
268
|
* mode (`lineNumbers`, `listNumbers` (deprecated), `gutter`) and any
|
|
@@ -237,7 +272,7 @@ export declare class RCTextarea extends LitElement {
|
|
|
237
272
|
* - `string` — the label to display
|
|
238
273
|
* - `null` — render an empty cell
|
|
239
274
|
*/
|
|
240
|
-
|
|
275
|
+
protected _computeGutterLabels(allDecorations: Decoration[], value?: string): (string | null)[];
|
|
241
276
|
/**
|
|
242
277
|
* Synchronize the pixel height of each gutter cell to match the
|
|
243
278
|
* corresponding `.line` element in the editor.
|
|
@@ -248,16 +283,17 @@ export declare class RCTextarea extends LitElement {
|
|
|
248
283
|
* Also copies the editor's computed `paddingTop`/`paddingBottom` to the
|
|
249
284
|
* gutter to compensate for browser UA overrides on contenteditable.
|
|
250
285
|
*/
|
|
251
|
-
|
|
286
|
+
protected _syncGutterHeights(): void;
|
|
252
287
|
/**
|
|
253
288
|
* Add, remove, or update `.gutter-cell` spans so their count and text
|
|
254
289
|
* content match `labels`. When `labels` is provided the cached
|
|
255
290
|
* `_gutterLabels` is updated first; otherwise the cached labels are reused
|
|
256
291
|
* (called by the `ResizeObserver` without a new render pass).
|
|
257
292
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
293
|
+
protected _syncGutter(labels?: (string | null)[]): void;
|
|
294
|
+
protected _syncLabel(): void;
|
|
295
|
+
protected _syncTypography($textarea: HTMLTextAreaElement): void;
|
|
261
296
|
protected _syncTextareaValue(fromUser?: boolean): void;
|
|
262
297
|
protected _dispatchChange(value: string): void;
|
|
263
298
|
}
|
|
299
|
+
export {};
|