use insertContent in some extensions

This commit is contained in:
Philipp Kühn
2021-05-05 14:50:43 +02:00
parent 12b6f0e4f7
commit fda4c780d3
2 changed files with 25 additions and 26 deletions

View File

@@ -69,15 +69,11 @@ export const Image = Node.create<ImageOptions>({
addCommands() {
return {
setImage: options => ({ tr, dispatch }) => {
const { selection } = tr
const node = this.type.create(options)
if (dispatch) {
tr.replaceRangeWith(selection.from, selection.to, node)
}
return true
setImage: options => ({ commands }) => {
return commands.insertContent({
type: this.name,
attrs: options,
})
},
}
},