rt-native 1.0.104 → 1.0.106

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.
Files changed (3) hide show
  1. package/README.md +232 -224
  2. package/package.json +1 -1
  3. package/rt-native.js +10 -1
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # `<rt-native>` — Native Web Component Rich Text Editor
1
+ # rt-native — Native Web Component Rich Text Editor
2
2
 
3
3
  **Author:** Ryan Kueter
4
4
  **Updated:** April, 2026
5
5
 
6
- `rt-native.js` HTML Editor is a free native web component that provides accessibility features and a wide variety of elements and customizations that make it one of the most robust and flexible HTML editors available. It allows the programmer to apply custom .css files to the preview window, so see how the content will be displayed in production. The editor uses embedded .svg Google Font Icons and the shadow DOM to isolate the HTML from inheriting the existing page styles. No frameworks, no build step, no dependencies — drop **one script tag** into any HTML page and you're done.
6
+ **rt-native.js** HTML Editor is a free native web component that provides accessibility features and a wide variety of elements and customizations that make it one of the most robust and flexible HTML editors available. It allows the programmer to apply custom .css files to the preview window, so see how the content will be displayed in production. The editor uses embedded .svg Google Font Icons and the shadow DOM to isolate the HTML from inheriting the existing page styles. No frameworks, no build step, no dependencies — drop **one script tag** into any HTML page and you're done.
7
7
 
8
8
  ---
9
9
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  | File | Purpose |
58
58
  |---|---|
59
- | `rt-native.js` | **The only required file.** Contains the complete editor engine, web component wrapper, all CSS defaults, and all dialog styles — everything is self-contained. |
59
+ | rt-native.js | **The only required file.** Contains the complete editor engine, web component wrapper, all CSS defaults, and all dialog styles — everything is self-contained. |
60
60
 
61
61
  ---
62
62
 
@@ -136,14 +136,14 @@ npm install rt-native
136
136
 
137
137
  | Attribute | Type | Default | Description |
138
138
  |---|---|---|---|
139
- | `value` | `string` | `''` | Initial HTML content of the editor. |
140
- | `width` | `string` | `100%` | Editor width. Any valid CSS value (`px`, `%`, `vw`, etc.). |
141
- | `height` | `string` | `300px` | Editor height. Any valid CSS value. |
142
- | `placeholder` | `string` | — | Placeholder text shown when the editor is empty. |
143
- | `readonly` | boolean (presence) | — | Puts the editor in read-only mode. Hides the toolbar. |
144
- | `aria-label` | `string` | `'Rich text editor'` | Accessible name for the editor region. |
145
- | `label` | `string` | — | Alternative to `aria-label` for the accessible name. |
146
- | `config` | JSON string | — | Declarative configuration. Parsed and passed to `configure()` on connect. |
139
+ | value | string | '' | Initial HTML content of the editor. |
140
+ | width | string | 100% | Editor width. Any valid CSS value (px, %, vw, etc.). |
141
+ | height | string | 300px | Editor height. Any valid CSS value. |
142
+ | placeholder | string | — | Placeholder text shown when the editor is empty. |
143
+ | readonly | boolean (presence) | — | Puts the editor in read-only mode. Hides the toolbar. |
144
+ | aria-label | string | 'Rich text editor' | Accessible name for the editor region. |
145
+ | label | string | — | Alternative to **aria-label** for the accessible name. |
146
+ | config | JSON string | — | Declarative configuration. Parsed and passed to **configure()** on connect. |
147
147
 
148
148
  ### Example
149
149
 
@@ -162,7 +162,7 @@ npm install rt-native
162
162
  <rt-native config='{"editor":{"height":"500px"},"visibility":{"embedMedia":false}}'></rt-native>
163
163
  ```
164
164
 
165
- > **Note:** `width` and `height` are shorthand for `--rtb-editor-width` and `--rtb-editor-height`. They can also be set via CSS variables or `configure({ editor: { width, height } })`.
165
+ > **Note:** **width** and **height** are shorthand for --rtb-editor-width and --rtb-editor-height. They can also be set via CSS variables or **configure({ editor: { width, height } })**.
166
166
 
167
167
  ---
168
168
 
@@ -188,7 +188,7 @@ const text = editor.getPlainText();
188
188
 
189
189
  ### setValue()
190
190
 
191
- Replaces the editor content with the supplied HTML string. Passing an empty string or `null` clears the editor.
191
+ Replaces the editor content with the supplied HTML string. Passing an empty string or null clears the editor.
192
192
 
193
193
  ```js
194
194
  editor.setValue('<h2>New content</h2><p>Paragraph text.</p>');
@@ -222,7 +222,7 @@ editor.setReadOnly(true); // lock
222
222
  editor.setReadOnly(false); // unlock
223
223
  ```
224
224
 
225
- The `readOnly` getter reflects the current state:
225
+ The **readOnly** getter reflects the current state:
226
226
 
227
227
  ```js
228
228
  if (editor.readOnly) {
@@ -230,7 +230,7 @@ if (editor.readOnly) {
230
230
  }
231
231
  ```
232
232
 
233
- Read-only mode can also be set declaratively via the `readonly` HTML attribute:
233
+ Read-only mode can also be set declaratively via the **readonly** HTML attribute:
234
234
 
235
235
  ```html
236
236
  <rt-native readonly></rt-native>
@@ -251,11 +251,11 @@ editor.setPreviewCssFiles('/styles/my-content.css');
251
251
  editor.setPreviewCssFiles();
252
252
  ```
253
253
 
254
- > **CORS:** Files are loaded with `fetch()`. They must be served from the same origin or include appropriate `Access-Control-Allow-Origin` headers.
254
+ > **CORS:** Files are loaded with fetch(). They must be served from the same origin or include appropriate Access-Control-Allow-Origin headers.
255
255
 
256
256
  ### setPreviewCssFile()
257
257
 
258
- Convenience method that sets a **single** CSS file. Equivalent to `setPreviewCssFiles(url)`.
258
+ Convenience method that sets a **single** CSS file. Equivalent to **setPreviewCssFiles(url)**.
259
259
 
260
260
  ```js
261
261
  editor.setPreviewCssFile('/styles/content.css');
@@ -266,7 +266,7 @@ editor.setPreviewCssFile('');
266
266
 
267
267
  ### setPreviewCss()
268
268
 
269
- Supplies **inline CSS** to apply to both the editor content area and the preview window. Rules are automatically scoped, exactly like `setPreviewCssFiles()`. Call with no argument (or `''`) to clear.
269
+ Supplies **inline CSS** to apply to both the editor content area and the preview window. Rules are automatically scoped, exactly like **setPreviewCssFiles()**. Call with no argument (or '') to clear.
270
270
 
271
271
  ```js
272
272
  editor.setPreviewCss(`
@@ -281,13 +281,13 @@ editor.setPreviewCss(`
281
281
  editor.setPreviewCss('');
282
282
  ```
283
283
 
284
- `setPreviewCss()` and `setPreviewCssFiles()` are independent — both can be active at the same time. File rules are applied first; inline rules are appended after, so inline CSS always wins when there is a conflict.
284
+ **setPreviewCss()** and **setPreviewCssFiles()** are independent — both can be active at the same time. File rules are applied first; inline rules are appended after, so inline CSS always wins when there is a conflict.
285
285
 
286
286
  ---
287
287
 
288
288
  ## Events
289
289
 
290
- ### `change`
290
+ ### change
291
291
 
292
292
  Fired on the element whenever the editor content changes. The event **bubbles** and is **composed** (crosses shadow DOM boundaries).
293
293
 
@@ -300,15 +300,15 @@ editor.addEventListener('change', (event) => {
300
300
 
301
301
  | Property | Value |
302
302
  |---|---|
303
- | `event.detail.value` | Current editor HTML as a string |
304
- | `event.bubbles` | `true` |
305
- | `event.composed` | `true` |
303
+ | event.detail.value | Current editor HTML as a string |
304
+ | event.bubbles | true |
305
+ | event.composed | true |
306
306
 
307
307
  ---
308
308
 
309
309
  ## CSS Variables
310
310
 
311
- All visual aspects of the editor are controlled through CSS custom properties declared on the `rt-native` element. Default values are injected automatically by `rt-native.js` when the first editor mounts — no stylesheet required. Override any variable in your own CSS to theme the editor.
311
+ All visual aspects of the editor are controlled through CSS custom properties declared on the **rt-native** element. Default values are injected automatically by **rt-native.js** when the first editor mounts — no stylesheet required. Override any variable in your own CSS to theme the editor.
312
312
 
313
313
  ```css
314
314
  /* Override globally (all editors on the page) */
@@ -332,15 +332,15 @@ rt-native {
332
332
 
333
333
  | Variable | Default | Description |
334
334
  |---|---|---|
335
- | `--rtb-toolbar-bg` | `#FFF` | Toolbar background color |
336
- | `--rtb-toolbar-border-style` | `solid` | Toolbar bottom border style |
337
- | `--rtb-toolbar-border-width` | `1px` | Toolbar bottom border width |
338
- | `--rtb-toolbar-border-color` | `#EEE` | Toolbar bottom border color |
339
- | `--rtb-toolbar-border-radius` | `0px` | Toolbar corner radius (container clips top corners automatically) |
340
- | `--rtb-dropdown-bg` | `#FFF` | Font / Size / Format dropdown background |
341
- | `--rtb-dropdown-text` | `#000` | Dropdown item text color |
342
- | `--rtb-dropdown-bg-hover` | `#e5e5e5` | Dropdown item hover background |
343
- | `--rtb-dropdown-text-hover` | `#000` | Dropdown item hover text color |
335
+ | --rtb-toolbar-bg | #FFF | Toolbar background color |
336
+ | --rtb-toolbar-border-style | solid | Toolbar bottom border style |
337
+ | --rtb-toolbar-border-width | 1px | Toolbar bottom border width |
338
+ | --rtb-toolbar-border-color | #EEE | Toolbar bottom border color |
339
+ | --rtb-toolbar-border-radius | 0px | Toolbar corner radius (container clips top corners automatically) |
340
+ | --rtb-dropdown-bg | #FFF | Font / Size / Format dropdown background |
341
+ | --rtb-dropdown-text | #000 | Dropdown item text color |
342
+ | --rtb-dropdown-bg-hover | #e5e5e5 | Dropdown item hover background |
343
+ | --rtb-dropdown-text-hover | #000 | Dropdown item hover text color |
344
344
 
345
345
  ---
346
346
 
@@ -348,18 +348,18 @@ rt-native {
348
348
 
349
349
  | Variable | Default | Description |
350
350
  |---|---|---|
351
- | `--rtb-btn-text` | `#000` | Button icon color |
352
- | `--rtb-btn-size` | `16px` | Icon size (also drives button `min-height` and divider height) |
353
- | `--rtb-btn-font` | `Arial, sans-serif` | Font for dropdown buttons |
354
- | `--rtb-btn-bg` | `inherit` | Button background at rest |
355
- | `--rtb-btn-bg-hover` | `#DDD` | Button background on hover |
356
- | `--rtb-btn-bg-selected` | `#CCC` | Button background when active / selected |
357
- | `--rtb-btn-border-style` | `none` | Button border style |
358
- | `--rtb-btn-border-width` | `0px` | Button border width |
359
- | `--rtb-btn-border-color` | `#AAA` | Button border color at rest |
360
- | `--rtb-btn-border-hover` | `inherit` | Button border color on hover |
361
- | `--rtb-btn-border-selected` | `inherit` | Button border color when selected |
362
- | `--rtb-btn-border-radius` | `5px` | Button corner radius |
351
+ | --rtb-btn-text | #000 | Button icon color |
352
+ | --rtb-btn-size | 16px | Icon size (also drives button min-height and divider height) |
353
+ | --rtb-btn-font | Arial, sans-serif | Font for dropdown buttons |
354
+ | --rtb-btn-bg | inherit | Button background at rest |
355
+ | --rtb-btn-bg-hover | #DDD | Button background on hover |
356
+ | --rtb-btn-bg-selected | #CCC | Button background when active / selected |
357
+ | --rtb-btn-border-style | none | Button border style |
358
+ | --rtb-btn-border-width | 0px | Button border width |
359
+ | --rtb-btn-border-color | #AAA | Button border color at rest |
360
+ | --rtb-btn-border-hover | inherit | Button border color on hover |
361
+ | --rtb-btn-border-selected | inherit | Button border color when selected |
362
+ | --rtb-btn-border-radius | 5px | Button corner radius |
363
363
 
364
364
  ---
365
365
 
@@ -367,12 +367,12 @@ rt-native {
367
367
 
368
368
  | Variable | Default | Description |
369
369
  |---|---|---|
370
- | `--rtb-content-text` | `#000` | Editor text color |
371
- | `--rtb-content-size` | `16px` | Editor font size |
372
- | `--rtb-content-font` | `Arial, sans-serif` | Editor font family |
373
- | `--rtb-content-bg` | `#FFF` | Editor content background color |
374
- | `--rtb-content-shadow` | `none` | Inner box shadow on the content area |
375
- | `--rtb-placeholder-color` | `#9ca3af` | Placeholder text color |
370
+ | --rtb-content-text | #000 | Editor text color |
371
+ | --rtb-content-size | 16px | Editor font size |
372
+ | --rtb-content-font | Arial, sans-serif | Editor font family |
373
+ | --rtb-content-bg | #FFF | Editor content background color |
374
+ | --rtb-content-shadow | none | Inner box shadow on the content area |
375
+ | --rtb-placeholder-color | #9ca3af | Placeholder text color |
376
376
 
377
377
  ---
378
378
 
@@ -380,14 +380,15 @@ rt-native {
380
380
 
381
381
  | Variable | Default | Description |
382
382
  |---|---|---|
383
- | `--rtb-editor-width` | `100%` | Maximum width of the editor |
384
- | `--rtb-editor-height` | `300px` | Height of the editor |
385
- | `--rtb-editor-border-style` | `solid` | Outer border style |
386
- | `--rtb-editor-border-width` | `1px` | Outer border width |
387
- | `--rtb-editor-border-color` | `#EEE` | Outer border color |
388
- | `--rtb-editor-border-radius` | `0px` | Outer corner radius |
389
- | `--rtb-editor-shadow` | `none` | Outer box shadow |
390
- | `--rtb-editor-resize` | `auto` | `auto` shows the resize handle; `hidden` removes it |
383
+ | --rtb-editor-width | 100% | Maximum width of the editor |
384
+ | --rtb-editor-height | 300px | Height of the editor |
385
+ | --rtb-editor-border-style | solid | Outer border style |
386
+ | --rtb-editor-border-width | 1px | Outer border width |
387
+ | --rtb-editor-border-color | #EEE | Outer border color |
388
+ | --rtb-editor-border-radius | 0px | Outer corner radius |
389
+ | --rtb-editor-shadow | none | Outer box shadow |
390
+ | --rtb-editor-resize | auto | auto shows the resize handle; hidden removes it |
391
+ | --rtb-z-index | 1 | Z-index of the editor container — raise this to stack the editor above surrounding page content |
391
392
 
392
393
  ---
393
394
 
@@ -395,12 +396,12 @@ rt-native {
395
396
 
396
397
  | Variable | Default | Description |
397
398
  |---|---|---|
398
- | `--rtb-scroll-width` | `10px` | Scrollbar track width |
399
- | `--rtb-scroll-opacity` | `1` | Scrollbar opacity |
400
- | `--rtb-scroll-bg` | `transparent` | Scrollbar track background |
401
- | `--rtb-scroll-thumb-bg` | `#AAA` | Scrollbar thumb color |
402
- | `--rtb-scroll-thumb-bg-hover` | `#DDD` | Scrollbar thumb color on hover |
403
- | `--rtb-scroll-thumb-radius` | `0` | Scrollbar thumb corner radius |
399
+ | --rtb-scroll-width | 10px | Scrollbar track width |
400
+ | --rtb-scroll-opacity | 1 | Scrollbar opacity |
401
+ | --rtb-scroll-bg | transparent | Scrollbar track background |
402
+ | --rtb-scroll-thumb-bg | #AAA | Scrollbar thumb color |
403
+ | --rtb-scroll-thumb-bg-hover | #DDD | Scrollbar thumb color on hover |
404
+ | --rtb-scroll-thumb-radius | 0 | Scrollbar thumb corner radius |
404
405
 
405
406
  ---
406
407
 
@@ -408,9 +409,9 @@ rt-native {
408
409
 
409
410
  | Variable | Default | Description |
410
411
  |---|---|---|
411
- | `--rtb-quote-bg` | `#f9f9f9` | Blockquote background color |
412
- | `--rtb-quote-border-color` | `#ccc` | Blockquote left-border color |
413
- | `--rtb-quote-border-width` | `5px` | Blockquote left-border width |
412
+ | --rtb-quote-bg | #f9f9f9 | Blockquote background color |
413
+ | --rtb-quote-border-color | #ccc | Blockquote left-border color |
414
+ | --rtb-quote-border-width | 5px | Blockquote left-border width |
414
415
 
415
416
  ---
416
417
 
@@ -418,8 +419,8 @@ rt-native {
418
419
 
419
420
  | Variable | Default | Description |
420
421
  |---|---|---|
421
- | `--rtb-code-bg` | `#f9f9f9` | Code block background color |
422
- | `--rtb-code-border-radius` | `10px` | Code block corner radius |
422
+ | --rtb-code-bg | #f9f9f9 | Code block background color |
423
+ | --rtb-code-border-radius | 10px | Code block corner radius |
423
424
 
424
425
  ---
425
426
 
@@ -427,14 +428,14 @@ rt-native {
427
428
 
428
429
  | Variable | Default | Description |
429
430
  |---|---|---|
430
- | `--rtb-modal-bg` | `#fefefe` | Dialog background color |
431
- | `--rtb-modal-text` | `#000` | Dialog text and close-button color |
432
- | `--rtb-modal-text-size` | `16px` | Dialog font size |
433
- | `--rtb-modal-text-font` | `Arial, sans-serif` | Dialog font family |
434
- | `--rtb-modal-input-bg` | `#fff` | Input field background |
435
- | `--rtb-modal-input-text` | `#000` | Input field text color |
436
- | `--rtb-modal-input-border` | `#CCC` | Input field border color |
437
- | `--rtb-modal-checkbox` | `#007bff` | Checkbox accent color |
431
+ | --rtb-modal-bg | #fefefe | Dialog background color |
432
+ | --rtb-modal-text | #000 | Dialog text and close-button color |
433
+ | --rtb-modal-text-size | 16px | Dialog font size |
434
+ | --rtb-modal-text-font | Arial, sans-serif | Dialog font family |
435
+ | --rtb-modal-input-bg | #fff | Input field background |
436
+ | --rtb-modal-input-text | #000 | Input field text color |
437
+ | --rtb-modal-input-border | #CCC | Input field border color |
438
+ | --rtb-modal-checkbox | #007bff | Checkbox accent color |
438
439
 
439
440
  ---
440
441
 
@@ -466,14 +467,21 @@ rt-native.dark {
466
467
 
467
468
  **Apply via HTML:**
468
469
  ```html
469
- <rt-native class="dark"></rt-native>
470
+ <rt-native class="dark" id="editor" height="400px"></rt-native>
470
471
  ```
471
472
 
472
473
  **Apply via JavaScript:**
473
474
  ```js
474
- editor.classList.add('dark');
475
- editor.classList.remove('dark');
476
- editor.classList.replace('dark', 'ocean');
475
+ var editor = document.getElementById("editor");
476
+ if (editor) {
477
+ if (editor.classList.contains('light')) {
478
+ editor.classList.remove('light');
479
+ }
480
+ if (editor.classList.contains('dark')) {
481
+ editor.classList.remove('dark');
482
+ }
483
+ editor.classList.add(theme);
484
+ }
477
485
  ```
478
486
 
479
487
  **Apply via media query (system dark mode):**
@@ -636,7 +644,7 @@ rt-native.fluent-dark {
636
644
 
637
645
  ## configure() Reference
638
646
 
639
- `configure()` accepts a single options object. Every property is optional. Calling `configure()` multiple times merges with the previous state.
647
+ **configure()** accepts a single options object. Every property is optional. Calling **configure()** multiple times merges with the previous state.
640
648
 
641
649
  ### toolbar options
642
650
 
@@ -765,7 +773,7 @@ editor.configure({
765
773
 
766
774
  ### visibility options
767
775
 
768
- Controls which toolbar buttons are rendered. All buttons are visible by default except the **status bar** (`wordCount`), which is hidden by default and revealed with the Toggle Status Bar button.
776
+ Controls which toolbar buttons are rendered. All buttons are visible by default except the **status bar** (wordCount), which is hidden by default and revealed with the Toggle Status Bar button.
769
777
 
770
778
  Use `clearAll: true` to hide everything first, then opt individual buttons back in.
771
779
 
@@ -804,64 +812,64 @@ editor.configure({
804
812
 
805
813
  | Key | Controls |
806
814
  |---|---|
807
- | `font` | Font family dropdown |
808
- | `size` | Font size dropdown |
809
- | `format` | Paragraph / heading format dropdown |
810
- | `textStylesDivider` | Divider after the three dropdowns |
811
- | `bold` | Bold button |
812
- | `italic` | Italic button |
813
- | `underline` | Underline button |
814
- | `strikethrough` | Strikethrough button |
815
- | `subscript` | Subscript button |
816
- | `superscript` | Superscript button |
817
- | `formatDivider` | Divider after text-format buttons |
818
- | `textColor` | Text color, background color, and remove-color buttons |
819
- | `textColorDivider` | Divider after color buttons |
820
- | `alignLeft` | Align left button |
821
- | `alignCenter` | Align center button |
822
- | `alignRight` | Align right button |
823
- | `alignJustify` | Justify button |
824
- | `alignDivider` | Divider after alignment buttons |
825
- | `cut` | Cut button |
826
- | `copy` | Copy button |
827
- | `paste` | Paste button |
828
- | `delete` | Delete button |
829
- | `selectAll` | Select all button |
830
- | `actionDivider` | Divider after clipboard buttons |
831
- | `orderedList` | Ordered list button |
832
- | `unorderedList` | Unordered list button |
833
- | `indent` | Increase / decrease indent buttons |
834
- | `listDivider` | Divider after list buttons |
835
- | `link` | Insert link and remove link buttons |
836
- | `image` | Insert image button |
837
- | `imageUpload` | Upload / embed image button |
838
- | `quote` | Block quote button |
839
- | `codeBlock` | Code block button |
840
- | `embedMedia` | Embed media (audio / PDF / iframe) button |
841
- | `video` | Video embed button |
842
- | `table` | Insert table button |
843
- | `horizontalRule` | Insert horizontal rule button |
844
- | `mediaDivider` | Divider after insert buttons |
845
- | `undo` | Undo button |
846
- | `redo` | Redo button |
847
- | `historyDivider` | Divider after undo / redo |
848
- | `statusBarToggle` | Toggle Status Bar button |
849
- | `saveHtml` | Save HTML file button |
850
- | `htmlView` | Toggle HTML source view button |
851
- | `preview` | Preview button |
852
- | `wordCount` | Status bar (word / character count) — hidden by default |
853
-
854
- > **Divider auto-hiding:** Dividers are only rendered when at least one button in their group is visible *and* the divider's own key is `true`.
815
+ | font | Font family dropdown |
816
+ | size | Font size dropdown |
817
+ | format | Paragraph / heading format dropdown |
818
+ | textStylesDivider | Divider after the three dropdowns |
819
+ | bold | Bold button |
820
+ | italic | Italic button |
821
+ | underline | Underline button |
822
+ | strikethrough | Strikethrough button |
823
+ | subscript | Subscript button |
824
+ | superscript | Superscript button |
825
+ | formatDivider | Divider after text-format buttons |
826
+ | textColor | Text color, background color, and remove-color buttons |
827
+ | textColorDivider | Divider after color buttons |
828
+ | alignLeft | Align left button |
829
+ | alignCenter | Align center button |
830
+ | alignRight | Align right button |
831
+ | alignJustify | Justify button |
832
+ | alignDivider | Divider after alignment buttons |
833
+ | cut | Cut button |
834
+ | copy | Copy button |
835
+ | paste | Paste button |
836
+ | delete | Delete button |
837
+ | selectAll | Select all button |
838
+ | actionDivider | Divider after clipboard buttons |
839
+ | orderedList | Ordered list button |
840
+ | unorderedList | Unordered list button |
841
+ | indent | Increase / decrease indent buttons |
842
+ | listDivider | Divider after list buttons |
843
+ | link | Insert link and remove link buttons |
844
+ | image | Insert image button |
845
+ | imageUpload | Upload / embed image button |
846
+ | quote | Block quote button |
847
+ | codeBlock | Code block button |
848
+ | embedMedia | Embed media (audio / PDF / iframe) button |
849
+ | video | Video embed button |
850
+ | table | Insert table button |
851
+ | horizontalRule | Insert horizontal rule button |
852
+ | mediaDivider | Divider after insert buttons |
853
+ | undo | Undo button |
854
+ | redo | Redo button |
855
+ | historyDivider | Divider after undo / redo |
856
+ | statusBarToggle | Toggle Status Bar button |
857
+ | saveHtml | Save HTML file button |
858
+ | htmlView | Toggle HTML source view button |
859
+ | preview | Preview button |
860
+ | wordCount | Status bar (word / character count) — hidden by default |
861
+
862
+ > **Divider auto-hiding:** Dividers are only rendered when at least one button in their group is visible *and* the divider's own key is true.
855
863
 
856
864
  ---
857
865
 
858
866
  ## Preview Window Styling
859
867
 
860
- When you load preview CSS with `setPreviewCssFiles()` or `setPreviewCss()`, the component applies the styles in two places simultaneously:
868
+ When you load preview CSS with **setPreviewCssFiles()** or **setPreviewCss()**, the component applies the styles in two places simultaneously:
861
869
 
862
- 1. **Editor content area** — CSS files are fetched, every selector is automatically prefixed with `.rich-text-box-content`, and the scoped rules are injected into the editor's shadow root. You see your production styles while you type, with no risk of styles escaping to the toolbar, menus, or the surrounding page.
870
+ 1. **Editor content area** — CSS files are fetched, every selector is automatically prefixed with .rich-text-box-content, and the scoped rules are injected into the editor's shadow root. You see your production styles while you type, with no risk of styles escaping to the toolbar, menus, or the surrounding page.
863
871
 
864
- 2. **Preview window** — Content is rendered inside an `<iframe srcdoc>` with a completely isolated browsing context. The preview shows exactly what a reader would see in production with a clean browser baseline.
872
+ 2. **Preview window** — Content is rendered inside an iframe srcdoc with a completely isolated browsing context. The preview shows exactly what a reader would see in production with a clean browser baseline.
865
873
 
866
874
  ### Writing your own preview CSS
867
875
 
@@ -891,7 +899,7 @@ editor.setPreviewCssFiles('my-content.css');
891
899
 
892
900
  ### At-rules
893
901
 
894
- `@media`, `@supports`, `@layer`, and `@container` blocks are handled correctly — selectors inside them are scoped. Other at-rules (`@keyframes`, `@font-face`, etc.) are passed through unchanged.
902
+ @media, @supports, @layer, and @container blocks are handled correctly — selectors inside them are scoped. Other at-rules (@keyframes, @font-face, etc.) are passed through unchanged.
895
903
 
896
904
  ---
897
905
 
@@ -902,113 +910,113 @@ Buttons appear left-to-right in the order listed. Dividers separate logical grou
902
910
  | Button | Action | Shortcut |
903
911
  |---|---|---|
904
912
  | Font | Set font family | — |
905
- | Size | Set font size | `Ctrl+Shift+<` / `Ctrl+Shift+>` |
906
- | Format | Apply block format (paragraph, headings 1–6) | `Ctrl+Shift+D` / `Ctrl+Shift+1`–`6` |
907
- | Bold | Bold | `Ctrl+B` |
908
- | Italic | Italic | `Ctrl+I` |
909
- | Underline | Underline | `Ctrl+U` |
910
- | Strikethrough | Strikethrough | `Ctrl+D` |
911
- | Subscript | Subscript | `Ctrl+=` |
912
- | Superscript | Superscript | `Ctrl+Shift++` |
913
- | Text Color | Open text color picker | `Ctrl+Shift+C` |
914
- | Background Color | Open text background color picker | `Ctrl+Shift+B` |
913
+ | Size | Set font size | Ctrl+Shift+< / Ctrl+Shift+> |
914
+ | Format | Apply block format (paragraph, headings 1–6) | Ctrl+Shift+D / Ctrl+Shift+16 |
915
+ | Bold | Bold | Ctrl+B |
916
+ | Italic | Italic | Ctrl+I |
917
+ | Underline | Underline | Ctrl+U |
918
+ | Strikethrough | Strikethrough | Ctrl+D |
919
+ | Subscript | Subscript | Ctrl+= |
920
+ | Superscript | Superscript | Ctrl+Shift++ |
921
+ | Text Color | Open text color picker | Ctrl+Shift+C |
922
+ | Background Color | Open text background color picker | Ctrl+Shift+B |
915
923
  | Remove Color | Strip text and background color | — |
916
- | Align Left | Left-align | `Ctrl+L` |
917
- | Align Center | Center-align | `Ctrl+E` |
918
- | Align Right | Right-align | `Ctrl+R` |
919
- | Justify | Justify | `Ctrl+J` |
920
- | Cut | Cut selection | `Ctrl+X` |
921
- | Copy | Copy selection | `Ctrl+C` |
922
- | Paste | Paste from clipboard | `Ctrl+V` |
923
- | Delete | Delete selection | `Delete` |
924
- | Select All | Select all content | `Ctrl+A` |
925
- | Ordered List | Insert numbered list | `Ctrl+Shift+O` |
926
- | Unordered List | Insert bulleted list | `Ctrl+Shift+U` |
927
- | Increase Indent | Indent / promote list item | `Tab` |
928
- | Decrease Indent | Outdent / demote list item | `Shift+Tab` |
929
- | Insert Link | Open link dialog | `Ctrl+Shift+K` |
924
+ | Align Left | Left-align | Ctrl+L |
925
+ | Align Center | Center-align | Ctrl+E |
926
+ | Align Right | Right-align | Ctrl+R |
927
+ | Justify | Justify | Ctrl+J |
928
+ | Cut | Cut selection | Ctrl+X |
929
+ | Copy | Copy selection | Ctrl+C |
930
+ | Paste | Paste from clipboard | Ctrl+V |
931
+ | Delete | Delete selection | Delete |
932
+ | Select All | Select all content | Ctrl+A |
933
+ | Ordered List | Insert numbered list | Ctrl+Shift+O |
934
+ | Unordered List | Insert bulleted list | Ctrl+Shift+U |
935
+ | Increase Indent | Indent / promote list item | Tab |
936
+ | Decrease Indent | Outdent / demote list item | Shift+Tab |
937
+ | Insert Link | Open link dialog | Ctrl+Shift+K |
930
938
  | Remove Link | Remove hyperlink | — |
931
- | Insert Image | Open image URL dialog | `Ctrl+Shift+I` |
932
- | Upload Image | Open image upload / embed dialog | `Ctrl+Shift+&` |
933
- | Block Quote | Open block quote dialog | `Ctrl+Shift+Q` |
934
- | Embed Media | Open media embed dialog (audio, PDF, iframe) | `Ctrl+Shift+M` |
935
- | Video | Open video embed dialog | `Ctrl+Shift+V` |
936
- | Insert Table | Open table dialog | `Ctrl+Shift+L` |
937
- | Code Block | Open code block dialog | `Ctrl+Shift+*` |
938
- | Horizontal Rule | Insert `<hr>` at cursor position | `Ctrl+Shift+H` |
939
- | Undo | Undo last action | `Ctrl+Z` |
940
- | Redo | Redo last action | `Ctrl+Y` |
941
- | Toggle Status Bar | Show / hide the word and character count bar | `Ctrl+\` |
942
- | Save HTML | Download editor content as an `.html` file | `Ctrl+Shift+S` |
943
- | HTML Source | Toggle raw HTML source view | `Ctrl+Shift+A` |
944
- | Preview | Open preview dialog | `Ctrl+Shift+P` |
939
+ | Insert Image | Open image URL dialog | Ctrl+Shift+I |
940
+ | Upload Image | Open image upload / embed dialog | Ctrl+Shift+& |
941
+ | Block Quote | Open block quote dialog | Ctrl+Shift+Q |
942
+ | Embed Media | Open media embed dialog (audio, PDF, iframe) | Ctrl+Shift+M |
943
+ | Video | Open video embed dialog | Ctrl+Shift+V |
944
+ | Insert Table | Open table dialog | Ctrl+Shift+L |
945
+ | Code Block | Open code block dialog | Ctrl+Shift+* |
946
+ | Horizontal Rule | Insert \<hr\> at cursor position | Ctrl+Shift+H |
947
+ | Undo | Undo last action | Ctrl+Z |
948
+ | Redo | Redo last action | Ctrl+Y |
949
+ | Toggle Status Bar | Show / hide the word and character count bar | Ctrl+\ |
950
+ | Save HTML | Download editor content as an .html file | Ctrl+Shift+S |
951
+ | HTML Source | Toggle raw HTML source view | Ctrl+Shift+A |
952
+ | Preview | Open preview dialog | Ctrl+Shift+P |
945
953
 
946
954
  ---
947
955
 
948
956
  ## Keyboard Shortcuts
949
957
 
950
- All shortcuts are active when the editor content area has focus. The `Ctrl+\` and `Ctrl+Shift+A/P/S` shortcuts also work when the HTML source textarea has focus.
958
+ All shortcuts are active when the editor content area has focus. The Ctrl+\ and Ctrl+Shift+A/P/S shortcuts also work when the HTML source textarea has focus.
951
959
 
952
960
  | Category | Action | Shortcut |
953
961
  |---|---|---|
954
- | **Formatting** | Bold | `Ctrl+B` |
955
- | | Italic | `Ctrl+I` |
956
- | | Underline | `Ctrl+U` |
957
- | | Strikethrough | `Ctrl+D` |
958
- | | Subscript | `Ctrl+=` |
959
- | | Superscript | `Ctrl+Shift++` |
960
- | **Color** | Text color | `Ctrl+Shift+C` |
961
- | | Text background color | `Ctrl+Shift+B` |
962
- | **Alignment** | Align left | `Ctrl+L` |
963
- | | Align center | `Ctrl+E` |
964
- | | Align right | `Ctrl+R` |
965
- | | Justify | `Ctrl+J` |
966
- | **Editing** | Cut | `Ctrl+X` |
967
- | | Copy | `Ctrl+C` |
968
- | | Paste | `Ctrl+V` |
969
- | | Select all | `Ctrl+A` |
970
- | | Undo | `Ctrl+Z` |
971
- | | Redo | `Ctrl+Y` |
972
- | **Lists** | Ordered list | `Ctrl+Shift+O` |
973
- | | Unordered list | `Ctrl+Shift+U` |
974
- | | Increase indent | `Tab` |
975
- | | Decrease indent | `Shift+Tab` |
976
- | **Insert** | Insert link | `Ctrl+Shift+K` |
977
- | | Insert image | `Ctrl+Shift+I` |
978
- | | Upload image | `Ctrl+Shift+&` |
979
- | | Block quote | `Ctrl+Shift+Q` |
980
- | | Video | `Ctrl+Shift+V` |
981
- | | Embed media | `Ctrl+Shift+M` |
982
- | | Insert table | `Ctrl+Shift+L` |
983
- | | Code block | `Ctrl+Shift+*` |
984
- | | Horizontal rule | `Ctrl+Shift+H` |
985
- | **Format** | Paragraph | `Ctrl+Shift+D` |
986
- | | Heading 1–6 | `Ctrl+Shift+1``Ctrl+Shift+6` |
987
- | | Increase font size | `Ctrl+Shift+>` |
988
- | | Decrease font size | `Ctrl+Shift+<` |
989
- | **View** | Toggle status bar | `Ctrl+\` |
990
- | | Toggle HTML source | `Ctrl+Shift+A` |
991
- | | Preview | `Ctrl+Shift+P` |
992
- | | Save HTML | `Ctrl+Shift+S` |
962
+ | **Formatting** | Bold | Ctrl+B |
963
+ | | Italic | Ctrl+I |
964
+ | | Underline | Ctrl+U |
965
+ | | Strikethrough | Ctrl+D |
966
+ | | Subscript | Ctrl+= |
967
+ | | Superscript | Ctrl+Shift++ |
968
+ | **Color** | Text color | Ctrl+Shift+C |
969
+ | | Text background color | Ctrl+Shift+B |
970
+ | **Alignment** | Align left | Ctrl+L |
971
+ | | Align center | Ctrl+E |
972
+ | | Align right | Ctrl+R |
973
+ | | Justify | Ctrl+J |
974
+ | **Editing** | Cut | Ctrl+X |
975
+ | | Copy | Ctrl+C |
976
+ | | Paste | Ctrl+V |
977
+ | | Select all | Ctrl+A |
978
+ | | Undo | Ctrl+Z |
979
+ | | Redo | Ctrl+Y |
980
+ | **Lists** | Ordered list | Ctrl+Shift+O |
981
+ | | Unordered list | Ctrl+Shift+U |
982
+ | | Increase indent | Tab |
983
+ | | Decrease indent | Shift+Tab |
984
+ | **Insert** | Insert link | Ctrl+Shift+K |
985
+ | | Insert image | Ctrl+Shift+I |
986
+ | | Upload image | Ctrl+Shift+& |
987
+ | | Block quote | Ctrl+Shift+Q |
988
+ | | Video | Ctrl+Shift+V |
989
+ | | Embed media | Ctrl+Shift+M |
990
+ | | Insert table | Ctrl+Shift+L |
991
+ | | Code block | Ctrl+Shift+* |
992
+ | | Horizontal rule | Ctrl+Shift+H |
993
+ | **Format** | Paragraph | Ctrl+Shift+D |
994
+ | | Heading 1–6 | Ctrl+Shift+1 – Ctrl+Shift+6 |
995
+ | | Increase font size | Ctrl+Shift+> |
996
+ | | Decrease font size | Ctrl+Shift+< |
997
+ | **View** | Toggle status bar | Ctrl+\ |
998
+ | | Toggle HTML source | Ctrl+Shift+A |
999
+ | | Preview | Ctrl+Shift+P |
1000
+ | | Save HTML | Ctrl+Shift+S |
993
1001
 
994
1002
  ---
995
1003
 
996
1004
  ## Accessibility
997
1005
 
998
- `rt-native` is built with WCAG 2.1 AA compliance in mind:
1006
+ **rt-native** is built with WCAG 2.1 AA compliance in mind:
999
1007
 
1000
- - **Editor region** — The content area carries `role="textbox"`, `aria-multiline="true"`, and an `aria-label` (defaults to `"Rich text editor"`; override with the `aria-label` or `label` attribute on the host element).
1001
- - **Read-only state** — `aria-readonly` is kept in sync with the `readonly` attribute and `setReadOnly()`.
1002
- - **Toolbar** — The toolbar container has `role="toolbar"` and `aria-label="Formatting toolbar"`. Every button has an `aria-label` derived from its tooltip text (e.g. `"Bold (Ctrl+B)"`) and an `aria-pressed` attribute that is kept in sync with the button's active/selected state.
1003
- - **Status bar** — Carries `role="status"`, `aria-live="polite"`, and `aria-atomic="true"` so word and character count updates are announced non-intrusively by screen readers.
1004
- - **Dialogs** — Every dialog has `aria-modal="true"` and `aria-labelledby` pointing to its title element. Close buttons are native `<button>` elements with descriptive `aria-label` text.
1005
- - **HTML source textarea** — Has `aria-label="HTML source"` to distinguish it from the main editor.
1008
+ - **Editor region** — The content area carries role="textbox", aria-multiline="true", and an aria-label (defaults to "Rich text editor"; override with the **aria-label** or **label** attribute on the host element).
1009
+ - **Read-only state** — aria-readonly is kept in sync with the **readonly** attribute and **setReadOnly()**.
1010
+ - **Toolbar** — The toolbar container has role="toolbar" and aria-label="Formatting toolbar". Every button has an aria-label derived from its tooltip text (e.g. "Bold (Ctrl+B)") and an aria-pressed attribute that is kept in sync with the button's active/selected state.
1011
+ - **Status bar** — Carries role="status", aria-live="polite", and aria-atomic="true" so word and character count updates are announced non-intrusively by screen readers.
1012
+ - **Dialogs** — Every dialog has aria-modal="true" and aria-labelledby pointing to its title element. Close buttons are native button elements with descriptive aria-label text.
1013
+ - **HTML source textarea** — Has aria-label="HTML source" to distinguish it from the main editor.
1006
1014
 
1007
1015
  ---
1008
1016
 
1009
1017
  ## Multiple Instances
1010
1018
 
1011
- Each `<rt-native>` element is fully isolated. You can place as many on a page as needed — each gets its own unique ID, shadow root, and state.
1019
+ Each rt-native element is fully isolated. You can place as many on a page as needed — each gets its own unique ID, shadow root, and state.
1012
1020
 
1013
1021
  ```html
1014
1022
  <rt-native id="editor-1" height="200px"></rt-native>
@@ -1033,8 +1041,8 @@ Requires browsers with native support for:
1033
1041
 
1034
1042
  - [Custom Elements v1](https://caniuse.com/custom-elementsv1)
1035
1043
  - [Shadow DOM v1](https://caniuse.com/shadowdomv1)
1036
- - [`<dialog>` element](https://caniuse.com/dialog)
1044
+ - [dialog element](https://caniuse.com/dialog)
1037
1045
  - [CSS Custom Properties](https://caniuse.com/css-variables)
1038
- - [`fetch()`](https://caniuse.com/fetch) *(required for `setPreviewCssFiles()` / `setPreviewCssFile()`)*
1046
+ - [fetch()](https://caniuse.com/fetch) *(required for **setPreviewCssFiles()** / **setPreviewCssFile()**)*
1039
1047
 
1040
1048
  All modern browsers (Chrome 67+, Firefox 63+, Safari 12.1+, Edge 79+) are supported. Internet Explorer is not supported.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rt-native",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "rt-native HTML Editor is a free native web component that provides accessibility features and a wide variety of elements and customizations that make it one of the most robust and flexible HTML editors available. It allows the programmer to apply custom .css files to the preview window, so see how the content will be displayed in production. The editor uses embedded .svg Google Font Icons and the shadow DOM to isolate the HTML from inheriting the existing page styles. No frameworks, no build step, no dependencies — drop one script tag into any HTML page and you're done.",
5
5
  "main": "rt-native.js",
6
6
  "exports": {
package/rt-native.js CHANGED
@@ -5338,7 +5338,7 @@ const _RTB_SHADOW_CSS = `
5338
5338
  height: var(--rtb-editor-height, 300px);
5339
5339
  display: flex;
5340
5340
  flex-direction: column;
5341
- z-index: 1;
5341
+ z-index: var(--rtb-z-index, 1);
5342
5342
  }
5343
5343
  .rich-text-box-content-container {
5344
5344
  width: 100%;
@@ -5596,6 +5596,12 @@ const _RTB_SHADOW_CSS = `
5596
5596
  resize: both;
5597
5597
  overflow: hidden;
5598
5598
  box-sizing: border-box;
5599
+ position: fixed;
5600
+ top: 50%;
5601
+ left: 50%;
5602
+ transform: translate(-50%, -50%);
5603
+ margin: 0;
5604
+ z-index: 9999;
5599
5605
  }
5600
5606
  .rtb-preview-dialog[open] {
5601
5607
  display: flex;
@@ -5892,6 +5898,9 @@ rt-native {
5892
5898
  /* Placeholder */
5893
5899
  --rtb-placeholder-color: #9ca3af;
5894
5900
 
5901
+ /* Stacking context — raise the entire editor above surrounding content */
5902
+ --rtb-z-index: 1;
5903
+
5895
5904
  /* Modals / dialogs */
5896
5905
  --rtb-modal-bg: #ffffff;
5897
5906
  --rtb-modal-text: #242424;