Skip to content

Commit ea08d63

Browse files
authored
Merge pull request #513 from Harbour-Enterprises/artem-HAR-9663
HAR-9663 - add zero width text when create a table
2 parents 36f461e + a8c23df commit ea08d63

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • packages/super-editor/src/extensions/table

packages/super-editor/src/extensions/table/table.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { createCellBorders } from '../table-cell/helpers/createCellBorders.js';
1313
import { findParentNode } from '@helpers/findParentNode.js';
1414
import { TextSelection } from 'prosemirror-state';
1515
import { getFieldAttrs } from '@helpers/annotator.js';
16+
import { getNodeType } from '@core/helpers/getNodeType.js';
1617
import {
1718
addColumnBefore,
1819
addColumnAfter,
@@ -151,7 +152,9 @@ export const Table = Node.create({
151152
return {
152153
insertTable:
153154
({ rows = 3, cols = 3, withHeaderRow = false } = {}) => ({ tr, dispatch, editor }) => {
154-
const node = createTable(editor.schema, rows, cols, withHeaderRow);
155+
const zeroWidthText = editor.schema.text('\u200B');
156+
const emptyPar = getNodeType('paragraph', editor.schema).create(null, zeroWidthText);
157+
const node = createTable(editor.schema, rows, cols, withHeaderRow, emptyPar);
155158

156159
if (dispatch) {
157160
const offset = tr.selection.from + 1;

0 commit comments

Comments
 (0)