Skip to content

Commit

Permalink
fix nodepos attribute update when node is not text
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed Oct 10, 2024
1 parent 15d6cc4 commit 04f4462
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/core/src/NodePos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ export class NodePos {
}

setAttribute(attributes: { [key: string]: any }) {
const { selection } = this.editor.state
const { tr } = this.editor.state

this.editor.chain()
.setTextSelection(this.from)
.updateAttributes(this.node.type.name, attributes)
.setTextSelection(selection.from)
.run()
tr.setNodeMarkup(this.from, undefined, {
...this.node.attrs,
...attributes,
})

this.editor.view.dispatch(tr)
}
}

0 comments on commit 04f4462

Please sign in to comment.