mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 19:29:02 +08:00
Merge pull request #496 from Chrissi2812/issue-488
use last selection + 1 to set table create selection
This commit is contained in:
commit
07daad1fab
@ -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