From 3591b5fa824303ced87d1492ad1157a0e305c90e Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Thu, 17 Oct 2019 14:15:36 +0200 Subject: [PATCH] use last selection + 1 to set table create selection --- packages/tiptap-extensions/src/nodes/Table.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/tiptap-extensions/src/nodes/Table.js b/packages/tiptap-extensions/src/nodes/Table.js index fcc8d8035..40c54a568 100644 --- a/packages/tiptap-extensions/src/nodes/Table.js +++ b/packages/tiptap-extensions/src/nodes/Table.js @@ -42,11 +42,12 @@ export default class Table extends Node { return { createTable: ({ rowsCount, colsCount, withHeaderRow }) => ( (state, dispatch) => { + const offset = state.tr.selection.anchor + 1 + const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow) const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView() + const resolvedPos = tr.doc.resolve(offset) - // get selection for first cell - const resolvedPos = tr.doc.resolve(tr.selection.anchor - nodes.content.size) tr.setSelection(TextSelection.near(resolvedPos)) dispatch(tr)