diff --git a/packages/editor/src/core/extensions/table/plugins/drag-handles/column/plugin.ts b/packages/editor/src/core/extensions/table/plugins/drag-handles/column/plugin.ts index 6cefa24b6..d25591e47 100644 --- a/packages/editor/src/core/extensions/table/plugins/drag-handles/column/plugin.ts +++ b/packages/editor/src/core/extensions/table/plugins/drag-handles/column/plugin.ts @@ -14,6 +14,9 @@ import { ColumnDragHandle, ColumnDragHandleProps } from "./drag-handle"; type TableColumnDragHandlePluginState = { decorations?: DecorationSet; + // track table structure to detect changes + tableWidth?: number; + tableNodePos?: number; }; const TABLE_COLUMN_DRAG_HANDLE_PLUGIN_KEY = new PluginKey("tableColumnHandlerDecorationPlugin"); @@ -31,20 +34,33 @@ export const TableColumnDragHandlePlugin = (editor: Editor): Plugin dragHandleComponent.element)); } - return { decorations: DecorationSet.create(newState.doc, decorations) }; + return { + decorations: DecorationSet.create(newState.doc, decorations), + tableHeight: tableMap.height, + tableNodePos: table.pos, + }; }, }, props: { diff --git a/packages/editor/src/core/plugins/drag-handle.ts b/packages/editor/src/core/plugins/drag-handle.ts index 5d05f80fc..b525759d9 100644 --- a/packages/editor/src/core/plugins/drag-handle.ts +++ b/packages/editor/src/core/plugins/drag-handle.ts @@ -379,7 +379,9 @@ const handleNodeSelection = ( let draggedNodePos = nodePosAtDOM(node, view, options); if (draggedNodePos == null || draggedNodePos < 0) return; - if (node.matches("blockquote")) { + if (node.matches("table")) { + draggedNodePos = draggedNodePos - 2; + } else if (node.matches("blockquote")) { draggedNodePos = nodePosAtDOMForBlockQuotes(node, view); if (draggedNodePos === null || draggedNodePos === undefined) return; } else {