@mdaemon/html-editor-react 1.11.0 → 1.12.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 +57 -7
- 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.17.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 indent the paragraph in the cell. |
|
|
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
|
|
@@ -438,7 +448,7 @@ 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.
|
|
442
452
|
|
|
443
453
|
### Ordered List Numbering
|
|
444
454
|
|
|
@@ -691,7 +701,12 @@ Buttons after `||` begin collapsed behind a toggle (`...`) button.
|
|
|
691
701
|
| `undo` | Undo |
|
|
692
702
|
| `redo` | Redo |
|
|
693
703
|
| `image` | Insert image (upload or URL) |
|
|
694
|
-
| `table` | Table
|
|
704
|
+
| `table` | Table menu: Insert table size grid, Cell / Row / Column submenus, Table properties, caption and Delete table (see [Tables](#tables)) |
|
|
705
|
+
| `tableinsertdialog`, `tableprops`, `tabledelete`, `tablecellprops`, `tablerowprops`, `tablemergecells`, `tablesplitcells` | Insert table dialog, properties dialogs, delete table, merge and split cells |
|
|
706
|
+
| `tableinsertrowbefore`, `tableinsertrowafter`, `tabledeleterow`, `tableinsertcolbefore`, `tableinsertcolafter`, `tabledeletecol` | Insert and delete rows and columns |
|
|
707
|
+
| `tablecutrow`, `tablecopyrow`, `tablepasterowbefore`, `tablepasterowafter`, `tablecutcol`, `tablecopycol`, `tablepastecolbefore`, `tablepastecolafter` | Row and column clipboard |
|
|
708
|
+
| `tablecaption`, `tablerowheader`, `tablecolheader` | Toggle caption, header row, header column |
|
|
709
|
+
| `tablecellvalign`, `tablecellborderwidth`, `tablecellborderstyle`, `tablecellbackgroundcolor`, `tablecellbordercolor` | Cell vertical alignment, border and background menus and pickers |
|
|
695
710
|
| `hr` | Insert horizontal rule |
|
|
696
711
|
| `charmap` | Special character picker |
|
|
697
712
|
| `emoticons` | Emoji picker with search |
|
|
@@ -768,6 +783,41 @@ Resizing is on by default. Set `object_resizing: false` to turn it off, or pass
|
|
|
768
783
|
|
|
769
784
|
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
785
|
|
|
786
|
+
### Image Maps
|
|
787
|
+
|
|
788
|
+
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.
|
|
789
|
+
|
|
790
|
+
## Tables
|
|
791
|
+
|
|
792
|
+
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.
|
|
793
|
+
|
|
794
|
+
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.
|
|
795
|
+
|
|
796
|
+
Table commands, queries and events have no props; reach them through the editor from `onInit` or `getEditor()`:
|
|
797
|
+
|
|
798
|
+
```tsx
|
|
799
|
+
<Editor
|
|
800
|
+
config={{
|
|
801
|
+
table_toolbar: 'tableprops tabledelete | tableinsertrowafter tabledeleterow',
|
|
802
|
+
table_default_header_rows: 1,
|
|
803
|
+
contextmenu: 'table',
|
|
804
|
+
}}
|
|
805
|
+
onInit={(editor) => {
|
|
806
|
+
editor.on('tablemodified', ({ table, structure, style }) => {
|
|
807
|
+
console.log('Table changed', { structure, style });
|
|
808
|
+
});
|
|
809
|
+
}}
|
|
810
|
+
/>
|
|
811
|
+
|
|
812
|
+
// Later, from a ref
|
|
813
|
+
const editor = editorRef.current?.getEditor();
|
|
814
|
+
editor?.execCommand('mceInsertTable', false, { rows: 3, columns: 4 });
|
|
815
|
+
editor?.isTableCommandEnabled('mceTableMergeCells'); // would merging apply?
|
|
816
|
+
editor?.queryCommandValue('mceTableCellType'); // 'th', 'td', or '' outside a table
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
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.
|
|
820
|
+
|
|
771
821
|
## Localization
|
|
772
822
|
|
|
773
823
|
### Set Language at Init
|
|
@@ -846,7 +896,7 @@ setGetFileSrc((path) => `https://cdn.example.com${path}`);
|
|
|
846
896
|
| Ctrl/Cmd + Shift + Z | Redo |
|
|
847
897
|
| Ctrl/Cmd + F | Find & Replace |
|
|
848
898
|
| Ctrl + Alt + C (Cmd + Option + C on macOS) | Toggle code sample |
|
|
849
|
-
| Tab | Increase indent — nests or indents a list item, moves to the next table cell, inserts a tab in a code block, or indents the block ([details](#lists--indentation)) |
|
|
899
|
+
| Tab | Increase indent — nests or indents a list item, moves to the next table cell (unless `table_tab_navigation: false`), inserts a tab in a code block, or indents the block ([details](#lists--indentation)) |
|
|
850
900
|
| Shift + Tab | Decrease indent — un-nests a list item, moves to the previous table cell, or removes block indent ([details](#lists--indentation)) |
|
|
851
901
|
| Esc, then Tab | Move focus to the next element outside the editor (keyboard escape) |
|
|
852
902
|
| Esc, then Shift + Tab | Move focus to the previous element outside the editor |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdaemon/html-editor-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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.17.0",
|
|
60
60
|
"@tiptap/react": "^3.32.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|