@mdaemon/html-editor-react 1.11.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ npm install @mdaemon/html-editor-react
|
|
|
19
19
|
**Peer dependencies:** `react` and `react-dom` (v18 or v19).
|
|
20
20
|
|
|
21
21
|
**TipTap:** the editor is built on TipTap 3, and this package tracks the same version the
|
|
22
|
-
engine uses — currently **3.32.0** (`@mdaemon/html-editor` `^1.
|
|
22
|
+
engine uses — currently **3.32.0** (`@mdaemon/html-editor` `^1.18.0`,
|
|
23
23
|
`@tiptap/react` `^3.32.0`). If your app depends on any `@tiptap/*` package directly, keep
|
|
24
24
|
it on that version too: ProseMirror throws at runtime if two copies of `@tiptap/core` /
|
|
25
25
|
`@tiptap/pm` end up in the bundle. If you only use `<Editor>` or `useEditor`, there is
|
|
@@ -254,7 +254,14 @@ The `config` prop (or `useEditor`'s `config` option) accepts an `EditorConfig` o
|
|
|
254
254
|
| `toolbar_narrow_breakpoint` | `number` | — | Pixel width below which the toolbar collapses into the overflow toggle. |
|
|
255
255
|
| `toolbar_priority` | `Record<string, number>` | — | Per-button overflow priority — higher values stay visible longer as the toolbar narrows. |
|
|
256
256
|
| `menubar` | `boolean` | `false` | Show a TinyMCE-style menu bar above the toolbar. |
|
|
257
|
-
| `contextmenu` | `boolean \| string` | `''` |
|
|
257
|
+
| `contextmenu` | `boolean \| string` | `''` | Right-click menu. A string naming `table` (or `true`) opens the table menu on a right-click in a table. Off by default, because it replaces the browser's menu and its spelling suggestions — see [Tables](#tables). |
|
|
258
|
+
| `table_toolbar` | `string \| false` | *(TinyMCE defaults)* | Buttons of the toolbar that floats above a table while the cursor is in it, as a toolbar string. `false` turns it off. Off by default in the basic editor. |
|
|
259
|
+
| `table_grid` | `boolean` | `true` | Insert tables from a size grid in the table menu. `false` opens the Insert table dialog instead. |
|
|
260
|
+
| `table_default_attributes` | `Record<string, string>` | `{ border: '1' }` | Attributes of a table the user inserts (`border`, `cellpadding`, `cellspacing`). |
|
|
261
|
+
| `table_default_styles` | `Record<string, string>` | `{ 'border-collapse': 'collapse', width: '100%' }` | Style of a table the user inserts. |
|
|
262
|
+
| `table_default_header_rows` | `number` | `0` | Header rows of an inserted table. |
|
|
263
|
+
| `table_default_header_cols` | `number` | `0` | Header columns of an inserted table. |
|
|
264
|
+
| `table_tab_navigation` | `boolean` | `true` | Tab and Shift+Tab move between table cells. `false` makes them work in a cell as they do outside a table: Tab types a tab at the cursor, and Shift+Tab outdents. |
|
|
258
265
|
| `quickbars_selection_toolbar` | `string` | `'bold italic \| quicklink blockquote'` | Inline floating toolbar shown over a text selection. |
|
|
259
266
|
| `quickbars_image_toolbar` | `boolean` | `false` | Inline floating toolbar shown when an image is selected. |
|
|
260
267
|
| `quickbars_insert_toolbar` | `boolean` | `false` | Inline floating toolbar shown on empty lines for quick insertion. |
|
|
@@ -287,6 +294,8 @@ The `config` prop (or `useEditor`'s `config` option) accepts an `EditorConfig` o
|
|
|
287
294
|
| `images_upload_error_message` | `(response: unknown, status: number) => string \| null \| undefined` | — | Words the message for a failed upload from the server's reply (parsed JSON body, or `null`, and the HTTP status). Return `null`/`undefined` for the editor's own translated message — see [Image Upload](#image-upload). |
|
|
288
295
|
| `setup` | `(editor) => void` | — | Pre-init callback for registering custom toolbar buttons. |
|
|
289
296
|
|
|
297
|
+
The table dialogs and pickers have further options (`table_appearance_options`, `table_advtab`, `table_row_advtab`, `table_cell_advtab`, `table_border_widths`, `table_border_styles`, `table_background_color_map`, `table_border_color_map`) — see the [engine docs](https://github.com/mdaemon-technologies/MDHTMLEditor#tables).
|
|
298
|
+
|
|
290
299
|
### Dark Theme
|
|
291
300
|
|
|
292
301
|
```tsx
|
|
@@ -329,7 +338,7 @@ Opt into the additional editing surfaces exposed by `@mdaemon/html-editor` 1.6.0
|
|
|
329
338
|
<Editor
|
|
330
339
|
config={{
|
|
331
340
|
menubar: true, // menu bar above the toolbar
|
|
332
|
-
contextmenu:
|
|
341
|
+
contextmenu: 'table', // right-click table menu in a table
|
|
333
342
|
quickbars_selection_toolbar: 'bold italic | quicklink blockquote',
|
|
334
343
|
quickbars_image_toolbar: true, // floating toolbar when an image is selected
|
|
335
344
|
elementpath: true, // breadcrumb status bar at the cursor
|
|
@@ -337,7 +346,8 @@ Opt into the additional editing surfaces exposed by `@mdaemon/html-editor` 1.6.0
|
|
|
337
346
|
/>
|
|
338
347
|
```
|
|
339
348
|
|
|
340
|
-
`contextmenu`
|
|
349
|
+
`contextmenu` replaces the browser's menu (and its spelling suggestions) only for a
|
|
350
|
+
right-click in a table; Ctrl+right-click still shows the browser's menu.
|
|
341
351
|
`quickbars_insert_toolbar` shows a floating insert toolbar on empty lines.
|
|
342
352
|
|
|
343
353
|
### Read-Only Mode
|
|
@@ -429,7 +439,7 @@ tiptap?.chain().focus().setBlockFontSize('14pt').run();
|
|
|
429
439
|
|
|
430
440
|
### Increase / Decrease Indent
|
|
431
441
|
|
|
432
|
-
The `indent` / `outdent` toolbar buttons, `execCommand('indent' | 'outdent')`, and the <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> keys all resolve to the same behavior, chosen by what is under the cursor:
|
|
442
|
+
The `indent` / `outdent` toolbar buttons, `execCommand('indent' | 'outdent')`, and the <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> keys all resolve to the same behavior, chosen by what is under the cursor (with one exception for <kbd>Tab</kbd> — see [Tab Characters](#tab-characters)):
|
|
433
443
|
|
|
434
444
|
| Context | Increase indent | Decrease indent |
|
|
435
445
|
|---------|-----------------|-----------------|
|
|
@@ -438,7 +448,15 @@ The `indent` / `outdent` toolbar buttons, `execCommand('indent' | 'outdent')`, a
|
|
|
438
448
|
| Paragraph, heading | Adds a `margin-left` in 40px steps (max 400px) | Removes one step |
|
|
439
449
|
| Code block | Inserts a literal tab | Nothing |
|
|
440
450
|
|
|
441
|
-
Inside a list the indent is written to the `<li>` rather than to the paragraph inside it, so the bullet or number moves with the text. Because it is an inline `margin-left`, it survives in the exported HTML — in a mail client, say — without the editor's stylesheet. In a table, <kbd>Tab</kbd> still moves between cells; the toolbar buttons indent the paragraph in the cell.
|
|
451
|
+
Inside a list the indent is written to the `<li>` rather than to the paragraph inside it, so the bullet or number moves with the text. Because it is an inline `margin-left`, it survives in the exported HTML — in a mail client, say — without the editor's stylesheet. In a table, <kbd>Tab</kbd> still moves between cells (unless `table_tab_navigation: false`); the toolbar buttons indent the paragraph in the cell.
|
|
452
|
+
|
|
453
|
+
<kbd>Backspace</kbd> at the start of an indented paragraph or heading removes one indent step, instead of joining the line to the one above. An empty line is still removed in one press.
|
|
454
|
+
|
|
455
|
+
### Tab Characters
|
|
456
|
+
|
|
457
|
+
In a paragraph or heading, <kbd>Tab</kbd> with nothing selected types a tab at the cursor, wherever it is in the line, as a word processor does. To indent the whole paragraph, select text in it first, or use the `indent` button. In a list, a code block or a table, <kbd>Tab</kbd> works as described above; with `table_tab_navigation: false`, <kbd>Tab</kbd> in a cell types a tab too.
|
|
458
|
+
|
|
459
|
+
A tab is written as `<span style="white-space: pre;">	</span>`, the form other editors use, so it keeps its tab stops in exported HTML instead of collapsing to a space. `setContent()`, `insertContent()` and paste read that span back as a tab, as well as tabs in `white-space: pre-wrap` text (as Google Docs writes) and in pasted plain text. A tab is one character: one <kbd>Backspace</kbd> or <kbd>Delete</kbd> removes it, and one undo takes it back. See the [engine docs](https://github.com/mdaemon-technologies/MDHTMLEditor#tab-characters) for the details.
|
|
442
460
|
|
|
443
461
|
### Ordered List Numbering
|
|
444
462
|
|
|
@@ -691,10 +709,15 @@ Buttons after `||` begin collapsed behind a toggle (`...`) button.
|
|
|
691
709
|
| `undo` | Undo |
|
|
692
710
|
| `redo` | Redo |
|
|
693
711
|
| `image` | Insert image (upload or URL) |
|
|
694
|
-
| `table` | Table
|
|
712
|
+
| `table` | Table menu: Insert table size grid, Cell / Row / Column submenus, Table properties, caption and Delete table (see [Tables](#tables)) |
|
|
713
|
+
| `tableinsertdialog`, `tableprops`, `tabledelete`, `tablecellprops`, `tablerowprops`, `tablemergecells`, `tablesplitcells` | Insert table dialog, properties dialogs, delete table, merge and split cells |
|
|
714
|
+
| `tableinsertrowbefore`, `tableinsertrowafter`, `tabledeleterow`, `tableinsertcolbefore`, `tableinsertcolafter`, `tabledeletecol` | Insert and delete rows and columns |
|
|
715
|
+
| `tablecutrow`, `tablecopyrow`, `tablepasterowbefore`, `tablepasterowafter`, `tablecutcol`, `tablecopycol`, `tablepastecolbefore`, `tablepastecolafter` | Row and column clipboard |
|
|
716
|
+
| `tablecaption`, `tablerowheader`, `tablecolheader` | Toggle caption, header row, header column |
|
|
717
|
+
| `tablecellvalign`, `tablecellborderwidth`, `tablecellborderstyle`, `tablecellbackgroundcolor`, `tablecellbordercolor` | Cell vertical alignment, border and background menus and pickers |
|
|
695
718
|
| `hr` | Insert horizontal rule |
|
|
696
719
|
| `charmap` | Special character picker |
|
|
697
|
-
| `emoticons` | Emoji picker with
|
|
720
|
+
| `emoticons` | Emoji picker, searchable by English name and keywords, with each emoji's name as its tooltip |
|
|
698
721
|
| `code` | Open HTML source code editor dialog |
|
|
699
722
|
| `link` | Insert/edit hyperlink (with the caret on a link, edits that link in place) |
|
|
700
723
|
| `unlink` | Remove the link at the cursor |
|
|
@@ -768,6 +791,41 @@ Resizing is on by default. Set `object_resizing: false` to turn it off, or pass
|
|
|
768
791
|
|
|
769
792
|
Images are inline, as in TinyMCE and mail HTML: a link around an image is kept, and an `<img>` that is not already in a line of text is put in a `<p>` (or a `<div>` with `forced_root_block: 'div'`).
|
|
770
793
|
|
|
794
|
+
### Image Maps
|
|
795
|
+
|
|
796
|
+
In the full editor, an `<img usemap="#name">` and its `<map name="name">` with the `<area>` hotspots are kept through loading, `insertContent()`, paste and the Source view, with their values checked (an area `href` gets the same check as a link's). While editing, a map is shown as a small marker and its hotspots do nothing; they work in the saved HTML. Maps have no toolbar button — edit them in the Source view. An image with a map has no resize handles. The basic editor has no images, so it drops maps. See the [engine docs](https://github.com/mdaemon-technologies/MDHTMLEditor#image-maps) for what is kept.
|
|
797
|
+
|
|
798
|
+
## Tables
|
|
799
|
+
|
|
800
|
+
Table editing follows TinyMCE's table plugin. The `table` toolbar button opens the table menu: Insert table (a 10×10 size grid, or a dialog with `table_grid: false`), Cell, Row and Column submenus, Table properties, Toggle caption and Delete table. The [table buttons](#available-toolbar-buttons) can also go in the `toolbar` string. While the cursor is in a table, a context toolbar floats above it (`table_toolbar`), and `contextmenu: 'table'` adds a right-click table menu.
|
|
801
|
+
|
|
802
|
+
A new table is inserted with `border="1"` and `border-collapse: collapse; width: 100%`, so its borders show in mail clients, and with no header row unless `table_default_header_rows` / `table_default_header_cols` ask for one. Tables keep their borders, padding, spacing, sizes, alignment, backgrounds and caption in `getContent()`, including the legacy `bgcolor`, `valign`, `width`, `height` and `align` attributes common in email.
|
|
803
|
+
|
|
804
|
+
Table commands, queries and events have no props; reach them through the editor from `onInit` or `getEditor()`:
|
|
805
|
+
|
|
806
|
+
```tsx
|
|
807
|
+
<Editor
|
|
808
|
+
config={{
|
|
809
|
+
table_toolbar: 'tableprops tabledelete | tableinsertrowafter tabledeleterow',
|
|
810
|
+
table_default_header_rows: 1,
|
|
811
|
+
contextmenu: 'table',
|
|
812
|
+
}}
|
|
813
|
+
onInit={(editor) => {
|
|
814
|
+
editor.on('tablemodified', ({ table, structure, style }) => {
|
|
815
|
+
console.log('Table changed', { structure, style });
|
|
816
|
+
});
|
|
817
|
+
}}
|
|
818
|
+
/>
|
|
819
|
+
|
|
820
|
+
// Later, from a ref
|
|
821
|
+
const editor = editorRef.current?.getEditor();
|
|
822
|
+
editor?.execCommand('mceInsertTable', false, { rows: 3, columns: 4 });
|
|
823
|
+
editor?.isTableCommandEnabled('mceTableMergeCells'); // would merging apply?
|
|
824
|
+
editor?.queryCommandValue('mceTableCellType'); // 'th', 'td', or '' outside a table
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
A table command returns `false` when it did not apply (outside a table, read-only, or nothing to do). See the [engine docs](https://github.com/mdaemon-technologies/MDHTMLEditor#tables) for every command, dialog, and the formatting a table keeps.
|
|
828
|
+
|
|
771
829
|
## Localization
|
|
772
830
|
|
|
773
831
|
### Set Language at Init
|
|
@@ -846,12 +904,13 @@ setGetFileSrc((path) => `https://cdn.example.com${path}`);
|
|
|
846
904
|
| Ctrl/Cmd + Shift + Z | Redo |
|
|
847
905
|
| Ctrl/Cmd + F | Find & Replace |
|
|
848
906
|
| Ctrl + Alt + C (Cmd + Option + C on macOS) | Toggle code sample |
|
|
849
|
-
| Tab |
|
|
907
|
+
| Tab | Types a tab at the cursor in a paragraph or heading ([details](#tab-characters)), indents the selected paragraphs when there is a selection, nests or indents a list item, inserts a tab in a code block, or moves to the next table cell (unless `table_tab_navigation: false`) ([details](#lists--indentation)) |
|
|
850
908
|
| Shift + Tab | Decrease indent — un-nests a list item, moves to the previous table cell, or removes block indent ([details](#lists--indentation)) |
|
|
909
|
+
| Backspace | Removes a tab in one press. At the start of an indented paragraph or heading, removes one indent step |
|
|
851
910
|
| Esc, then Tab | Move focus to the next element outside the editor (keyboard escape) |
|
|
852
911
|
| Esc, then Shift + Tab | Move focus to the previous element outside the editor |
|
|
853
912
|
|
|
854
|
-
> `Tab` is captured
|
|
913
|
+
> `Tab` is captured by the editor, so the `Esc`-then-`Tab` sequence provides a
|
|
855
914
|
> keyboard escape (WCAG 2.1.2, "No Keyboard Trap"). `Esc` arms the escape for a single
|
|
856
915
|
> key press; any other key disarms it.
|
|
857
916
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdaemon/html-editor-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "React wrapper for MDHTMLEditor",
|
|
5
5
|
"homepage": "https://github.com/mdaemon-technologies/MDHTMLEditor-react",
|
|
6
6
|
"repository": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-dom": "^19.0.0 || ^18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@mdaemon/html-editor": "^1.
|
|
59
|
+
"@mdaemon/html-editor": "^1.18.0",
|
|
60
60
|
"@tiptap/react": "^3.32.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|