@rcarls/rc-textarea 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/README.md +1311 -0
- package/dist/custom-elements.json +2103 -0
- package/dist/demo.css +85 -0
- package/dist/demo.js +40 -0
- package/dist/line-actions-controller-BsM6DJ0b.js +2334 -0
- package/dist/line-actions-controller-BsM6DJ0b.js.map +1 -0
- package/dist/rc-textarea-define.js +10 -0
- package/dist/rc-textarea-define.js.map +1 -0
- package/dist/rc-textarea.js +8 -0
- package/dist/rc-textarea.js.map +1 -0
- package/dist/types/packages/rc-textarea/src/blots.d.ts +39 -0
- package/dist/types/packages/rc-textarea/src/decoration.d.ts +65 -0
- package/dist/types/packages/rc-textarea/src/decoration.test.d.ts +1 -0
- package/dist/types/packages/rc-textarea/src/define.d.ts +1 -0
- package/dist/types/packages/rc-textarea/src/document.d.ts +19 -0
- package/dist/types/packages/rc-textarea/src/index.d.ts +7 -0
- package/dist/types/packages/rc-textarea/src/line-actions-controller.d.ts +91 -0
- package/dist/types/packages/rc-textarea/src/line-decorator.d.ts +57 -0
- package/dist/types/packages/rc-textarea/src/line-decorator.test.d.ts +1 -0
- package/dist/types/packages/rc-textarea/src/pattern-matcher.d.ts +23 -0
- package/dist/types/packages/rc-textarea/src/pattern-matcher.test.d.ts +1 -0
- package/dist/types/packages/rc-textarea/src/rc-textarea.d.ts +194 -0
- package/dist/types/packages/rc-textarea/src/rc-textarea.styles.d.ts +1 -0
- package/dist/types/packages/rc-textarea/src/rc-textarea.test.d.ts +0 -0
- package/dist/types/packages/rc-textarea/src/selection.d.ts +39 -0
- package/dist/types/packages/rc-textarea/src/test-helpers.d.ts +18 -0
- package/dist/types/packages/rc-textarea/src/types.d.ts +394 -0
- package/package.json +68 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A styled inline range over characters [from, to).
|
|
3
|
+
* Rich formatting properties (bold, italic, color, etc.) are rendered as
|
|
4
|
+
* inline styles on the blot span; `className` adds an extra CSS class.
|
|
5
|
+
*/
|
|
6
|
+
export interface MarkDecoration {
|
|
7
|
+
id: string;
|
|
8
|
+
type: 'mark';
|
|
9
|
+
/** Inclusive start offset (0-based character index into plain text). */
|
|
10
|
+
from: number;
|
|
11
|
+
/** Exclusive end offset. */
|
|
12
|
+
to: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
bold?: boolean;
|
|
15
|
+
italic?: boolean;
|
|
16
|
+
color?: string;
|
|
17
|
+
background?: string;
|
|
18
|
+
underline?: 'solid' | 'wavy' | 'dotted' | 'dashed';
|
|
19
|
+
underlineColor?: string;
|
|
20
|
+
attributes?: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A decoration applied to an entire logical line.
|
|
24
|
+
* Adds a CSS class and/or data attributes to the line div, and optionally
|
|
25
|
+
* appends an error-lens style annotation message at the end of the line.
|
|
26
|
+
*/
|
|
27
|
+
export interface LineDecoration {
|
|
28
|
+
id: string;
|
|
29
|
+
type: 'line';
|
|
30
|
+
/** 1-based logical line number. */
|
|
31
|
+
line: number;
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Error-lens style annotation text shown at the end of the line.
|
|
35
|
+
* Rendered via `::after` pseudo-element on the line div (not a real DOM node),
|
|
36
|
+
* so it is completely excluded from selection and clipboard operations.
|
|
37
|
+
*/
|
|
38
|
+
message?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Space-separated CSS class name(s) applied to the `data-message-class` attribute
|
|
41
|
+
* on the line div. Use attribute selectors in CSS to style the message:
|
|
42
|
+
*
|
|
43
|
+
* ```css
|
|
44
|
+
* .v2-line[data-message-class~="error"][data-message]::after { color: red; }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
messageClassName?: string;
|
|
48
|
+
attributes?: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Override the built-in gutter cell text for this line.
|
|
51
|
+
* - `string` — custom label (e.g. `"!"`, `"▶"`)
|
|
52
|
+
* - `null` — force empty cell (suppress built-in content)
|
|
53
|
+
* - `undefined` — use the built-in mode default (`line-numbers`, `list-numbers`, etc.)
|
|
54
|
+
*/
|
|
55
|
+
gutterContent?: string | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A non-editable DOM element inserted at a character offset.
|
|
59
|
+
* Widgets are purely visual and do not appear in the plain text value.
|
|
60
|
+
*/
|
|
61
|
+
export interface WidgetDecoration {
|
|
62
|
+
id: string;
|
|
63
|
+
type: 'widget';
|
|
64
|
+
/** Character offset. Widget is placed before (or after) the character at this position. */
|
|
65
|
+
offset: number;
|
|
66
|
+
/** Factory called each render cycle. Must return a new element each time. */
|
|
67
|
+
create(): HTMLElement;
|
|
68
|
+
/** Whether to place the widget before or after the character at `offset`. Default: 'before'. */
|
|
69
|
+
side?: 'before' | 'after';
|
|
70
|
+
}
|
|
71
|
+
export type Decoration = MarkDecoration | LineDecoration | WidgetDecoration;
|
|
72
|
+
export type DecorationInput = Omit<MarkDecoration, 'id'> | Omit<LineDecoration, 'id'> | Omit<WidgetDecoration, 'id'>;
|
|
73
|
+
/**
|
|
74
|
+
* A semantic token produced by an external tokenizer (lezer, tree-sitter, shiki, etc.).
|
|
75
|
+
* Offsets are absolute character indices into the plain-text value — the same coordinate
|
|
76
|
+
* space as `MarkDecoration.from` / `MarkDecoration.to`.
|
|
77
|
+
*
|
|
78
|
+
* Use `RCTextareaPluginAPI.decorationsFromTokens()` to convert a token array into
|
|
79
|
+
* `DecorationInput[]` using a theme map.
|
|
80
|
+
*/
|
|
81
|
+
export interface Token {
|
|
82
|
+
/** Inclusive start offset (0-based character index into plain text). */
|
|
83
|
+
from: number;
|
|
84
|
+
/** Exclusive end offset. */
|
|
85
|
+
to: number;
|
|
86
|
+
/** Semantic token type, e.g. `"keyword"`, `"string"`, `"comment"`. */
|
|
87
|
+
type: string;
|
|
88
|
+
/** Optional TextMate / VS Code scope list (e.g. `["keyword.control", "source.js"]`). */
|
|
89
|
+
scopes?: string[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Contextual API available inside plugin lifecycle callbacks.
|
|
93
|
+
*
|
|
94
|
+
* Plugins own the decoration state — keep a reference to `api` from `mount()`
|
|
95
|
+
* to set decorations from outside the plugin lifecycle:
|
|
96
|
+
*
|
|
97
|
+
* ```ts
|
|
98
|
+
* let api: RCTextareaPluginAPI;
|
|
99
|
+
* editor.usePlugin({
|
|
100
|
+
* mount(a) { api = a; },
|
|
101
|
+
* update() {},
|
|
102
|
+
* });
|
|
103
|
+
* // later:
|
|
104
|
+
* api.setDecorations([...]);
|
|
105
|
+
* api.scheduleUpdate();
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export interface RCTextareaPluginAPI {
|
|
109
|
+
/** The host rc-textarea element. */
|
|
110
|
+
readonly host: HTMLElement;
|
|
111
|
+
readonly value: string;
|
|
112
|
+
/** Normalized selection start offset (always ≤ selectionEnd). */
|
|
113
|
+
readonly selectionStart: number;
|
|
114
|
+
/** Normalized selection end offset (always ≥ selectionStart). Equals selectionStart when the cursor is collapsed. */
|
|
115
|
+
readonly selectionEnd: number;
|
|
116
|
+
/**
|
|
117
|
+
* Returns the bounding rect of the cursor (caret) in viewport coordinates,
|
|
118
|
+
* or `null` if the editor is not focused or the cursor is outside the editor.
|
|
119
|
+
* Useful for anchoring autocomplete popups or hover tooltips to the cursor.
|
|
120
|
+
*/
|
|
121
|
+
getCursorRect(): DOMRect | null;
|
|
122
|
+
/**
|
|
123
|
+
* Returns the word at the current cursor position, or `null` if the cursor is
|
|
124
|
+
* not on a word character (`\w` — alphanumeric + underscore).
|
|
125
|
+
*/
|
|
126
|
+
getWordAtCursor(): {
|
|
127
|
+
word: string;
|
|
128
|
+
from: number;
|
|
129
|
+
to: number;
|
|
130
|
+
} | null;
|
|
131
|
+
/**
|
|
132
|
+
* Subscribe to cursor/selection changes. The callback fires on every cursor
|
|
133
|
+
* move (arrow keys, mouse clicks, selection changes) while the editor is focused.
|
|
134
|
+
* Returns an unsubscribe function — call it in your plugin's `destroy()`.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* let unsub: () => void;
|
|
139
|
+
* editor.usePlugin({
|
|
140
|
+
* mount(api) {
|
|
141
|
+
* unsub = api.onCursorMove((start, end) => {
|
|
142
|
+
* const word = api.getWordAtCursor();
|
|
143
|
+
* if (word) showTooltip(word, api.getCursorRect());
|
|
144
|
+
* });
|
|
145
|
+
* },
|
|
146
|
+
* destroy() { unsub?.(); },
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
onCursorMove(callback: (selectionStart: number, selectionEnd: number) => void): () => void;
|
|
151
|
+
addDecoration(d: DecorationInput): string;
|
|
152
|
+
removeDecoration(id: string): void;
|
|
153
|
+
clearDecorations(): void;
|
|
154
|
+
setDecorations(decorations: DecorationInput[]): void;
|
|
155
|
+
/** Returns the decorations this plugin has currently set, in insertion order. */
|
|
156
|
+
getDecorations(): readonly Decoration[];
|
|
157
|
+
/** Trigger a render pass outside of normal text input events. */
|
|
158
|
+
scheduleUpdate(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Inject a stylesheet into the component's shadow root via `adoptedStyleSheets`.
|
|
161
|
+
*
|
|
162
|
+
* Pass a `CSSStyleSheet` object to share an already-constructed sheet (zero
|
|
163
|
+
* extra parsing cost), or a raw CSS text string to compile and adopt a new one.
|
|
164
|
+
* Returns the adopted `CSSStyleSheet` so it can be passed to `removeStyleSheet`
|
|
165
|
+
* if explicit removal is needed before the plugin is unmounted.
|
|
166
|
+
*
|
|
167
|
+
* Adopted sheets are **automatically removed** when the plugin is unmounted
|
|
168
|
+
* (via `removePlugin()` or `usePlugin()` with a replacement).
|
|
169
|
+
*
|
|
170
|
+
* @example CSS text string
|
|
171
|
+
* ```ts
|
|
172
|
+
* editor.usePlugin({
|
|
173
|
+
* mount(api) {
|
|
174
|
+
* api.adoptStyleSheet(`
|
|
175
|
+
* .hljs-keyword { color: #cba6f7; }
|
|
176
|
+
* .hljs-string { color: #a6e3a1; }
|
|
177
|
+
* `);
|
|
178
|
+
* },
|
|
179
|
+
* });
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @example Shared CSSStyleSheet (constructed once, adopted by many)
|
|
183
|
+
* ```ts
|
|
184
|
+
* const sharedSheet = new CSSStyleSheet();
|
|
185
|
+
* sharedSheet.replaceSync('.hljs-keyword { color: #cba6f7; }');
|
|
186
|
+
*
|
|
187
|
+
* editor.usePlugin({
|
|
188
|
+
* mount(api) { api.adoptStyleSheet(sharedSheet); },
|
|
189
|
+
* });
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
adoptStyleSheet(sheetOrCssText: CSSStyleSheet | string): CSSStyleSheet;
|
|
193
|
+
/**
|
|
194
|
+
* Remove a previously adopted stylesheet from the shadow root.
|
|
195
|
+
* The sheet does not need to have been adopted via `adoptStyleSheet` —
|
|
196
|
+
* any sheet already present in `adoptedStyleSheets` may be removed.
|
|
197
|
+
*/
|
|
198
|
+
removeStyleSheet(sheet: CSSStyleSheet): void;
|
|
199
|
+
/**
|
|
200
|
+
* Compatibility bridge for highlight.js / prism.js.
|
|
201
|
+
*
|
|
202
|
+
* Parses an HTML string of `<span class="...">text</span>` structures
|
|
203
|
+
* (as returned by `hljs.highlight()` or `Prism.highlight()`) and converts
|
|
204
|
+
* them into `MarkDecoration` objects covering the corresponding character
|
|
205
|
+
* ranges of the plain text value.
|
|
206
|
+
*
|
|
207
|
+
* ```ts
|
|
208
|
+
* editor.usePlugin({
|
|
209
|
+
* highlight(value, api) {
|
|
210
|
+
* const html = hljs.highlight(value, { language: 'js' }).value;
|
|
211
|
+
* api.setDecorations(api.decorationsFromHtml(html));
|
|
212
|
+
* },
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
decorationsFromHtml(html: string): Omit<MarkDecoration, 'id'>[];
|
|
217
|
+
/**
|
|
218
|
+
* Convert a flat token array from an external tokenizer (lezer, tree-sitter, shiki, moo, etc.)
|
|
219
|
+
* into `DecorationInput` objects using a theme map keyed by `token.type`.
|
|
220
|
+
*
|
|
221
|
+
* Token offsets must be **absolute** character indices into the plain-text value
|
|
222
|
+
* (same coordinate space as `MarkDecoration.from` / `MarkDecoration.to`).
|
|
223
|
+
* Types not present in `themeMap` are silently ignored.
|
|
224
|
+
*
|
|
225
|
+
* ```ts
|
|
226
|
+
* editor.usePlugin({
|
|
227
|
+
* update(value, api) {
|
|
228
|
+
* const tokens = myTokenizer.tokenize(value);
|
|
229
|
+
* api.setDecorations(api.decorationsFromTokens(tokens, {
|
|
230
|
+
* keyword: { bold: true, color: 'var(--color-keyword)' },
|
|
231
|
+
* string: { color: 'var(--color-string)' },
|
|
232
|
+
* comment: { italic: true, color: 'var(--color-comment)' },
|
|
233
|
+
* }));
|
|
234
|
+
* },
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
decorationsFromTokens(tokens: Token[], themeMap: Record<string, Omit<MarkDecoration, 'id' | 'type' | 'from' | 'to'>>): Omit<MarkDecoration, 'id'>[];
|
|
239
|
+
/**
|
|
240
|
+
* Insert `text` at the current cursor position, replacing any active selection.
|
|
241
|
+
* Equivalent to typing the text with the keyboard.
|
|
242
|
+
*/
|
|
243
|
+
insertText(text: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Wrap the current selection with `prefix` and `suffix`.
|
|
246
|
+
* No-op when the selection is collapsed (no text selected).
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* api.wrapSelection('**', '**'); // bold
|
|
250
|
+
* api.wrapSelection('`', '`'); // inline code
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
wrapSelection(prefix: string, suffix: string): void;
|
|
254
|
+
/**
|
|
255
|
+
* Replace the current selection with `text`.
|
|
256
|
+
* When the selection is collapsed this is equivalent to `insertText`.
|
|
257
|
+
*/
|
|
258
|
+
replaceSelection(text: string): void;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Plugin interface for rc-textarea.
|
|
262
|
+
*
|
|
263
|
+
* At least one of `update` or `highlight` must be provided.
|
|
264
|
+
*
|
|
265
|
+
* @example Syntax highlighting with highlight.js
|
|
266
|
+
* ```ts
|
|
267
|
+
* import hljs from 'highlight.js/lib/core';
|
|
268
|
+
* import javascript from 'highlight.js/lib/languages/javascript';
|
|
269
|
+
* hljs.registerLanguage('javascript', javascript);
|
|
270
|
+
*
|
|
271
|
+
* editor.usePlugin({
|
|
272
|
+
* highlight(value, api) {
|
|
273
|
+
* const html = hljs.highlight(value, { language: 'javascript' }).value;
|
|
274
|
+
* api.setDecorations(api.decorationsFromHtml(html));
|
|
275
|
+
* },
|
|
276
|
+
* });
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @example Async highlighter (WASM / web worker)
|
|
280
|
+
* ```ts
|
|
281
|
+
* editor.usePlugin({
|
|
282
|
+
* async update(value, api) {
|
|
283
|
+
* const decs = await myParser.decorate(value);
|
|
284
|
+
* api.setDecorations(decs);
|
|
285
|
+
* },
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
export interface RCTextareaPlugin {
|
|
290
|
+
/** Called when the plugin is registered. Store `api` here for external use. */
|
|
291
|
+
mount?(api: RCTextareaPluginAPI): void;
|
|
292
|
+
/** Called when the plugin is replaced or the element disconnects. */
|
|
293
|
+
destroy?(): void;
|
|
294
|
+
/**
|
|
295
|
+
* Display-layer value transform — called before `update`/`highlight` in
|
|
296
|
+
* read-only mode. Return a non-null string to substitute it as the rendered
|
|
297
|
+
* text passed to all subsequent hooks and to the document builder.
|
|
298
|
+
* The underlying `element.value` is **never** modified; only the display
|
|
299
|
+
* layer sees the transformed text.
|
|
300
|
+
* Return `null` or `void` to leave the value unchanged.
|
|
301
|
+
*/
|
|
302
|
+
transform?(value: string, api: RCTextareaPluginAPI): string | null | void;
|
|
303
|
+
/**
|
|
304
|
+
* Imperative decoration API — called on each value change.
|
|
305
|
+
* Use `api.setDecorations()` to apply decorations.
|
|
306
|
+
*/
|
|
307
|
+
update?(value: string, api: RCTextareaPluginAPI): void | Promise<void>;
|
|
308
|
+
/**
|
|
309
|
+
* HTML-based compat — called on each value change.
|
|
310
|
+
* Return an HTML string (e.g. from hljs/prism); it will be parsed via
|
|
311
|
+
* `api.decorationsFromHtml()` and applied as mark decorations.
|
|
312
|
+
* Return `null` or `void` to skip.
|
|
313
|
+
*/
|
|
314
|
+
highlight?(value: string, api: RCTextareaPluginAPI): string | null | void | Promise<string | null | void>;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The subset of `MarkDecoration` properties used for styling.
|
|
318
|
+
* Used in `TextPattern.captureGroups` to assign a style to each named capture group.
|
|
319
|
+
*/
|
|
320
|
+
export type MarkDecorationStyle = Pick<MarkDecoration, 'className' | 'bold' | 'italic' | 'color' | 'background' | 'underline' | 'underlineColor' | 'attributes'>;
|
|
321
|
+
export interface TextPattern {
|
|
322
|
+
id: string;
|
|
323
|
+
pattern: RegExp;
|
|
324
|
+
className?: string;
|
|
325
|
+
bold?: boolean;
|
|
326
|
+
italic?: boolean;
|
|
327
|
+
color?: string;
|
|
328
|
+
background?: string;
|
|
329
|
+
underline?: 'solid' | 'wavy' | 'dotted' | 'dashed';
|
|
330
|
+
underlineColor?: string;
|
|
331
|
+
attributes?: Record<string, string>;
|
|
332
|
+
/**
|
|
333
|
+
* Factory called for each regex match. Return a partial LineDecoration
|
|
334
|
+
* (message, messageClassName, className, attributes) to add an error-lens
|
|
335
|
+
* annotation on the matched line, or `null` to skip.
|
|
336
|
+
*/
|
|
337
|
+
createLineDecoration?: (match: RegExpMatchArray) => Omit<LineDecoration, 'id' | 'type' | 'line'> | null;
|
|
338
|
+
/**
|
|
339
|
+
* Per-named-capture-group decoration styles. When provided, one
|
|
340
|
+
* `MarkDecoration` is emitted per captured group (unmatched optional groups
|
|
341
|
+
* are skipped) instead of one decoration for the whole match.
|
|
342
|
+
*
|
|
343
|
+
* The `pattern` must use named capture groups (`(?<name>...)`). The `d`
|
|
344
|
+
* flag (indices) is added automatically when `captureGroups` is set.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* {
|
|
349
|
+
* id: 'kv',
|
|
350
|
+
* pattern: /^(?<key>\w+):\s*(?<value>.+)$/gm,
|
|
351
|
+
* captureGroups: {
|
|
352
|
+
* key: { bold: true, color: '#c792ea' },
|
|
353
|
+
* value: { color: '#c3e88d' },
|
|
354
|
+
* },
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
358
|
+
captureGroups?: Record<string, MarkDecorationStyle>;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* A simplified plugin variant for per-line decoration.
|
|
362
|
+
*
|
|
363
|
+
* Return mark/line decorations with offsets **relative to the start of the
|
|
364
|
+
* line** — `createLineDecoratorPlugin()` converts them to absolute document
|
|
365
|
+
* offsets automatically, so no `lineStart` bookkeeping is needed.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* const myDecorator: LineDecoratorPlugin = {
|
|
370
|
+
* styles: '.kw { font-weight: bold; color: #cba6f7; }',
|
|
371
|
+
* decorateLine(line) {
|
|
372
|
+
* const results: Omit<MarkDecoration | LineDecoration, 'id'>[] = [];
|
|
373
|
+
* const m = /\bfunction\b/.exec(line);
|
|
374
|
+
* if (m) results.push({ type: 'mark', from: m.index, to: m.index + m[0].length, className: 'kw' });
|
|
375
|
+
* return results;
|
|
376
|
+
* },
|
|
377
|
+
* };
|
|
378
|
+
* editor.usePlugin(createLineDecoratorPlugin(myDecorator));
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
export interface LineDecoratorPlugin {
|
|
382
|
+
/**
|
|
383
|
+
* Called for each line of text (including empty lines, which can be skipped
|
|
384
|
+
* by returning `[]`). `lineIndex` is 0-based.
|
|
385
|
+
*
|
|
386
|
+
* Offsets in returned `MarkDecoration` objects must be **line-relative**
|
|
387
|
+
* (0 = start of the line). `LineDecoration.line` should be 1-based as usual.
|
|
388
|
+
*/
|
|
389
|
+
decorateLine(line: string, lineIndex: number): (Omit<MarkDecoration, 'id'> | Omit<LineDecoration, 'id'>)[];
|
|
390
|
+
/** CSS text to inject into the component's shadow root once on mount. */
|
|
391
|
+
styles?: string;
|
|
392
|
+
}
|
|
393
|
+
/** Generate a unique decoration ID (UUID v4). */
|
|
394
|
+
export declare function generateId(): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rcarls/rc-textarea",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"description": "Headless enhanced textarea web component built with Lit",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/richardcarls/rc-webcomponents.git",
|
|
11
|
+
"directory": "packages/rc-textarea"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/richardcarls/rc-webcomponents#readme",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"module": "./dist/rc-textarea.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/types/packages/rc-textarea/src/index.d.ts",
|
|
24
|
+
"default": "./dist/rc-textarea.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./define": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/types/packages/rc-textarea/src/define.d.ts",
|
|
30
|
+
"default": "./dist/rc-textarea-define.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/types/packages/rc-textarea/src/index.d.ts",
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"./dist/rc-textarea-define.js"
|
|
37
|
+
],
|
|
38
|
+
"customElements": "dist/custom-elements.json",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"dev": "vite",
|
|
41
|
+
"build": "tsc && vite build && cem analyze",
|
|
42
|
+
"cem:analyze": "cem analyze",
|
|
43
|
+
"preview": "vite preview",
|
|
44
|
+
"test:browser": "vitest",
|
|
45
|
+
"test:browser:chrome": "vitest --project=chromium",
|
|
46
|
+
"test:browser:firefox": "vitest --project=firefox"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"parchment": "^3.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
53
|
+
"@guanghechen/rollup-plugin-copy": "^6.0.9",
|
|
54
|
+
"@types/node": "^25.6.0",
|
|
55
|
+
"@vitest/browser-playwright": "4.1.5",
|
|
56
|
+
"lit": "^3.0.0",
|
|
57
|
+
"playwright": "^1.56.0",
|
|
58
|
+
"rollup": "^4.60.2",
|
|
59
|
+
"typescript": "~5.9.3",
|
|
60
|
+
"vite": "^7.1.7",
|
|
61
|
+
"vite-plugin-dts": "^4.5.4",
|
|
62
|
+
"vitest": "^4.0.6",
|
|
63
|
+
"vitest-browser-lit": "^1.0.1"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"lit": "^3.0.0"
|
|
67
|
+
}
|
|
68
|
+
}
|