mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-19 06:43:02 +08:00
use last selection + 1 to set table create selection
This commit is contained in:
parent
8cce2508a9
commit
3591b5fa82
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user