rt-native 1.0.105 → 1.0.107
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 +270 -449
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rt-native — Native Web Component Rich Text Editor
|
|
2
2
|
|
|
3
3
|
**Author:** Ryan Kueter
|
|
4
4
|
**Updated:** April, 2026
|
|
5
5
|
|
|
6
|
-
|
|
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
|
|
|
@@ -33,22 +33,12 @@
|
|
|
33
33
|
- [Code / Pre](#code--pre-variables)
|
|
34
34
|
- [Modals & Dialogs](#modal--dialog-variables)
|
|
35
35
|
8. [Theming with CSS Classes](#theming-with-css-classes)
|
|
36
|
-
9. [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- [modal](#modal-options)
|
|
43
|
-
- [quote](#quote-options)
|
|
44
|
-
- [code](#code-options)
|
|
45
|
-
- [visibility](#visibility-options)
|
|
46
|
-
10. [Preview Window Styling](#preview-window-styling)
|
|
47
|
-
11. [Toolbar Buttons](#toolbar-buttons)
|
|
48
|
-
12. [Keyboard Shortcuts](#keyboard-shortcuts)
|
|
49
|
-
13. [Accessibility](#accessibility)
|
|
50
|
-
14. [Multiple Instances](#multiple-instances)
|
|
51
|
-
15. [Browser Support](#browser-support)
|
|
36
|
+
9. [Preview Window Styling](#preview-window-styling)
|
|
37
|
+
10. [Toolbar Buttons](#toolbar-buttons)
|
|
38
|
+
11. [Keyboard Shortcuts](#keyboard-shortcuts)
|
|
39
|
+
12. [Accessibility](#accessibility)
|
|
40
|
+
13. [Multiple Instances](#multiple-instances)
|
|
41
|
+
14. [Browser Support](#browser-support)
|
|
52
42
|
|
|
53
43
|
---
|
|
54
44
|
|
|
@@ -56,7 +46,7 @@
|
|
|
56
46
|
|
|
57
47
|
| File | Purpose |
|
|
58
48
|
|---|---|
|
|
59
|
-
|
|
|
49
|
+
| 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
50
|
|
|
61
51
|
---
|
|
62
52
|
|
|
@@ -136,14 +126,14 @@ npm install rt-native
|
|
|
136
126
|
|
|
137
127
|
| Attribute | Type | Default | Description |
|
|
138
128
|
|---|---|---|---|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
129
|
+
| value | string | '' | Initial HTML content of the editor. |
|
|
130
|
+
| width | string | 100% | Editor width. Any valid CSS value (px, %, vw, etc.). |
|
|
131
|
+
| height | string | 300px | Editor height. Any valid CSS value. |
|
|
132
|
+
| placeholder | string | — | Placeholder text shown when the editor is empty. |
|
|
133
|
+
| readonly | boolean (presence) | — | Puts the editor in read-only mode. Hides the toolbar. |
|
|
134
|
+
| aria-label | string | 'Rich text editor' | Accessible name for the editor region. |
|
|
135
|
+
| label | string | — | Alternative to **aria-label** for the accessible name. |
|
|
136
|
+
| config | JSON string | — | Declarative configuration. Parsed and passed to **configure()** on connect. |
|
|
147
137
|
|
|
148
138
|
### Example
|
|
149
139
|
|
|
@@ -157,13 +147,8 @@ npm install rt-native
|
|
|
157
147
|
|
|
158
148
|
<!-- Accessible label -->
|
|
159
149
|
<rt-native aria-label="Article body"></rt-native>
|
|
160
|
-
|
|
161
|
-
<!-- Declarative config (JSON attribute) -->
|
|
162
|
-
<rt-native config='{"editor":{"height":"500px"},"visibility":{"embedMedia":false}}'></rt-native>
|
|
163
150
|
```
|
|
164
151
|
|
|
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
|
-
|
|
167
152
|
---
|
|
168
153
|
|
|
169
154
|
## JavaScript API
|
|
@@ -188,7 +173,7 @@ const text = editor.getPlainText();
|
|
|
188
173
|
|
|
189
174
|
### setValue()
|
|
190
175
|
|
|
191
|
-
Replaces the editor content with the supplied HTML string. Passing an empty string or
|
|
176
|
+
Replaces the editor content with the supplied HTML string. Passing an empty string or null clears the editor.
|
|
192
177
|
|
|
193
178
|
```js
|
|
194
179
|
editor.setValue('<h2>New content</h2><p>Paragraph text.</p>');
|
|
@@ -197,21 +182,95 @@ editor.setValue(''); // clear
|
|
|
197
182
|
|
|
198
183
|
### configure()
|
|
199
184
|
|
|
200
|
-
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
Use `clearAll: true` to hide everything first, then opt individual buttons back in.
|
|
201
188
|
|
|
202
189
|
```js
|
|
190
|
+
// Hide specific buttons
|
|
203
191
|
editor.configure({
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
visibility: {
|
|
193
|
+
embedMedia: false,
|
|
194
|
+
table: false,
|
|
195
|
+
imageUpload: false,
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Pass every key explicitly as true to restore full toolbar
|
|
200
|
+
editor.configure({
|
|
201
|
+
visibility: {
|
|
202
|
+
clearAll: true,
|
|
203
|
+
font: true, size: true, format: true, textStylesDivider: true,
|
|
204
|
+
bold: true, italic: true, underline: true, strikethrough: true,
|
|
205
|
+
subscript: true, superscript: true, formatDivider: true,
|
|
206
|
+
textColor: true, textColorDivider: true,
|
|
207
|
+
alignLeft: true, alignCenter: true, alignRight: true,
|
|
208
|
+
alignJustify: true, alignDivider: true,
|
|
209
|
+
copy: true, cut: true, paste: true, delete: true,
|
|
210
|
+
selectAll: true, actionDivider: true,
|
|
211
|
+
orderedList: true, unorderedList: true, indent: true, listDivider: true,
|
|
212
|
+
link: true, image: true, imageUpload: true,
|
|
213
|
+
quote: true, codeBlock: true, embedMedia: true,
|
|
214
|
+
table: true, horizontalRule: true, mediaDivider: true,
|
|
215
|
+
undo: true, redo: true, historyDivider: true,
|
|
216
|
+
saveHtml: true, htmlView: true, preview: true, statusBarToggle: true,
|
|
217
|
+
wordCount: true,
|
|
218
|
+
}
|
|
211
219
|
});
|
|
212
220
|
```
|
|
213
221
|
|
|
214
|
-
|
|
222
|
+
**All visibility keys:**
|
|
223
|
+
|
|
224
|
+
| Key | Controls |
|
|
225
|
+
|---|---|
|
|
226
|
+
| font | Font family dropdown |
|
|
227
|
+
| size | Font size dropdown |
|
|
228
|
+
| format | Paragraph / heading format dropdown |
|
|
229
|
+
| textStylesDivider | Divider after the three dropdowns |
|
|
230
|
+
| bold | Bold button |
|
|
231
|
+
| italic | Italic button |
|
|
232
|
+
| underline | Underline button |
|
|
233
|
+
| strikethrough | Strikethrough button |
|
|
234
|
+
| subscript | Subscript button |
|
|
235
|
+
| superscript | Superscript button |
|
|
236
|
+
| formatDivider | Divider after text-format buttons |
|
|
237
|
+
| textColor | Text color, background color, and remove-color buttons |
|
|
238
|
+
| textColorDivider | Divider after color buttons |
|
|
239
|
+
| alignLeft | Align left button |
|
|
240
|
+
| alignCenter | Align center button |
|
|
241
|
+
| alignRight | Align right button |
|
|
242
|
+
| alignJustify | Justify button |
|
|
243
|
+
| alignDivider | Divider after alignment buttons |
|
|
244
|
+
| cut | Cut button |
|
|
245
|
+
| copy | Copy button |
|
|
246
|
+
| paste | Paste button |
|
|
247
|
+
| delete | Delete button |
|
|
248
|
+
| selectAll | Select all button |
|
|
249
|
+
| actionDivider | Divider after clipboard buttons |
|
|
250
|
+
| orderedList | Ordered list button |
|
|
251
|
+
| unorderedList | Unordered list button |
|
|
252
|
+
| indent | Increase / decrease indent buttons |
|
|
253
|
+
| listDivider | Divider after list buttons |
|
|
254
|
+
| link | Insert link and remove link buttons |
|
|
255
|
+
| image | Insert image button |
|
|
256
|
+
| imageUpload | Upload / embed image button |
|
|
257
|
+
| quote | Block quote button |
|
|
258
|
+
| codeBlock | Code block button |
|
|
259
|
+
| embedMedia | Embed media (audio / PDF / iframe) button |
|
|
260
|
+
| video | Video embed button |
|
|
261
|
+
| table | Insert table button |
|
|
262
|
+
| horizontalRule | Insert horizontal rule button |
|
|
263
|
+
| mediaDivider | Divider after insert buttons |
|
|
264
|
+
| undo | Undo button |
|
|
265
|
+
| redo | Redo button |
|
|
266
|
+
| historyDivider | Divider after undo / redo |
|
|
267
|
+
| statusBarToggle | Toggle Status Bar button |
|
|
268
|
+
| saveHtml | Save HTML file button |
|
|
269
|
+
| htmlView | Toggle HTML source view button |
|
|
270
|
+
| preview | Preview button |
|
|
271
|
+
| wordCount | Status bar (word / character count) — hidden by default |
|
|
272
|
+
|
|
273
|
+
> **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.
|
|
215
274
|
|
|
216
275
|
### setReadOnly()
|
|
217
276
|
|
|
@@ -222,7 +281,7 @@ editor.setReadOnly(true); // lock
|
|
|
222
281
|
editor.setReadOnly(false); // unlock
|
|
223
282
|
```
|
|
224
283
|
|
|
225
|
-
The
|
|
284
|
+
The **readOnly** getter reflects the current state:
|
|
226
285
|
|
|
227
286
|
```js
|
|
228
287
|
if (editor.readOnly) {
|
|
@@ -230,7 +289,7 @@ if (editor.readOnly) {
|
|
|
230
289
|
}
|
|
231
290
|
```
|
|
232
291
|
|
|
233
|
-
Read-only mode can also be set declaratively via the
|
|
292
|
+
Read-only mode can also be set declaratively via the **readonly** HTML attribute:
|
|
234
293
|
|
|
235
294
|
```html
|
|
236
295
|
<rt-native readonly></rt-native>
|
|
@@ -251,11 +310,11 @@ editor.setPreviewCssFiles('/styles/my-content.css');
|
|
|
251
310
|
editor.setPreviewCssFiles();
|
|
252
311
|
```
|
|
253
312
|
|
|
254
|
-
> **CORS:** Files are loaded with
|
|
313
|
+
> **CORS:** Files are loaded with fetch(). They must be served from the same origin or include appropriate Access-Control-Allow-Origin headers.
|
|
255
314
|
|
|
256
315
|
### setPreviewCssFile()
|
|
257
316
|
|
|
258
|
-
Convenience method that sets a **single** CSS file. Equivalent to
|
|
317
|
+
Convenience method that sets a **single** CSS file. Equivalent to **setPreviewCssFiles(url)**.
|
|
259
318
|
|
|
260
319
|
```js
|
|
261
320
|
editor.setPreviewCssFile('/styles/content.css');
|
|
@@ -266,7 +325,7 @@ editor.setPreviewCssFile('');
|
|
|
266
325
|
|
|
267
326
|
### setPreviewCss()
|
|
268
327
|
|
|
269
|
-
Supplies **inline CSS** to apply to both the editor content area and the preview window. Rules are automatically scoped, exactly like
|
|
328
|
+
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
329
|
|
|
271
330
|
```js
|
|
272
331
|
editor.setPreviewCss(`
|
|
@@ -281,13 +340,13 @@ editor.setPreviewCss(`
|
|
|
281
340
|
editor.setPreviewCss('');
|
|
282
341
|
```
|
|
283
342
|
|
|
284
|
-
|
|
343
|
+
**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
344
|
|
|
286
345
|
---
|
|
287
346
|
|
|
288
347
|
## Events
|
|
289
348
|
|
|
290
|
-
###
|
|
349
|
+
### change
|
|
291
350
|
|
|
292
351
|
Fired on the element whenever the editor content changes. The event **bubbles** and is **composed** (crosses shadow DOM boundaries).
|
|
293
352
|
|
|
@@ -300,15 +359,15 @@ editor.addEventListener('change', (event) => {
|
|
|
300
359
|
|
|
301
360
|
| Property | Value |
|
|
302
361
|
|---|---|
|
|
303
|
-
|
|
|
304
|
-
|
|
|
305
|
-
|
|
|
362
|
+
| event.detail.value | Current editor HTML as a string |
|
|
363
|
+
| event.bubbles | true |
|
|
364
|
+
| event.composed | true |
|
|
306
365
|
|
|
307
366
|
---
|
|
308
367
|
|
|
309
368
|
## CSS Variables
|
|
310
369
|
|
|
311
|
-
All visual aspects of the editor are controlled through CSS custom properties declared on the
|
|
370
|
+
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
371
|
|
|
313
372
|
```css
|
|
314
373
|
/* Override globally (all editors on the page) */
|
|
@@ -332,15 +391,15 @@ rt-native {
|
|
|
332
391
|
|
|
333
392
|
| Variable | Default | Description |
|
|
334
393
|
|---|---|---|
|
|
335
|
-
|
|
|
336
|
-
|
|
|
337
|
-
|
|
|
338
|
-
|
|
|
339
|
-
|
|
|
340
|
-
|
|
|
341
|
-
|
|
|
342
|
-
|
|
|
343
|
-
|
|
|
394
|
+
| --rtb-toolbar-bg | #FFF | Toolbar background color |
|
|
395
|
+
| --rtb-toolbar-border-style | solid | Toolbar bottom border style |
|
|
396
|
+
| --rtb-toolbar-border-width | 1px | Toolbar bottom border width |
|
|
397
|
+
| --rtb-toolbar-border-color | #EEE | Toolbar bottom border color |
|
|
398
|
+
| --rtb-toolbar-border-radius | 0px | Toolbar corner radius (container clips top corners automatically) |
|
|
399
|
+
| --rtb-dropdown-bg | #FFF | Font / Size / Format dropdown background |
|
|
400
|
+
| --rtb-dropdown-text | #000 | Dropdown item text color |
|
|
401
|
+
| --rtb-dropdown-bg-hover | #e5e5e5 | Dropdown item hover background |
|
|
402
|
+
| --rtb-dropdown-text-hover | #000 | Dropdown item hover text color |
|
|
344
403
|
|
|
345
404
|
---
|
|
346
405
|
|
|
@@ -348,18 +407,18 @@ rt-native {
|
|
|
348
407
|
|
|
349
408
|
| Variable | Default | Description |
|
|
350
409
|
|---|---|---|
|
|
351
|
-
|
|
|
352
|
-
|
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
|
|
|
356
|
-
|
|
|
357
|
-
|
|
|
358
|
-
|
|
|
359
|
-
|
|
|
360
|
-
|
|
|
361
|
-
|
|
|
362
|
-
|
|
|
410
|
+
| --rtb-btn-text | #000 | Button icon color |
|
|
411
|
+
| --rtb-btn-size | 16px | Icon size (also drives button min-height and divider height) |
|
|
412
|
+
| --rtb-btn-font | Arial, sans-serif | Font for dropdown buttons |
|
|
413
|
+
| --rtb-btn-bg | inherit | Button background at rest |
|
|
414
|
+
| --rtb-btn-bg-hover | #DDD | Button background on hover |
|
|
415
|
+
| --rtb-btn-bg-selected | #CCC | Button background when active / selected |
|
|
416
|
+
| --rtb-btn-border-style | none | Button border style |
|
|
417
|
+
| --rtb-btn-border-width | 0px | Button border width |
|
|
418
|
+
| --rtb-btn-border-color | #AAA | Button border color at rest |
|
|
419
|
+
| --rtb-btn-border-hover | inherit | Button border color on hover |
|
|
420
|
+
| --rtb-btn-border-selected | inherit | Button border color when selected |
|
|
421
|
+
| --rtb-btn-border-radius | 5px | Button corner radius |
|
|
363
422
|
|
|
364
423
|
---
|
|
365
424
|
|
|
@@ -367,12 +426,12 @@ rt-native {
|
|
|
367
426
|
|
|
368
427
|
| Variable | Default | Description |
|
|
369
428
|
|---|---|---|
|
|
370
|
-
|
|
|
371
|
-
|
|
|
372
|
-
|
|
|
373
|
-
|
|
|
374
|
-
|
|
|
375
|
-
|
|
|
429
|
+
| --rtb-content-text | #000 | Editor text color |
|
|
430
|
+
| --rtb-content-size | 16px | Editor font size |
|
|
431
|
+
| --rtb-content-font | Arial, sans-serif | Editor font family |
|
|
432
|
+
| --rtb-content-bg | #FFF | Editor content background color |
|
|
433
|
+
| --rtb-content-shadow | none | Inner box shadow on the content area |
|
|
434
|
+
| --rtb-placeholder-color | #9ca3af | Placeholder text color |
|
|
376
435
|
|
|
377
436
|
---
|
|
378
437
|
|
|
@@ -380,15 +439,15 @@ rt-native {
|
|
|
380
439
|
|
|
381
440
|
| Variable | Default | Description |
|
|
382
441
|
|---|---|---|
|
|
383
|
-
|
|
|
384
|
-
|
|
|
385
|
-
|
|
|
386
|
-
|
|
|
387
|
-
|
|
|
388
|
-
|
|
|
389
|
-
|
|
|
390
|
-
|
|
|
391
|
-
|
|
|
442
|
+
| --rtb-editor-width | 100% | Maximum width of the editor |
|
|
443
|
+
| --rtb-editor-height | 300px | Height of the editor |
|
|
444
|
+
| --rtb-editor-border-style | solid | Outer border style |
|
|
445
|
+
| --rtb-editor-border-width | 1px | Outer border width |
|
|
446
|
+
| --rtb-editor-border-color | #EEE | Outer border color |
|
|
447
|
+
| --rtb-editor-border-radius | 0px | Outer corner radius |
|
|
448
|
+
| --rtb-editor-shadow | none | Outer box shadow |
|
|
449
|
+
| --rtb-editor-resize | auto | auto shows the resize handle; hidden removes it |
|
|
450
|
+
| --rtb-z-index | 1 | Z-index of the editor container — raise this to stack the editor above surrounding page content |
|
|
392
451
|
|
|
393
452
|
---
|
|
394
453
|
|
|
@@ -396,12 +455,12 @@ rt-native {
|
|
|
396
455
|
|
|
397
456
|
| Variable | Default | Description |
|
|
398
457
|
|---|---|---|
|
|
399
|
-
|
|
|
400
|
-
|
|
|
401
|
-
|
|
|
402
|
-
|
|
|
403
|
-
|
|
|
404
|
-
|
|
|
458
|
+
| --rtb-scroll-width | 10px | Scrollbar track width |
|
|
459
|
+
| --rtb-scroll-opacity | 1 | Scrollbar opacity |
|
|
460
|
+
| --rtb-scroll-bg | transparent | Scrollbar track background |
|
|
461
|
+
| --rtb-scroll-thumb-bg | #AAA | Scrollbar thumb color |
|
|
462
|
+
| --rtb-scroll-thumb-bg-hover | #DDD | Scrollbar thumb color on hover |
|
|
463
|
+
| --rtb-scroll-thumb-radius | 0 | Scrollbar thumb corner radius |
|
|
405
464
|
|
|
406
465
|
---
|
|
407
466
|
|
|
@@ -409,9 +468,9 @@ rt-native {
|
|
|
409
468
|
|
|
410
469
|
| Variable | Default | Description |
|
|
411
470
|
|---|---|---|
|
|
412
|
-
|
|
|
413
|
-
|
|
|
414
|
-
|
|
|
471
|
+
| --rtb-quote-bg | #f9f9f9 | Blockquote background color |
|
|
472
|
+
| --rtb-quote-border-color | #ccc | Blockquote left-border color |
|
|
473
|
+
| --rtb-quote-border-width | 5px | Blockquote left-border width |
|
|
415
474
|
|
|
416
475
|
---
|
|
417
476
|
|
|
@@ -419,8 +478,8 @@ rt-native {
|
|
|
419
478
|
|
|
420
479
|
| Variable | Default | Description |
|
|
421
480
|
|---|---|---|
|
|
422
|
-
|
|
|
423
|
-
|
|
|
481
|
+
| --rtb-code-bg | #f9f9f9 | Code block background color |
|
|
482
|
+
| --rtb-code-border-radius | 10px | Code block corner radius |
|
|
424
483
|
|
|
425
484
|
---
|
|
426
485
|
|
|
@@ -428,14 +487,14 @@ rt-native {
|
|
|
428
487
|
|
|
429
488
|
| Variable | Default | Description |
|
|
430
489
|
|---|---|---|
|
|
431
|
-
|
|
|
432
|
-
|
|
|
433
|
-
|
|
|
434
|
-
|
|
|
435
|
-
|
|
|
436
|
-
|
|
|
437
|
-
|
|
|
438
|
-
|
|
|
490
|
+
| --rtb-modal-bg | #fefefe | Dialog background color |
|
|
491
|
+
| --rtb-modal-text | #000 | Dialog text and close-button color |
|
|
492
|
+
| --rtb-modal-text-size | 16px | Dialog font size |
|
|
493
|
+
| --rtb-modal-text-font | Arial, sans-serif | Dialog font family |
|
|
494
|
+
| --rtb-modal-input-bg | #fff | Input field background |
|
|
495
|
+
| --rtb-modal-input-text | #000 | Input field text color |
|
|
496
|
+
| --rtb-modal-input-border | #CCC | Input field border color |
|
|
497
|
+
| --rtb-modal-checkbox | #007bff | Checkbox accent color |
|
|
439
498
|
|
|
440
499
|
---
|
|
441
500
|
|
|
@@ -467,14 +526,21 @@ rt-native.dark {
|
|
|
467
526
|
|
|
468
527
|
**Apply via HTML:**
|
|
469
528
|
```html
|
|
470
|
-
<rt-native class="dark"></rt-native>
|
|
529
|
+
<rt-native class="dark" id="editor" height="400px"></rt-native>
|
|
471
530
|
```
|
|
472
531
|
|
|
473
532
|
**Apply via JavaScript:**
|
|
474
533
|
```js
|
|
475
|
-
editor.
|
|
476
|
-
editor
|
|
477
|
-
editor.classList.
|
|
534
|
+
var editor = document.getElementById("editor");
|
|
535
|
+
if (editor) {
|
|
536
|
+
if (editor.classList.contains('light')) {
|
|
537
|
+
editor.classList.remove('light');
|
|
538
|
+
}
|
|
539
|
+
if (editor.classList.contains('dark')) {
|
|
540
|
+
editor.classList.remove('dark');
|
|
541
|
+
}
|
|
542
|
+
editor.classList.add(theme);
|
|
543
|
+
}
|
|
478
544
|
```
|
|
479
545
|
|
|
480
546
|
**Apply via media query (system dark mode):**
|
|
@@ -632,259 +698,15 @@ rt-native.fluent-dark {
|
|
|
632
698
|
```html
|
|
633
699
|
<rt-native class="fluent-dark" id="editor" height="400px"></rt-native>
|
|
634
700
|
```
|
|
635
|
-
|
|
636
|
-
---
|
|
637
|
-
|
|
638
|
-
## configure() Reference
|
|
639
|
-
|
|
640
|
-
`configure()` accepts a single options object. Every property is optional. Calling `configure()` multiple times merges with the previous state.
|
|
641
|
-
|
|
642
|
-
### toolbar options
|
|
643
|
-
|
|
644
|
-
```js
|
|
645
|
-
editor.configure({
|
|
646
|
-
toolbar: {
|
|
647
|
-
backgroundColor: '#f5f5f5',
|
|
648
|
-
borderStyle: 'solid',
|
|
649
|
-
borderWidth: '1px',
|
|
650
|
-
borderColor: '#ddd',
|
|
651
|
-
borderRadius: '4px',
|
|
652
|
-
dropdownBackgroundColor: '#fff',
|
|
653
|
-
dropdownTextColor: '#000',
|
|
654
|
-
dropdownBackgroundColorHover: '#e5e5e5',
|
|
655
|
-
dropdownTextColorHover: '#000',
|
|
656
|
-
}
|
|
657
|
-
});
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
### button options
|
|
661
|
-
|
|
662
|
-
```js
|
|
663
|
-
editor.configure({
|
|
664
|
-
button: {
|
|
665
|
-
textColor: '#333',
|
|
666
|
-
textSize: '14px',
|
|
667
|
-
textFont: 'Arial, sans-serif',
|
|
668
|
-
backgroundColor: 'transparent',
|
|
669
|
-
backgroundColorHover: '#ddd',
|
|
670
|
-
backgroundColorSelected: '#ccc',
|
|
671
|
-
borderStyle: 'solid',
|
|
672
|
-
borderWidth: '1px',
|
|
673
|
-
borderColor: '#ccc',
|
|
674
|
-
borderColorHover: '#aaa',
|
|
675
|
-
borderColorSelected: '#aaa',
|
|
676
|
-
borderRadius: '4px',
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
### content options
|
|
682
|
-
|
|
683
|
-
```js
|
|
684
|
-
editor.configure({
|
|
685
|
-
content: {
|
|
686
|
-
textColor: '#222',
|
|
687
|
-
textSize: '16px',
|
|
688
|
-
textFont: 'Georgia, serif',
|
|
689
|
-
backgroundColor: '#fff',
|
|
690
|
-
boxShadow: 'none',
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
### editor options
|
|
696
|
-
|
|
697
|
-
```js
|
|
698
|
-
editor.configure({
|
|
699
|
-
editor: {
|
|
700
|
-
width: '100%',
|
|
701
|
-
height: '500px',
|
|
702
|
-
borderStyle: 'solid',
|
|
703
|
-
borderWidth: '1px',
|
|
704
|
-
borderColor: '#ccc',
|
|
705
|
-
borderRadius: '6px',
|
|
706
|
-
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
707
|
-
removeResizeHandle: false, // true = hide the resize grip
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
### scroll options
|
|
713
|
-
|
|
714
|
-
```js
|
|
715
|
-
editor.configure({
|
|
716
|
-
scroll: {
|
|
717
|
-
width: '8px',
|
|
718
|
-
opacity: '0.8',
|
|
719
|
-
backgroundColor: 'transparent',
|
|
720
|
-
thumbBackground: '#bbb',
|
|
721
|
-
thumbBackgroundHover:'#888',
|
|
722
|
-
thumbBorderRadius: '4px',
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
### modal options
|
|
728
|
-
|
|
729
|
-
```js
|
|
730
|
-
editor.configure({
|
|
731
|
-
modal: {
|
|
732
|
-
backgroundColor: '#fff',
|
|
733
|
-
textColor: '#000',
|
|
734
|
-
textSize: '15px',
|
|
735
|
-
textFont: 'Arial, sans-serif',
|
|
736
|
-
textboxBackgroundColor: '#fafafa',
|
|
737
|
-
textboxTextColor: '#000',
|
|
738
|
-
textboxBorderColor: '#ccc',
|
|
739
|
-
checkboxAccentColor: '#0066cc',
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
```
|
|
743
|
-
|
|
744
|
-
### quote options
|
|
745
|
-
|
|
746
|
-
```js
|
|
747
|
-
editor.configure({
|
|
748
|
-
quote: {
|
|
749
|
-
backgroundColor: '#f9f9f9',
|
|
750
|
-
borderColor: '#ccc',
|
|
751
|
-
borderWidth: '5px',
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
```
|
|
755
|
-
|
|
756
|
-
### code options
|
|
757
|
-
|
|
758
|
-
```js
|
|
759
|
-
editor.configure({
|
|
760
|
-
code: {
|
|
761
|
-
backgroundColor: '#f9f9f9',
|
|
762
|
-
borderRadius: '10px',
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
```
|
|
766
|
-
|
|
767
|
-
### visibility options
|
|
768
|
-
|
|
769
|
-
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.
|
|
770
|
-
|
|
771
|
-
Use `clearAll: true` to hide everything first, then opt individual buttons back in.
|
|
772
|
-
|
|
773
|
-
```js
|
|
774
|
-
// Hide specific buttons
|
|
775
|
-
editor.configure({
|
|
776
|
-
visibility: {
|
|
777
|
-
embedMedia: false,
|
|
778
|
-
table: false,
|
|
779
|
-
imageUpload: false,
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
// Essentials-only toolbar
|
|
784
|
-
editor.configure({
|
|
785
|
-
visibility: {
|
|
786
|
-
clearAll: true, // hide all first
|
|
787
|
-
bold: true,
|
|
788
|
-
italic: true,
|
|
789
|
-
underline: true,
|
|
790
|
-
formatDivider: true,
|
|
791
|
-
alignLeft: true,
|
|
792
|
-
alignCenter: true,
|
|
793
|
-
alignRight: true,
|
|
794
|
-
alignDivider: true,
|
|
795
|
-
undo: true,
|
|
796
|
-
redo: true,
|
|
797
|
-
historyDivider:true,
|
|
798
|
-
htmlView: true,
|
|
799
|
-
preview: true,
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
```
|
|
803
|
-
|
|
804
|
-
**All visibility keys:**
|
|
805
|
-
|
|
806
|
-
| Key | Controls |
|
|
807
|
-
|---|---|
|
|
808
|
-
| `font` | Font family dropdown |
|
|
809
|
-
| `size` | Font size dropdown |
|
|
810
|
-
| `format` | Paragraph / heading format dropdown |
|
|
811
|
-
| `textStylesDivider` | Divider after the three dropdowns |
|
|
812
|
-
| `bold` | Bold button |
|
|
813
|
-
| `italic` | Italic button |
|
|
814
|
-
| `underline` | Underline button |
|
|
815
|
-
| `strikethrough` | Strikethrough button |
|
|
816
|
-
| `subscript` | Subscript button |
|
|
817
|
-
| `superscript` | Superscript button |
|
|
818
|
-
| `formatDivider` | Divider after text-format buttons |
|
|
819
|
-
| `textColor` | Text color, background color, and remove-color buttons |
|
|
820
|
-
| `textColorDivider` | Divider after color buttons |
|
|
821
|
-
| `alignLeft` | Align left button |
|
|
822
|
-
| `alignCenter` | Align center button |
|
|
823
|
-
| `alignRight` | Align right button |
|
|
824
|
-
| `alignJustify` | Justify button |
|
|
825
|
-
| `alignDivider` | Divider after alignment buttons |
|
|
826
|
-
| `cut` | Cut button |
|
|
827
|
-
| `copy` | Copy button |
|
|
828
|
-
| `paste` | Paste button |
|
|
829
|
-
| `delete` | Delete button |
|
|
830
|
-
| `selectAll` | Select all button |
|
|
831
|
-
| `actionDivider` | Divider after clipboard buttons |
|
|
832
|
-
| `orderedList` | Ordered list button |
|
|
833
|
-
| `unorderedList` | Unordered list button |
|
|
834
|
-
| `indent` | Increase / decrease indent buttons |
|
|
835
|
-
| `listDivider` | Divider after list buttons |
|
|
836
|
-
| `link` | Insert link and remove link buttons |
|
|
837
|
-
| `image` | Insert image button |
|
|
838
|
-
| `imageUpload` | Upload / embed image button |
|
|
839
|
-
| `quote` | Block quote button |
|
|
840
|
-
| `codeBlock` | Code block button |
|
|
841
|
-
| `embedMedia` | Embed media (audio / PDF / iframe) button |
|
|
842
|
-
| `video` | Video embed button |
|
|
843
|
-
| `table` | Insert table button |
|
|
844
|
-
| `horizontalRule` | Insert horizontal rule button |
|
|
845
|
-
| `mediaDivider` | Divider after insert buttons |
|
|
846
|
-
| `undo` | Undo button |
|
|
847
|
-
| `redo` | Redo button |
|
|
848
|
-
| `historyDivider` | Divider after undo / redo |
|
|
849
|
-
| `statusBarToggle` | Toggle Status Bar button |
|
|
850
|
-
| `saveHtml` | Save HTML file button |
|
|
851
|
-
| `htmlView` | Toggle HTML source view button |
|
|
852
|
-
| `preview` | Preview button |
|
|
853
|
-
| `wordCount` | Status bar (word / character count) — hidden by default |
|
|
854
|
-
|
|
855
|
-
> **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`.
|
|
856
|
-
|
|
857
701
|
---
|
|
858
702
|
|
|
859
703
|
## Preview Window Styling
|
|
860
704
|
|
|
861
|
-
When you load preview CSS with
|
|
862
|
-
|
|
863
|
-
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.
|
|
864
|
-
|
|
865
|
-
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.
|
|
705
|
+
When you load preview CSS with **setPreviewCssFiles()** or **setPreviewCss()**, the component applies the styles in two places simultaneously:
|
|
866
706
|
|
|
867
|
-
|
|
707
|
+
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.
|
|
868
708
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
```css
|
|
872
|
-
/* my-content.css */
|
|
873
|
-
p {
|
|
874
|
-
font-family: Georgia, serif;
|
|
875
|
-
line-height: 1.8;
|
|
876
|
-
margin-bottom: 1em;
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
h1, h2, h3 { color: #0a2540; }
|
|
880
|
-
|
|
881
|
-
blockquote {
|
|
882
|
-
border-left: 4px solid #0070f3;
|
|
883
|
-
background: #f0f7ff;
|
|
884
|
-
padding: 12px 20px;
|
|
885
|
-
font-style: italic;
|
|
886
|
-
}
|
|
887
|
-
```
|
|
709
|
+
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.
|
|
888
710
|
|
|
889
711
|
```js
|
|
890
712
|
editor.setPreviewCssFiles('my-content.css');
|
|
@@ -892,7 +714,7 @@ editor.setPreviewCssFiles('my-content.css');
|
|
|
892
714
|
|
|
893
715
|
### At-rules
|
|
894
716
|
|
|
895
|
-
|
|
717
|
+
@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.
|
|
896
718
|
|
|
897
719
|
---
|
|
898
720
|
|
|
@@ -903,113 +725,113 @@ Buttons appear left-to-right in the order listed. Dividers separate logical grou
|
|
|
903
725
|
| Button | Action | Shortcut |
|
|
904
726
|
|---|---|---|
|
|
905
727
|
| Font | Set font family | — |
|
|
906
|
-
| Size | Set font size |
|
|
907
|
-
| Format | Apply block format (paragraph, headings 1–6) |
|
|
908
|
-
| Bold | Bold |
|
|
909
|
-
| Italic | Italic |
|
|
910
|
-
| Underline | Underline |
|
|
911
|
-
| Strikethrough | Strikethrough |
|
|
912
|
-
| Subscript | Subscript |
|
|
913
|
-
| Superscript | Superscript |
|
|
914
|
-
| Text Color | Open text color picker |
|
|
915
|
-
| Background Color | Open text background color picker |
|
|
728
|
+
| Size | Set font size | Ctrl+Shift+< / Ctrl+Shift+> |
|
|
729
|
+
| Format | Apply block format (paragraph, headings 1–6) | Ctrl+Shift+D / Ctrl+Shift+1–6 |
|
|
730
|
+
| Bold | Bold | Ctrl+B |
|
|
731
|
+
| Italic | Italic | Ctrl+I |
|
|
732
|
+
| Underline | Underline | Ctrl+U |
|
|
733
|
+
| Strikethrough | Strikethrough | Ctrl+D |
|
|
734
|
+
| Subscript | Subscript | Ctrl+= |
|
|
735
|
+
| Superscript | Superscript | Ctrl+Shift++ |
|
|
736
|
+
| Text Color | Open text color picker | Ctrl+Shift+C |
|
|
737
|
+
| Background Color | Open text background color picker | Ctrl+Shift+B |
|
|
916
738
|
| Remove Color | Strip text and background color | — |
|
|
917
|
-
| Align Left | Left-align |
|
|
918
|
-
| Align Center | Center-align |
|
|
919
|
-
| Align Right | Right-align |
|
|
920
|
-
| Justify | Justify |
|
|
921
|
-
| Cut | Cut selection |
|
|
922
|
-
| Copy | Copy selection |
|
|
923
|
-
| Paste | Paste from clipboard |
|
|
924
|
-
| Delete | Delete selection |
|
|
925
|
-
| Select All | Select all content |
|
|
926
|
-
| Ordered List | Insert numbered list |
|
|
927
|
-
| Unordered List | Insert bulleted list |
|
|
928
|
-
| Increase Indent | Indent / promote list item |
|
|
929
|
-
| Decrease Indent | Outdent / demote list item |
|
|
930
|
-
| Insert Link | Open link dialog |
|
|
739
|
+
| Align Left | Left-align | Ctrl+L |
|
|
740
|
+
| Align Center | Center-align | Ctrl+E |
|
|
741
|
+
| Align Right | Right-align | Ctrl+R |
|
|
742
|
+
| Justify | Justify | Ctrl+J |
|
|
743
|
+
| Cut | Cut selection | Ctrl+X |
|
|
744
|
+
| Copy | Copy selection | Ctrl+C |
|
|
745
|
+
| Paste | Paste from clipboard | Ctrl+V |
|
|
746
|
+
| Delete | Delete selection | Delete |
|
|
747
|
+
| Select All | Select all content | Ctrl+A |
|
|
748
|
+
| Ordered List | Insert numbered list | Ctrl+Shift+O |
|
|
749
|
+
| Unordered List | Insert bulleted list | Ctrl+Shift+U |
|
|
750
|
+
| Increase Indent | Indent / promote list item | Tab |
|
|
751
|
+
| Decrease Indent | Outdent / demote list item | Shift+Tab |
|
|
752
|
+
| Insert Link | Open link dialog | Ctrl+Shift+K |
|
|
931
753
|
| Remove Link | Remove hyperlink | — |
|
|
932
|
-
| Insert Image | Open image URL dialog |
|
|
933
|
-
| Upload Image | Open image upload / embed dialog |
|
|
934
|
-
| Block Quote | Open block quote dialog |
|
|
935
|
-
| Embed Media | Open media embed dialog (audio, PDF, iframe) |
|
|
936
|
-
| Video | Open video embed dialog |
|
|
937
|
-
| Insert Table | Open table dialog |
|
|
938
|
-
| Code Block | Open code block dialog |
|
|
939
|
-
| Horizontal Rule | Insert
|
|
940
|
-
| Undo | Undo last action |
|
|
941
|
-
| Redo | Redo last action |
|
|
942
|
-
| Toggle Status Bar | Show / hide the word and character count bar |
|
|
943
|
-
| Save HTML | Download editor content as an
|
|
944
|
-
| HTML Source | Toggle raw HTML source view |
|
|
945
|
-
| Preview | Open preview dialog |
|
|
754
|
+
| Insert Image | Open image URL dialog | Ctrl+Shift+I |
|
|
755
|
+
| Upload Image | Open image upload / embed dialog | Ctrl+Shift+& |
|
|
756
|
+
| Block Quote | Open block quote dialog | Ctrl+Shift+Q |
|
|
757
|
+
| Embed Media | Open media embed dialog (audio, PDF, iframe) | Ctrl+Shift+M |
|
|
758
|
+
| Video | Open video embed dialog | Ctrl+Shift+V |
|
|
759
|
+
| Insert Table | Open table dialog | Ctrl+Shift+L |
|
|
760
|
+
| Code Block | Open code block dialog | Ctrl+Shift+* |
|
|
761
|
+
| Horizontal Rule | Insert \<hr\> at cursor position | Ctrl+Shift+H |
|
|
762
|
+
| Undo | Undo last action | Ctrl+Z |
|
|
763
|
+
| Redo | Redo last action | Ctrl+Y |
|
|
764
|
+
| Toggle Status Bar | Show / hide the word and character count bar | Ctrl+\ |
|
|
765
|
+
| Save HTML | Download editor content as an .html file | Ctrl+Shift+S |
|
|
766
|
+
| HTML Source | Toggle raw HTML source view | Ctrl+Shift+A |
|
|
767
|
+
| Preview | Open preview dialog | Ctrl+Shift+P |
|
|
946
768
|
|
|
947
769
|
---
|
|
948
770
|
|
|
949
771
|
## Keyboard Shortcuts
|
|
950
772
|
|
|
951
|
-
All shortcuts are active when the editor content area has focus. The
|
|
773
|
+
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.
|
|
952
774
|
|
|
953
775
|
| Category | Action | Shortcut |
|
|
954
776
|
|---|---|---|
|
|
955
|
-
| **Formatting** | Bold |
|
|
956
|
-
| | Italic |
|
|
957
|
-
| | Underline |
|
|
958
|
-
| | Strikethrough |
|
|
959
|
-
| | Subscript |
|
|
960
|
-
| | Superscript |
|
|
961
|
-
| **Color** | Text color |
|
|
962
|
-
| | Text background color |
|
|
963
|
-
| **Alignment** | Align left |
|
|
964
|
-
| | Align center |
|
|
965
|
-
| | Align right |
|
|
966
|
-
| | Justify |
|
|
967
|
-
| **Editing** | Cut |
|
|
968
|
-
| | Copy |
|
|
969
|
-
| | Paste |
|
|
970
|
-
| | Select all |
|
|
971
|
-
| | Undo |
|
|
972
|
-
| | Redo |
|
|
973
|
-
| **Lists** | Ordered list |
|
|
974
|
-
| | Unordered list |
|
|
975
|
-
| | Increase indent |
|
|
976
|
-
| | Decrease indent |
|
|
977
|
-
| **Insert** | Insert link |
|
|
978
|
-
| | Insert image |
|
|
979
|
-
| | Upload image |
|
|
980
|
-
| | Block quote |
|
|
981
|
-
| | Video |
|
|
982
|
-
| | Embed media |
|
|
983
|
-
| | Insert table |
|
|
984
|
-
| | Code block |
|
|
985
|
-
| | Horizontal rule |
|
|
986
|
-
| **Format** | Paragraph |
|
|
987
|
-
| | Heading 1–6 |
|
|
988
|
-
| | Increase font size |
|
|
989
|
-
| | Decrease font size |
|
|
990
|
-
| **View** | Toggle status bar |
|
|
991
|
-
| | Toggle HTML source |
|
|
992
|
-
| | Preview |
|
|
993
|
-
| | Save HTML |
|
|
777
|
+
| **Formatting** | Bold | Ctrl+B |
|
|
778
|
+
| | Italic | Ctrl+I |
|
|
779
|
+
| | Underline | Ctrl+U |
|
|
780
|
+
| | Strikethrough | Ctrl+D |
|
|
781
|
+
| | Subscript | Ctrl+= |
|
|
782
|
+
| | Superscript | Ctrl+Shift++ |
|
|
783
|
+
| **Color** | Text color | Ctrl+Shift+C |
|
|
784
|
+
| | Text background color | Ctrl+Shift+B |
|
|
785
|
+
| **Alignment** | Align left | Ctrl+L |
|
|
786
|
+
| | Align center | Ctrl+E |
|
|
787
|
+
| | Align right | Ctrl+R |
|
|
788
|
+
| | Justify | Ctrl+J |
|
|
789
|
+
| **Editing** | Cut | Ctrl+X |
|
|
790
|
+
| | Copy | Ctrl+C |
|
|
791
|
+
| | Paste | Ctrl+V |
|
|
792
|
+
| | Select all | Ctrl+A |
|
|
793
|
+
| | Undo | Ctrl+Z |
|
|
794
|
+
| | Redo | Ctrl+Y |
|
|
795
|
+
| **Lists** | Ordered list | Ctrl+Shift+O |
|
|
796
|
+
| | Unordered list | Ctrl+Shift+U |
|
|
797
|
+
| | Increase indent | Tab |
|
|
798
|
+
| | Decrease indent | Shift+Tab |
|
|
799
|
+
| **Insert** | Insert link | Ctrl+Shift+K |
|
|
800
|
+
| | Insert image | Ctrl+Shift+I |
|
|
801
|
+
| | Upload image | Ctrl+Shift+& |
|
|
802
|
+
| | Block quote | Ctrl+Shift+Q |
|
|
803
|
+
| | Video | Ctrl+Shift+V |
|
|
804
|
+
| | Embed media | Ctrl+Shift+M |
|
|
805
|
+
| | Insert table | Ctrl+Shift+L |
|
|
806
|
+
| | Code block | Ctrl+Shift+* |
|
|
807
|
+
| | Horizontal rule | Ctrl+Shift+H |
|
|
808
|
+
| **Format** | Paragraph | Ctrl+Shift+D |
|
|
809
|
+
| | Heading 1–6 | Ctrl+Shift+1 – Ctrl+Shift+6 |
|
|
810
|
+
| | Increase font size | Ctrl+Shift+> |
|
|
811
|
+
| | Decrease font size | Ctrl+Shift+< |
|
|
812
|
+
| **View** | Toggle status bar | Ctrl+\ |
|
|
813
|
+
| | Toggle HTML source | Ctrl+Shift+A |
|
|
814
|
+
| | Preview | Ctrl+Shift+P |
|
|
815
|
+
| | Save HTML | Ctrl+Shift+S |
|
|
994
816
|
|
|
995
817
|
---
|
|
996
818
|
|
|
997
819
|
## Accessibility
|
|
998
820
|
|
|
999
|
-
|
|
821
|
+
**rt-native** is built with WCAG 2.1 AA compliance in mind:
|
|
1000
822
|
|
|
1001
|
-
- **Editor region** — The content area carries
|
|
1002
|
-
- **Read-only state** —
|
|
1003
|
-
- **Toolbar** — The toolbar container has
|
|
1004
|
-
- **Status bar** — Carries
|
|
1005
|
-
- **Dialogs** — Every dialog has
|
|
1006
|
-
- **HTML source textarea** — Has
|
|
823
|
+
- **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).
|
|
824
|
+
- **Read-only state** — aria-readonly is kept in sync with the **readonly** attribute and **setReadOnly()**.
|
|
825
|
+
- **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.
|
|
826
|
+
- **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.
|
|
827
|
+
- **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.
|
|
828
|
+
- **HTML source textarea** — Has aria-label="HTML source" to distinguish it from the main editor.
|
|
1007
829
|
|
|
1008
830
|
---
|
|
1009
831
|
|
|
1010
832
|
## Multiple Instances
|
|
1011
833
|
|
|
1012
|
-
Each
|
|
834
|
+
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.
|
|
1013
835
|
|
|
1014
836
|
```html
|
|
1015
837
|
<rt-native id="editor-1" height="200px"></rt-native>
|
|
@@ -1022,7 +844,6 @@ Each `<rt-native>` element is fully isolated. You can place as many on a page as
|
|
|
1022
844
|
visibility: { clearAll: true, bold: true, italic: true }
|
|
1023
845
|
});
|
|
1024
846
|
document.getElementById('editor-2').setPreviewCssFiles('/styles/content.css');
|
|
1025
|
-
document.getElementById('editor-3').configure({ editor: { height: '400px' } });
|
|
1026
847
|
</script>
|
|
1027
848
|
```
|
|
1028
849
|
|
|
@@ -1034,8 +855,8 @@ Requires browsers with native support for:
|
|
|
1034
855
|
|
|
1035
856
|
- [Custom Elements v1](https://caniuse.com/custom-elementsv1)
|
|
1036
857
|
- [Shadow DOM v1](https://caniuse.com/shadowdomv1)
|
|
1037
|
-
- [
|
|
858
|
+
- [dialog element](https://caniuse.com/dialog)
|
|
1038
859
|
- [CSS Custom Properties](https://caniuse.com/css-variables)
|
|
1039
|
-
- [
|
|
860
|
+
- [fetch()](https://caniuse.com/fetch) *(required for **setPreviewCssFiles()** / **setPreviewCssFile()**)*
|
|
1040
861
|
|
|
1041
862
|
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.
|
|
3
|
+
"version": "1.0.107",
|
|
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": {
|