rt-native 1.0.116 → 1.0.117

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 +147 -70
  2. package/package.json +1 -1
  3. package/rt-native.js +1 -1
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
- # rt-native Native Web Component Rich Text Editor
1
+ # rt-native - Rich Text Editor
2
2
 
3
- **Author:** Ryan Kueter
4
- **Updated:** May, 2026
3
+ **Author:** Ryan Kueter | **Updated:** May, 2026
5
4
 
6
5
  **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, to 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
6
 
@@ -14,24 +13,28 @@
14
13
  3. [Quick Start](#quick-start)
15
14
  4. [HTML Attributes](#html-attributes)
16
15
  5. [JavaScript API](#javascript-api)
17
- - [getValue()](#getvalue)
18
- - [getPlainText()](#getplaintext)
19
- - [setValue()](#setvalue)
20
- - [configure()](#configure)
21
- - [setReadOnly()](#setreadonly)
22
- - [setPreviewCssFiles()](#setpreviewcssfiles)
23
- - [setPreviewCssFile()](#setpreviewcssfile)
24
- - [setPreviewCss()](#setpreviewcss)
16
+ - [getValue()](#getvalue)
17
+ - [getPlainText()](#getplaintext)
18
+ - [setValue()](#setvalue)
19
+ - [configure()](#configure)
20
+ - [setReadOnly()](#setreadonly)
21
+ - [setPreviewCssFiles()](#setpreviewcssfiles)
22
+ - [setPreviewCssFile()](#setpreviewcssfile)
23
+ - [setPreviewCss()](#setpreviewcss)
24
+ - [addCustomButton()](#addcustombutton)
25
+ - [setCustomButtons()](#setcustombuttons)
26
+ - [removeCustomButton()](#removecustombutton)
27
+ - [clearCustomButtons()](#clearcustombuttons)
25
28
  6. [Events](#events)
26
29
  7. [CSS Variables](#css-variables)
27
- - [Toolbar](#toolbar-variables)
28
- - [Buttons](#button-variables)
29
- - [Content Area](#content-area-variables)
30
- - [Editor Container](#editor-container-variables)
31
- - [Scrollbars](#scrollbar-variables)
32
- - [Blockquote](#blockquote-variables)
33
- - [Code / Pre](#code--pre-variables)
34
- - [Modals & Dialogs](#modal--dialog-variables)
30
+ - [Toolbar](#toolbar-variables)
31
+ - [Buttons](#button-variables)
32
+ - [Content Area](#content-area-variables)
33
+ - [Editor Container](#editor-container-variables)
34
+ - [Scrollbars](#scrollbar-variables)
35
+ - [Blockquote](#blockquote-variables)
36
+ - [Code / Pre](#code--pre-variables)
37
+ - [Modals & Dialogs](#modal--dialog-variables)
35
38
  8. [Theming with CSS Classes](#theming-with-css-classes)
36
39
  9. [Preview Window Styling](#preview-window-styling)
37
40
  10. [Toolbar Buttons](#toolbar-buttons)
@@ -45,7 +48,7 @@
45
48
  ## Files
46
49
 
47
50
  | File | Purpose |
48
- |---|---|
51
+ | --- | --- |
49
52
  | 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. |
50
53
 
51
54
  ---
@@ -125,7 +128,7 @@ npm install rt-native
125
128
  ## HTML Attributes
126
129
 
127
130
  | Attribute | Type | Default | Description |
128
- |---|---|---|---|
131
+ | --- | --- | --- | --- |
129
132
  | value | string | '' | Initial HTML content of the editor. |
130
133
  | width | string | 100% | Editor width. Any valid CSS value (px, %, vw, etc.). |
131
134
  | height | string | 300px | Editor height. Any valid CSS value. |
@@ -222,7 +225,7 @@ editor.configure({
222
225
  **All visibility keys:**
223
226
 
224
227
  | Key | Controls |
225
- |---|---|
228
+ | --- | --- |
226
229
  | font | Font family dropdown |
227
230
  | size | Font size dropdown |
228
231
  | format | Paragraph / heading format dropdown |
@@ -346,6 +349,58 @@ editor.setPreviewCss('');
346
349
 
347
350
  @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.
348
351
 
352
+ ### addCustomButton()
353
+
354
+ Adds a single custom button to the right end of the toolbar (after the built-in buttons). If a button with the same `id` already exists it is replaced in-place. The toolbar rebuilds automatically.
355
+
356
+ ```js
357
+ editor.addCustomButton({
358
+ id: 'my-stamp',
359
+ title: 'Insert Stamp',
360
+ svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960">
361
+ <path d="M160-120v-80h640v80H160Zm0-120v-80l320-400-320-400v-80h640v80L480-720l320 400v80H160Z"/>
362
+ </svg>`,
363
+ onClick: (event, editor) => {
364
+ editor.setValue(editor.getValue() + '<p>🔖 Stamp inserted.</p>');
365
+ }
366
+ });
367
+ ```
368
+
369
+ | Property | Type | Required | Description |
370
+ | --- | --- | --- | --- |
371
+ | id | string | yes | Unique identifier for the button. |
372
+ | title | string | — | Tooltip text and accessible label. Defaults to `id`. |
373
+ | svg | string | — | SVG markup rendered as the button icon. |
374
+ | onClick | Function \| string | — | Called when the button is clicked. A string is resolved as a dot-path on `window` (e.g. `'myApp.handleStamp'`). Receives `(event, editor, instance)`. |
375
+ | disabled | boolean | — | When `true` the button is rendered but not clickable. |
376
+
377
+ ### setCustomButtons()
378
+
379
+ Replaces **all** custom toolbar buttons at once.
380
+
381
+ ```js
382
+ editor.setCustomButtons([
383
+ { id: 'stamp', title: 'Stamp', svg: '…', onClick: handleStamp },
384
+ { id: 'sign', title: 'Sign', svg: '…', onClick: handleSign },
385
+ ]);
386
+ ```
387
+
388
+ ### removeCustomButton()
389
+
390
+ Removes the custom button with the given `id`.
391
+
392
+ ```js
393
+ editor.removeCustomButton('stamp');
394
+ ```
395
+
396
+ ### clearCustomButtons()
397
+
398
+ Removes **all** custom toolbar buttons.
399
+
400
+ ```js
401
+ editor.clearCustomButtons();
402
+ ```
403
+
349
404
  ---
350
405
 
351
406
  ## Events
@@ -362,11 +417,29 @@ editor.addEventListener('change', (event) => {
362
417
  ```
363
418
 
364
419
  | Property | Value |
365
- |---|---|
420
+ | --- | --- |
366
421
  | event.detail.value | Current editor HTML as a string |
367
422
  | event.bubbles | true |
368
423
  | event.composed | true |
369
424
 
425
+ ### custom-button-click
426
+
427
+ Fired whenever a custom toolbar button is clicked. The event **bubbles** and is **composed**.
428
+
429
+ ```js
430
+ editor.addEventListener('custom-button-click', (event) => {
431
+ console.log('Custom button clicked:', event.detail.id);
432
+ });
433
+ ```
434
+
435
+ | Property | Value |
436
+ | --- | --- |
437
+ | event.detail.id | The `id` of the button that was clicked |
438
+ | event.detail.button | The full button definition object |
439
+ | event.detail.editor | The `rt-native` element |
440
+ | event.bubbles | true |
441
+ | event.composed | true |
442
+
370
443
  ---
371
444
 
372
445
  ## CSS Variables
@@ -394,7 +467,7 @@ rt-native {
394
467
  ### Toolbar Variables
395
468
 
396
469
  | Variable | Default | Description |
397
- |---|---|---|
470
+ | --- | --- | --- |
398
471
  | --rtb-toolbar-bg | #FFF | Toolbar background color |
399
472
  | --rtb-toolbar-border-style | solid | Toolbar bottom border style |
400
473
  | --rtb-toolbar-border-width | 1px | Toolbar bottom border width |
@@ -410,7 +483,7 @@ rt-native {
410
483
  ### Button Variables
411
484
 
412
485
  | Variable | Default | Description |
413
- |---|---|---|
486
+ | --- | --- | --- |
414
487
  | --rtb-btn-text | #000 | Button icon color |
415
488
  | --rtb-btn-size | 16px | Icon size (also drives button min-height and divider height) |
416
489
  | --rtb-btn-font | Arial, sans-serif | Font for dropdown buttons |
@@ -429,7 +502,7 @@ rt-native {
429
502
  ### Content Area Variables
430
503
 
431
504
  | Variable | Default | Description |
432
- |---|---|---|
505
+ | --- | --- | --- |
433
506
  | --rtb-content-text | #000 | Editor text color |
434
507
  | --rtb-content-size | 16px | Editor font size |
435
508
  | --rtb-content-font | Arial, sans-serif | Editor font family |
@@ -442,7 +515,7 @@ rt-native {
442
515
  ### Editor Container Variables
443
516
 
444
517
  | Variable | Default | Description |
445
- |---|---|---|
518
+ | --- | --- | --- |
446
519
  | --rtb-editor-width | 100% | Maximum width of the editor |
447
520
  | --rtb-editor-height | 300px | Height of the editor |
448
521
  | --rtb-editor-border-style | solid | Outer border style |
@@ -458,7 +531,7 @@ rt-native {
458
531
  ### Scrollbar Variables
459
532
 
460
533
  | Variable | Default | Description |
461
- |---|---|---|
534
+ | --- | --- | --- |
462
535
  | --rtb-scroll-width | 10px | Scrollbar track width |
463
536
  | --rtb-scroll-opacity | 1 | Scrollbar opacity |
464
537
  | --rtb-scroll-bg | transparent | Scrollbar track background |
@@ -471,7 +544,7 @@ rt-native {
471
544
  ### Blockquote Variables
472
545
 
473
546
  | Variable | Default | Description |
474
- |---|---|---|
547
+ | --- | --- | --- |
475
548
  | --rtb-quote-bg | #f9f9f9 | Blockquote background color |
476
549
  | --rtb-quote-border-color | #ccc | Blockquote left-border color |
477
550
  | --rtb-quote-border-width | 5px | Blockquote left-border width |
@@ -481,7 +554,7 @@ rt-native {
481
554
  ### Code / Pre Variables
482
555
 
483
556
  | Variable | Default | Description |
484
- |---|---|---|
557
+ | --- | --- | --- |
485
558
  | --rtb-code-bg | #f9f9f9 | Code block background color |
486
559
  | --rtb-code-border-radius | 10px | Code block corner radius |
487
560
 
@@ -490,7 +563,7 @@ rt-native {
490
563
  ### Modal / Dialog Variables
491
564
 
492
565
  | Variable | Default | Description |
493
- |---|---|---|
566
+ | --- | --- | --- |
494
567
  | --rtb-modal-bg | #fefefe | Dialog background color |
495
568
  | --rtb-modal-text | #000 | Dialog text and close-button color |
496
569
  | --rtb-modal-text-size | 16px | Dialog font size |
@@ -529,11 +602,13 @@ rt-native.dark {
529
602
  ```
530
603
 
531
604
  **Apply via HTML:**
605
+
532
606
  ```html
533
607
  <rt-native class="dark" id="editor" height="400px"></rt-native>
534
608
  ```
535
609
 
536
610
  **Apply via JavaScript:**
611
+
537
612
  ```js
538
613
  var editor = document.getElementById("editor");
539
614
  if (editor) {
@@ -548,6 +623,7 @@ if (editor) {
548
623
  ```
549
624
 
550
625
  **Apply via media query (system dark mode):**
626
+
551
627
  ```css
552
628
  @media (prefers-color-scheme: dark) {
553
629
  rt-native {
@@ -702,6 +778,7 @@ rt-native.fluent-dark {
702
778
  ```html
703
779
  <rt-native class="fluent-dark" id="editor" height="400px"></rt-native>
704
780
  ```
781
+
705
782
  ---
706
783
 
707
784
  ## Preview Window Styling
@@ -719,7 +796,7 @@ editor.setPreviewCssFiles('my-content.css');
719
796
  Buttons appear left-to-right in the order listed. Dividers separate logical groups.
720
797
 
721
798
  | Button | Action | Shortcut |
722
- |---|---|---|
799
+ | --- | --- | --- |
723
800
  | Font | Set font family | — |
724
801
  | Size | Set font size | Ctrl+Shift+< / Ctrl+Shift+> |
725
802
  | Format | Apply block format (paragraph, headings 1–6) | Ctrl+Shift+D / Ctrl+Shift+1–6 |
@@ -753,11 +830,11 @@ Buttons appear left-to-right in the order listed. Dividers separate logical grou
753
830
  | Embed Media | Open media embed dialog (audio, PDF, iframe) | Ctrl+Shift+M |
754
831
  | Video | Open video embed dialog | Ctrl+Shift+V |
755
832
  | Insert Table | Open table dialog | Ctrl+Shift+L |
756
- | Code Block | Open code block dialog | Ctrl+Shift+* |
757
- | Horizontal Rule | Insert \<hr\> at cursor position | Ctrl+Shift+H |
833
+ | Code Block | Open code block dialog | Ctrl+Shift+\* |
834
+ | Horizontal Rule | Insert \\<hr> at cursor position | Ctrl+Shift+H |
758
835
  | Undo | Undo last action | Ctrl+Z |
759
836
  | Redo | Redo last action | Ctrl+Y |
760
- | Toggle Status Bar | Show / hide the word and character count bar | Ctrl+\ |
837
+ | Toggle Status Bar | Show / hide the word and character count bar | Ctrl+\\ |
761
838
  | Save HTML | Download editor content as an .html file | Ctrl+Shift+S |
762
839
  | HTML Source | Toggle raw HTML source view | Ctrl+Shift+A |
763
840
  | Preview | Open preview dialog | Ctrl+Shift+P |
@@ -766,49 +843,49 @@ Buttons appear left-to-right in the order listed. Dividers separate logical grou
766
843
 
767
844
  ## Keyboard Shortcuts
768
845
 
769
- 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.
846
+ 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.
770
847
 
771
848
  | Category | Action | Shortcut |
772
- |---|---|---|
849
+ | --- | --- | --- |
773
850
  | **Formatting** | Bold | Ctrl+B |
774
- | | Italic | Ctrl+I |
775
- | | Underline | Ctrl+U |
776
- | | Strikethrough | Ctrl+D |
777
- | | Subscript | Ctrl+= |
778
- | | Superscript | Ctrl+Shift++ |
851
+ | | Italic | Ctrl+I |
852
+ | | Underline | Ctrl+U |
853
+ | | Strikethrough | Ctrl+D |
854
+ | | Subscript | Ctrl+= |
855
+ | | Superscript | Ctrl+Shift++ |
779
856
  | **Color** | Text color | Ctrl+Shift+C |
780
- | | Text background color | Ctrl+Shift+B |
857
+ | | Text background color | Ctrl+Shift+B |
781
858
  | **Alignment** | Align left | Ctrl+L |
782
- | | Align center | Ctrl+E |
783
- | | Align right | Ctrl+R |
784
- | | Justify | Ctrl+J |
859
+ | | Align center | Ctrl+E |
860
+ | | Align right | Ctrl+R |
861
+ | | Justify | Ctrl+J |
785
862
  | **Editing** | Cut | Ctrl+X |
786
- | | Copy | Ctrl+C |
787
- | | Paste | Ctrl+V |
788
- | | Select all | Ctrl+A |
789
- | | Undo | Ctrl+Z |
790
- | | Redo | Ctrl+Y |
863
+ | | Copy | Ctrl+C |
864
+ | | Paste | Ctrl+V |
865
+ | | Select all | Ctrl+A |
866
+ | | Undo | Ctrl+Z |
867
+ | | Redo | Ctrl+Y |
791
868
  | **Lists** | Ordered list | Ctrl+Shift+O |
792
- | | Unordered list | Ctrl+Shift+U |
793
- | | Increase indent | Tab |
794
- | | Decrease indent | Shift+Tab |
869
+ | | Unordered list | Ctrl+Shift+U |
870
+ | | Increase indent | Tab |
871
+ | | Decrease indent | Shift+Tab |
795
872
  | **Insert** | Insert link | Ctrl+Shift+K |
796
- | | Insert image | Ctrl+Shift+I |
797
- | | Upload image | Ctrl+Shift+& |
798
- | | Block quote | Ctrl+Shift+Q |
799
- | | Video | Ctrl+Shift+V |
800
- | | Embed media | Ctrl+Shift+M |
801
- | | Insert table | Ctrl+Shift+L |
802
- | | Code block | Ctrl+Shift+* |
803
- | | Horizontal rule | Ctrl+Shift+H |
873
+ | | Insert image | Ctrl+Shift+I |
874
+ | | Upload image | Ctrl+Shift+& |
875
+ | | Block quote | Ctrl+Shift+Q |
876
+ | | Video | Ctrl+Shift+V |
877
+ | | Embed media | Ctrl+Shift+M |
878
+ | | Insert table | Ctrl+Shift+L |
879
+ | | Code block | Ctrl+Shift+\* |
880
+ | | Horizontal rule | Ctrl+Shift+H |
804
881
  | **Format** | Paragraph | Ctrl+Shift+D |
805
- | | Heading 1–6 | Ctrl+Shift+1 – Ctrl+Shift+6 |
806
- | | Increase font size | Ctrl+Shift+> |
807
- | | Decrease font size | Ctrl+Shift+< |
808
- | **View** | Toggle status bar | Ctrl+\ |
809
- | | Toggle HTML source | Ctrl+Shift+A |
810
- | | Preview | Ctrl+Shift+P |
811
- | | Save HTML | Ctrl+Shift+S |
882
+ | | Heading 1–6 | Ctrl+Shift+1 – Ctrl+Shift+6 |
883
+ | | Increase font size | Ctrl+Shift+> |
884
+ | | Decrease font size | Ctrl+Shift+< |
885
+ | **View** | Toggle status bar | Ctrl+\\ |
886
+ | | Toggle HTML source | Ctrl+Shift+A |
887
+ | | Preview | Ctrl+Shift+P |
888
+ | | Save HTML | Ctrl+Shift+S |
812
889
 
813
890
  ---
814
891
 
@@ -855,4 +932,4 @@ Requires browsers with native support for:
855
932
  - [CSS Custom Properties](https://caniuse.com/css-variables)
856
933
  - [fetch()](https://caniuse.com/fetch) *(required for **setPreviewCssFiles()** / **setPreviewCssFile()**)*
857
934
 
858
- All modern browsers (Chrome 67+, Firefox 63+, Safari 12.1+, Edge 79+) are supported. Internet Explorer is not supported.
935
+ 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.116",
3
+ "version": "1.0.117",
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": {