@rcarls/rc-textarea 0.0.0-next-20260921045401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,157 @@
1
+ # @rcarls/rc-textarea
2
+
3
+ ## 0.0.0-next-20260921045401
4
+
5
+ ### Minor Changes
6
+
7
+ - 079e025: Standardize component styling contracts for the breaking 0.7 release.
8
+
9
+ BREAKING CHANGE: Rename the Markdown editor's `--rme-*` properties to
10
+ `--rc-markdown-editor-*`, `--rc-app-bar-background` to `--rc-app-bar-bg`,
11
+ `--rc-textarea-radius` to `--rc-textarea-border-radius`, the transfer-list
12
+ `--rc-transfer-list-panel-*` properties to `--rc-transfer-list-listbox-*`,
13
+ `--rc-chip-group-webkit-scrollbar-display` to
14
+ `--rc-chip-group-scrollbar-display`, and `--rc-text` to `--rc-field-text`.
15
+ Compatibility aliases are intentionally not provided.
16
+
17
+ BREAKING CHANGE: Replace `--rc-select-chip-padding-inline` and
18
+ `--rc-combobox-chip-padding-inline` with explicit `*-padding-inline-start` and
19
+ `*-padding-inline-end` tokens. Generated removable chips now reserve the full
20
+ remove target and its edge offset, so their indicator cannot overlap label text.
21
+
22
+ Add canonical app-bar elevation, transfer-list listbox radius, and textarea
23
+ line-action tokens. Add logical `rc-chip` inline-padding properties so themes
24
+ can implement Material's icon-aware spacing without overriding authored child
25
+ styles. Make `rc-field` consume the shared semantic token layer,
26
+ and place the `rc-chip` and `rc-search-bar` light-DOM structural styles in the
27
+ `rc-base` cascade layer so normal consumer rules override them.
28
+
29
+ Prevent decorative, `aria-hidden` trailing list content from intercepting a
30
+ whole-row action target, and keep segmented-list item geometry from leaking
31
+ into nested standard lists.
32
+
33
+ Remove unused Material navigation-rail toggle tokens and obsolete list-item
34
+ theme tokens. Register the segmented-button private theme seam and enforce
35
+ token ownership, documentation, removed-name, selector-budget, and cascade
36
+ layer contracts through the component architecture audit.
37
+
38
+ ### Patch Changes
39
+
40
+ - 4617b45: Keep active-line and cursor tracking consistent when browsers expose a shadow-DOM selection
41
+ through different selection APIs.
42
+ - Updated dependencies [50d5610]
43
+ - Updated dependencies [4341311]
44
+ - @rcarls/rc-common@0.0.0-next-20260921045401
45
+
46
+ ## 0.6.0
47
+
48
+ ### Patch Changes
49
+
50
+ - 985067e: Allow `rc-textarea` to shrink below its intrinsic content width so `word-wrap`
51
+ wraps long, unbroken lines inside narrow grid and flex layouts instead of
52
+ forcing the consumer layout to overflow.
53
+ - 57370e4: Align component metadata, aggregate framework typings, development-time native-child
54
+ validation, controlled menu state, package declarations, and public documentation before the
55
+ next release.
56
+ - Updated dependencies [6683eb9]
57
+ - Updated dependencies [ee7ba6c]
58
+ - Updated dependencies [30eb232]
59
+ - @rcarls/rc-common@0.6.0
60
+
61
+ ## 0.5.0
62
+
63
+ ### Minor Changes
64
+
65
+ - 689340c: Remove pre-1.0 deprecated APIs: the boolean `keyNavigation` option, `rc-disclosure.fragment`,
66
+ `rc-textarea.listNumbers`, `rc-textarea.label`, and `decorationsFromHtml`.
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [4ae2ef0]
71
+ - Updated dependencies [689340c]
72
+ - @rcarls/rc-common@0.5.0
73
+
74
+ ## 0.4.2
75
+
76
+ ### Patch Changes
77
+
78
+ - @rcarls/rc-common@0.4.2
79
+
80
+ ## 0.4.1
81
+
82
+ ### Patch Changes
83
+
84
+ - @rcarls/rc-common@0.4.1
85
+
86
+ ## 0.4.0
87
+
88
+ ### Patch Changes
89
+
90
+ - 46810f7: Render line breaks immediately when Enter is pressed at the end of an editable line, including virtual-keyboard `beforeinput` events.
91
+ - 32b1dc4: Allow gutter typography to be themed independently with `--rc-textarea-gutter-font-family`.
92
+ - c50d9e2: Document the `root`, `gutter`, `gutter-cells`, `editor-area`, and `editor` CSS
93
+ parts, all public attributes, and the `--rc-textarea-gutter-padding-inline-end`
94
+ custom property in the generated API reference.
95
+ - be4f0ae: Fix `defaultValue` so its HTML attribute is `default-value`, matching every
96
+ other `default-*` attribute in the library. It previously had no kebab-case
97
+ mapping, so `<rc-textarea default-value="...">` was silently ignored.
98
+ - c40a1be: Add theme-neutral fast, default, and slow effects and spatial motion token
99
+ pairs. Expose bottom-sheet settle easing through
100
+ `--rc-bottom-sheet-snap-easing` and map sheet settling to the Material spatial
101
+ motion scheme.
102
+
103
+ Give direct-child bottom-sheet handles a full-width 48px interaction target
104
+ while preserving the 32 by 4 pixel visual indicator. Replace rectangular
105
+ mobile browser tap highlights on chips with themeable, shape-clipped state
106
+ layers. Keep bottom-sheet snap targets docked to the block-end edge when CSS
107
+ minimum or maximum sizing constrains their requested heights.
108
+
109
+ Mount declaratively assigned textarea plugins at connection time and remount
110
+ them after reconnection, preserving plugin effects and adopted styles in
111
+ framework render lifecycles.
112
+
113
+ - aecba33: Fix cursor position tracking in WebKit, where a plain Range from `getRangeAt()` does not
114
+ resolve inside `rc-textarea`'s open shadow root. This made every Enter press and
115
+ virtual-keyboard paragraph insert land at the start of the value instead of the cursor. Fall
116
+ back to `Selection.getComposedRanges()` when Chrome's non-standard `shadowRoot.getSelection()`
117
+ isn't available.
118
+ - Updated dependencies [e57277f]
119
+ - Updated dependencies [ccca8e2]
120
+ - Updated dependencies [037b1b3]
121
+ - @rcarls/rc-common@0.4.0
122
+
123
+ ## 0.3.2
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [88b4086]
128
+ - @rcarls/rc-common@0.3.2
129
+
130
+ ## 0.3.1
131
+
132
+ ### Patch Changes
133
+
134
+ - 808afe4: ### Fixed
135
+
136
+ - Fix regression where the visible editor did not reflect `value` and `defaultValue` on first mount.
137
+ - @rcarls/rc-common@0.3.1
138
+
139
+ ## 0.3.0
140
+
141
+ ### Added
142
+
143
+ - Add `parseDecorationsFromHtml` as the canonical HTML decoration helper.
144
+ - Add `rc-textarea` to `HTMLElementTagNameMap`.
145
+
146
+ ### Changed
147
+
148
+ - Deprecate `decorationsFromHtml` in favor of `parseDecorationsFromHtml`.
149
+ - Rename internal Parchment blot classes and document helpers from `V2` to `RC`.
150
+ - Expand public JSDoc across the component and plugin APIs.
151
+ - Update package metadata, README intro, and docs links.
152
+
153
+ ### Dependencies
154
+
155
+ - Sync internal dependencies to 0.3.0.
156
+
157
+ ## 0.2.0
package/README.md ADDED
@@ -0,0 +1,317 @@
1
+ # rc-textarea
2
+
3
+ Textarea wrapper with line decorations, gutter rendering, inline widgets, and plugin hooks.
4
+
5
+ Docs: [https://richardcarls.github.io/rc-webcomponents/components/rc-textarea](https://richardcarls.github.io/rc-webcomponents/components/rc-textarea).
6
+
7
+ Made with [Lit](https://lit.dev) and [Parchment](https://github.com/quilljs/parchment).
8
+
9
+ ---
10
+
11
+ ## Feature Highlights
12
+
13
+ - **Mixed inline formatting** - bold, italic, color, background, and underline
14
+ - **Imperative APIs** that behave well with reactive frameworks
15
+ - **Error-lens style line annotations** that stay separate from text content
16
+ - **Inline widgets** - color swatches, icons, tooltips or quick action buttons are possible
17
+ - **Simple Pattern API** that auto-decorates text matching regular expressions
18
+ - **Plugin API** - imperative decoration control + highlight.js / prism.js HTML compatibility bridge
19
+ - **Line numbers, word wrap, auto-grow** - declarative features for common use cases
20
+ - **Progressive enhancement** - wraps a native `<textarea>` for form submission, label association
21
+ - **Undo/redo** - durable internally tracked undo stack
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @rcarls/rc-textarea
29
+ ```
30
+
31
+ ```bash
32
+ yarn add @rcarls/rc-textarea
33
+ ```
34
+
35
+ Import the define entry to register `<rc-textarea>`:
36
+
37
+ ```ts
38
+ import '@rcarls/rc-textarea/define';
39
+ ```
40
+
41
+ Import public types when you need typed access:
42
+
43
+ ```ts
44
+ import type { RCTextarea, RCTextareaPlugin } from '@rcarls/rc-textarea';
45
+ ```
46
+
47
+ ## Basic Usage
48
+
49
+ Slot a native `<textarea>` as the direct child. It is hidden from view and used
50
+ only for form wiring.
51
+
52
+ ```html
53
+ <label for="message">Message</label>
54
+
55
+ <rc-textarea line-numbers word-wrap auto-grow>
56
+ <textarea id="message" name="message" rows="10" placeholder="Start typing..."></textarea>
57
+ </rc-textarea>
58
+ ```
59
+
60
+ Use the `value` property for controlled updates, `defaultValue` for an initial uncontrolled
61
+ value, and `rc-textarea-change` for user-originated changes.
62
+
63
+ ```ts
64
+ const editor = document.querySelector('rc-textarea');
65
+
66
+ editor.value = 'Programmatic updates are silent.';
67
+
68
+ editor.addEventListener('rc-textarea-change', (event) => {
69
+ console.log(event.detail.value);
70
+ });
71
+ ```
72
+
73
+ When the user edits, the slotted textarea is kept in sync and dispatches a native bubbling
74
+ `input` event. Submitting a form reads the textarea's plain-text value normally.
75
+
76
+ ```html
77
+ <form>
78
+ <rc-textarea>
79
+ <textarea name="body" required maxlength="5000"></textarea>
80
+ </rc-textarea>
81
+
82
+ <button type="submit">Send</button>
83
+ </form>
84
+ ```
85
+
86
+ ## Common Options
87
+
88
+ | Attribute | Property | Description |
89
+ | -------------- | ------------- | ----------------------------------------------------------------------------------- |
90
+ | `line-numbers` | `lineNumbers` | Show sequential line numbers in the gutter. |
91
+ | `gutter` | `gutter` | Show an empty gutter that plugins can populate with `LineDecoration.gutterContent`. |
92
+ | `word-wrap` | `wordWrap` | Wrap long lines instead of scrolling horizontally. |
93
+ | `auto-grow` | `autoGrow` | Let the field grow vertically with content. |
94
+ | `read-only` | `readOnly` | Render selectable, non-editable content. |
95
+
96
+ Use a plugin with `LineDecoration.gutterContent` for sparse numbering. Put accessible names on
97
+ the slotted textarea with `aria-label` or a real `<label for="...">`.
98
+
99
+ The main JavaScript-only properties are:
100
+
101
+ | Property | Type | Description |
102
+ | --------------------------------- | -------------------------- | ------------------------------------------------------------------------- |
103
+ | `value` | `string` | Current plain-text value. Host writes are silent. |
104
+ | `defaultValue` | `string \| undefined` | Initial uncontrolled value, used before `value` or textarea content wins. |
105
+ | `plugin` | `RCTextareaPlugin \| null` | Declarative plugin hook for reactive frameworks. |
106
+ | `decorations` | `DecorationInput[]` | External decoration layer merged with plugin and pattern decorations. |
107
+ | `selectionStart` / `selectionEnd` | `number` | Current plain-text selection offsets. |
108
+
109
+ ## Events
110
+
111
+ All public events bubble and are composed.
112
+
113
+ | Event | Detail | Fires when |
114
+ | -------------------- | -------------------------------------------------- | -------------------------------------------------- |
115
+ | `rc-textarea-change` | `{ value: string }` | User editing changes the plain-text value. |
116
+ | `rc-textarea-focus` | none | The editor receives focus. |
117
+ | `rc-textarea-blur` | none | The editor loses focus. |
118
+ | `rc-textarea-select` | `{ selectionStart: number, selectionEnd: number }` | The selection changes while the editor is focused. |
119
+
120
+ ## Pattern Highlights
121
+
122
+ Use `addPattern()` for lightweight regex decoration without writing a plugin.
123
+
124
+ ```ts
125
+ const todoPatternId = editor.addPattern({
126
+ pattern: /\bTODO\b/g,
127
+ bold: true,
128
+ color: 'var(--editor-todo-color)',
129
+ });
130
+
131
+ editor.removePattern(todoPatternId);
132
+ editor.clearPatterns();
133
+ ```
134
+
135
+ Patterns can also style named capture groups and add line diagnostics.
136
+
137
+ ```ts
138
+ editor.addPattern({
139
+ pattern: /^(?<key>\w[\w-]*):\s*(?<value>.+)$/gm,
140
+ captureGroups: {
141
+ key: { bold: true, color: 'var(--editor-key-color)' },
142
+ value: { color: 'var(--editor-value-color)' },
143
+ },
144
+ createLineDecoration: () => ({ className: 'config-line' }),
145
+ });
146
+ ```
147
+
148
+ See [PLUGIN_AUTHORING.md](PLUGIN_AUTHORING.md) for the complete decoration and plugin model.
149
+
150
+ ## Markdown Plugin Package
151
+
152
+ Install the Markdown plugin package when you want Markdown-oriented decorations and preview
153
+ HTML without writing your own parser bridge.
154
+
155
+ ```bash
156
+ npm install @rcarls/rc-textarea @rcarls/rc-textarea-plugin-markdown \
157
+ mdast-util-from-markdown micromark unist-util-visit
158
+ ```
159
+
160
+ ```bash
161
+ yarn add @rcarls/rc-textarea @rcarls/rc-textarea-plugin-markdown \
162
+ mdast-util-from-markdown micromark unist-util-visit
163
+ ```
164
+
165
+ ```ts
166
+ import '@rcarls/rc-textarea/define';
167
+ import { createMarkdownPlugin } from '@rcarls/rc-textarea-plugin-markdown';
168
+
169
+ const editor = document.querySelector('rc-textarea');
170
+ const markdown = createMarkdownPlugin();
171
+
172
+ editor.usePlugin(markdown);
173
+
174
+ preview.innerHTML = markdown.getPreviewHtml(editor.value);
175
+ ```
176
+
177
+ The package decorates common Markdown syntax using `mdast-util-from-markdown` and exposes
178
+ `getMarkdownPreviewHtml()` / `plugin.getPreviewHtml()` for preview rendering.
179
+
180
+ ## highlight.js And Prism Bridge
181
+
182
+ `rc-textarea` can consume the HTML strings produced by highlighters that wrap token text in
183
+ `<span class="...">...</span>` nodes. Return that HTML from `highlight()` or call
184
+ `api.parseDecorationsFromHtml()` yourself inside `update()`.
185
+
186
+ ```ts
187
+ import hljs from 'highlight.js/lib/core';
188
+ import javascript from 'highlight.js/lib/languages/javascript';
189
+
190
+ hljs.registerLanguage('javascript', javascript);
191
+
192
+ editor.usePlugin({
193
+ mount(api) {
194
+ api.adoptStyleSheet(`
195
+ .hljs-keyword { color: var(--editor-syntax-keyword); font-weight: 600; }
196
+ .hljs-string { color: var(--editor-syntax-string); }
197
+ .hljs-comment { color: var(--editor-syntax-comment); font-style: italic; }
198
+ `);
199
+ },
200
+
201
+ highlight(value) {
202
+ return hljs.highlight(value, { language: 'javascript' }).value;
203
+ },
204
+ });
205
+ ```
206
+
207
+ ```ts
208
+ import Prism from 'prismjs';
209
+ import 'prismjs/components/prism-python';
210
+
211
+ editor.usePlugin({
212
+ mount(api) {
213
+ api.adoptStyleSheet(`
214
+ .token.keyword { color: var(--editor-syntax-keyword); font-weight: 600; }
215
+ .token.string { color: var(--editor-syntax-string); }
216
+ .token.comment { color: var(--editor-syntax-comment); font-style: italic; }
217
+ `);
218
+ },
219
+
220
+ highlight(value) {
221
+ return Prism.highlight(value, Prism.languages.python, 'python');
222
+ },
223
+ });
224
+ ```
225
+
226
+ For Lezer, Unified, and Shiki integrations, see `@rcarls/rc-textarea-adapters`.
227
+
228
+ ## Theming
229
+
230
+ `rc-textarea` is design-system neutral and uses CSS system colors by default. Theme it with broad tokens
231
+ for the field, then add component tokens for editor-specific surfaces.
232
+
233
+ ### Broad Theme Tokens
234
+
235
+ The component reads inherited tokens where possible:
236
+
237
+ | Token | Use |
238
+ | ----------------- | ------------------------------------------------------------ |
239
+ | `--rc-field-text` | Fallback text color before `--rc-textarea-color`. |
240
+ | `color-scheme` | Inherited by the host so system colors match the page theme. |
241
+
242
+ ### Component Tokens
243
+
244
+ | Token | Default | Use |
245
+ | ----------------------------------------- | ------------------------------------------- | ------------------------------------- |
246
+ | `--rc-textarea-font-family` | `monospace` | Editor font family. |
247
+ | `--rc-textarea-font-size` | `1em` | Editor and gutter font size. |
248
+ | `--rc-textarea-line-height` | `1.5` | Editor and gutter line height. |
249
+ | `--rc-textarea-padding` | `0.5em` | Editor and gutter padding. |
250
+ | `--rc-textarea-background` | `Field` | Field background. |
251
+ | `--rc-textarea-color` | `var(--rc-field-text, FieldText)` | Field text color. |
252
+ | `--rc-textarea-caret-color` | `var(--rc-textarea-color, FieldText)` | Caret color. |
253
+ | `--rc-textarea-border` | `1px solid ButtonBorder` | Field border. |
254
+ | `--rc-textarea-border-radius` | `2px` | Field corner radius. |
255
+ | `--rc-textarea-focus-outline` | `2px solid Highlight` | Focus ring. |
256
+ | `--rc-textarea-active-line-bg` | `transparent` | Active line background. |
257
+ | `--rc-textarea-gutter-bg` | `Canvas` | Gutter background. |
258
+ | `--rc-textarea-gutter-color` | `GrayText` | Gutter text color. |
259
+ | `--rc-textarea-gutter-border` | `1px solid ButtonBorder` | Gutter separator. |
260
+ | `--rc-textarea-gutter-font-family` | `var(--rc-textarea-font-family, monospace)` | Gutter font family. |
261
+ | `--rc-textarea-gutter-padding-inline-end` | `0.75em` | Space between gutter labels and text. |
262
+
263
+ Line actions added by plugins use the `--rc-line-action-*` family. Inline actions default to
264
+ compact, inherited styling; popover actions use `Canvas`, `ButtonText`, and `ButtonFace` system
265
+ colors where their surface needs an independent default. The public hooks are
266
+ `--rc-line-actions-gap`, `--rc-line-actions-margin-start`, `--rc-line-action-padding`,
267
+ `--rc-line-action-border`, `--rc-line-action-border-radius`, `--rc-line-action-bg`,
268
+ `--rc-line-action-color`, `--rc-line-action-font-size`, `--rc-line-action-opacity`,
269
+ `--rc-line-action-hover-opacity`, `--rc-line-action-hover-bg`,
270
+ `--rc-line-action-hover-color`, and `--rc-line-action-shadow`.
271
+
272
+ ```css
273
+ rc-textarea {
274
+ color-scheme: dark;
275
+ --rc-textarea-font-family: 'Fira Code', monospace;
276
+ --rc-textarea-font-size: 13px;
277
+ --rc-textarea-background: #1e1e2e;
278
+ --rc-textarea-color: #cdd6f4;
279
+ --rc-textarea-border: 1px solid #313244;
280
+ --rc-textarea-active-line-bg: rgb(255 255 255 / 0.06);
281
+ }
282
+ ```
283
+
284
+ ### Parts And Decoration Styles
285
+
286
+ The exposed CSS parts are `root`, `gutter`, `gutter-cells`, `editor-area`, and `editor`.
287
+
288
+ ```css
289
+ rc-textarea::part(editor) {
290
+ tab-size: 2;
291
+ }
292
+ ```
293
+
294
+ Decoration elements are inside the shadow root. Use `api.adoptStyleSheet()` from a plugin to
295
+ style custom classes such as `.my-highlight`, `.line[data-message]`, or token classes from a
296
+ syntax highlighter.
297
+
298
+ ## Keyboard Behavior
299
+
300
+ | Key | Behavior |
301
+ | --------------------------------- | ------------------------------------------------------------ |
302
+ | `Tab` | Inserts `\t`. |
303
+ | `Ctrl/Cmd+Z` | Undo. |
304
+ | `Ctrl/Cmd+Y` / `Ctrl/Cmd+Shift+Z` | Redo. |
305
+ | `Paste` | Inserts plain text only and normalizes line endings to `\n`. |
306
+ | `Enter` | Inserts a line break. |
307
+
308
+ ## More Detail
309
+
310
+ - [PLUGIN_AUTHORING.md](PLUGIN_AUTHORING.md) covers custom plugins, decoration types,
311
+ selection APIs, stylesheet injection, and parser/highlighter recipes.
312
+ - [ARCHITECTURE.md](ARCHITECTURE.md) is an internal contributor reference for the rendering
313
+ loop, Parchment integration, selection mapping, and gutter synchronization.
314
+
315
+ ## License
316
+
317
+ [MIT](../../LICENSE)