diff options
author | Max <max@nextcloud.com> | 2022-03-15 17:56:06 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-03-31 15:29:22 +0300 |
commit | 15480e0d41d0f5300e215ec7be75e240d1160491 (patch) | |
tree | f79ad466c7a50d85e9008bd043c927a2231e03b4 | |
parent | 244386171bb1f8acb10ab07545ab858a6c3d0ceb (diff) |
fix: use tableRole `row` for headerRow
Prosemirrors `goToNextCell` command checks for a node with tableRole `row`.
Without this the command fails.
Signed-off-by: Max <max@nextcloud.com>
-rw-r--r-- | src/nodes/Table.js | 35 | ||||
-rw-r--r-- | src/nodes/TableHeadRow.js | 2 |
2 files changed, 8 insertions, 29 deletions
diff --git a/src/nodes/Table.js b/src/nodes/Table.js index ac667eee0..d3bec5aa1 100644 --- a/src/nodes/Table.js +++ b/src/nodes/Table.js @@ -30,48 +30,27 @@ const tableCaption = Node.create({ }) -function getTableNodeTypes(schema) { - if (schema.cached.tableNodeTypes) { - return schema.cached.tableNodeTypes - } - - const roles = {} - - Object.keys(schema.nodes).forEach(type => { - const nodeType = schema.nodes[type] - - if (nodeType.spec.tableRole) { - roles[nodeType.spec.tableRole] = nodeType - } - }) - - schema.cached.tableNodeTypes = roles - - return roles -} - function createTable(schema, rowsCount, colsCount, cellContent) { - const types = getTableNodeTypes(schema) const headerCells = [] const cells = [] for (let index = 0; index < colsCount; index += 1) { - const cell = types.cell.createAndFill() + const cell = schema.nodes.tableCell.createAndFill() if (cell) { cells.push(cell) } - const headerCell = types.header_cell.createAndFill() + const headerCell = schema.nodes.tableHeader.createAndFill() if (headerCell) { headerCells.push(headerCell) } } - const headRow = types.headRow.createChecked(null, headerCells) + const headRow = schema.nodes.tableHeadRow.createChecked(null, headerCells) const rows = [] for (let index = 1; index < rowsCount; index += 1) { - rows.push(types.row.createChecked(null, cells)) + rows.push(schema.nodes.tableRow.createChecked(null, cells)) } - const head = types.head.createChecked(null, headRow) - const body = types.body.createChecked(null, rows) - return types.table.createChecked(null, [head, body]) + const head = schema.nodes.tableHead.createChecked(null, headRow) + const body = schema.nodes.tableBody.createChecked(null, rows) + return schema.nodes.table.createChecked(null, [head, body]) } export default Table.extend({ diff --git a/src/nodes/TableHeadRow.js b/src/nodes/TableHeadRow.js index a0b9fedd0..f37e5530e 100644 --- a/src/nodes/TableHeadRow.js +++ b/src/nodes/TableHeadRow.js @@ -3,7 +3,7 @@ import { Node, mergeAttributes } from '@tiptap/core' export default Node.create({ name: 'tableHeadRow', content: 'tableHeader*', - tableRole: 'headRow', + tableRole: 'row', addOptions() { return { |