diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js index 3a72be1e77c3730d05315f894139f42e27619975..8bd8ed095d3b9a3f078533df7c3d329f18359a0d 100644 --- a/editors/demo/src/Editoria/Editoria.js +++ b/editors/demo/src/Editoria/Editoria.js @@ -40,6 +40,19 @@ const Editoria = () => { } const editorRef = useRef(); + const text = `<table> + <caption>Monthly savings</caption> + <tr> + <th>Month</th> + <th>Savings</th> + </tr> + <tr> + <td>January</td> + <td>$100</td> + </tr> +</table> + `; + const EditoriaComponent = useMemo( () => ( <> @@ -50,7 +63,7 @@ const Editoria = () => { autoFocus placeholder="Type Something..." fileUpload={file => renderImage(file)} - value={demo} + value={text} // readonly layout={layout} // onChange={debounce(source => { diff --git a/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js b/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js index ce9c7f4237daf05a9d15b8f94d441c01add2e61b..c722bea85aa8bb5366a58a4b82c4861675c58827 100644 --- a/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js +++ b/wax-prosemirror-services/src/TablesService/InsertTableService/InsertTableService.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { Service } from 'wax-prosemirror-core'; import { tableNodes, goToNextCell } from '../tableSrc'; import Table from './Table'; @@ -8,7 +9,14 @@ class InsertTableService extends Service { const CreateShortCut = this.container.get('CreateShortCut'); // eslint-disable-next-line camelcase - const { table, table_row, table_cell, table_header } = tableNodes({ + const { + table, + table_row, + table_caption, + table_body, + table_cell, + table_header, + } = tableNodes({ tableGroup: 'block', cellContent: 'block+', }); @@ -17,6 +25,12 @@ class InsertTableService extends Service { createNode({ table, }); + createNode({ + table_caption, + }); + createNode({ + table_body, + }); createNode({ table_row, }); diff --git a/wax-prosemirror-services/src/TablesService/tableSrc/index.js b/wax-prosemirror-services/src/TablesService/tableSrc/index.js index e5b83c099d8a9462006fc43374b430d9b5a82ea3..ed1ddc8e6161ab6a49237f657133f926dd9a30c3 100644 --- a/wax-prosemirror-services/src/TablesService/tableSrc/index.js +++ b/wax-prosemirror-services/src/TablesService/tableSrc/index.js @@ -332,13 +332,31 @@ function tableNodes(options) { cellAttrs[prop] = { default: extraAttrs[prop].default }; return { table: { - content: 'table_row+', + content: 'table_caption? table_body*', tableRole: 'table', isolating: true, group: options.tableGroup, parseDOM: [{ tag: 'table' }], toDOM() { - return ['table', ['tbody', 0]]; + return ['table', 0]; + }, + }, + table_caption: { + content: 'block+', + tableRole: 'caption', + isolating: true, + parseDOM: [{ tag: 'caption' }], + toDOM() { + return ['caption', 0]; + }, + }, + table_body: { + content: 'table_row+', + tableRole: 'body', + isolating: true, + parseDOM: [{ tag: 'tbody' }], + toDOM() { + return ['tbody', 0]; }, }, table_row: {