Skip to content

Commit

Permalink
fix(extension-table): update selection position when inserting a new …
Browse files Browse the repository at this point in the history
…table

Typically when inserting a new table we want to select within the first cell of the newly inserted
table. This change should ensure that occurs even if original selection's head precedes the anchor.

fix ueberdosis#5143
  • Loading branch information
wilson-everlaw committed May 14, 2024
1 parent ef7d195 commit 0105e9e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/extension-table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export const Table = Node.create<TableOptions>({
const node = createTable(editor.schema, rows, cols, withHeaderRow)

if (dispatch) {
const offset = tr.selection.anchor + 1
const offset = tr.selection.from + 1

tr.replaceSelectionWith(node)
.scrollIntoView()
Expand Down

0 comments on commit 0105e9e

Please sign in to comment.