Merge pull request #496 from Chrissi2812/issue-488
use last selection + 1 to set table create selection
This commit is contained in:
@@ -42,11 +42,12 @@ export default class Table extends Node {
|
|||||||
return {
|
return {
|
||||||
createTable: ({ rowsCount, colsCount, withHeaderRow }) => (
|
createTable: ({ rowsCount, colsCount, withHeaderRow }) => (
|
||||||
(state, dispatch) => {
|
(state, dispatch) => {
|
||||||
|
const offset = state.tr.selection.anchor + 1
|
||||||
|
|
||||||
const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow)
|
const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow)
|
||||||
const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView()
|
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))
|
tr.setSelection(TextSelection.near(resolvedPos))
|
||||||
|
|
||||||
dispatch(tr)
|
dispatch(tr)
|
||||||
|
|||||||
Reference in New Issue
Block a user