Merge pull request #496 from Chrissi2812/issue-488

use last selection + 1 to set table create selection
This commit is contained in:
Philipp Kühn 2019-10-17 22:40:05 +02:00 committed by GitHub
commit 07daad1fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)