reuse attrs for setNodeAttributes and resetNodeAttributes, fix #37

This commit is contained in:
Philipp Kühn
2020-11-05 14:44:14 +01:00
parent 6f3db0970f
commit a8e478abec
2 changed files with 5 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ export default (attributeNames: string[] = []): Command => ({ tr, state, dispatc
if (attribute && defaultValue !== undefined && dispatch) {
tr.setNodeMarkup(pos, undefined, {
...node.attrs,
[name]: defaultValue,
})
}

View File

@@ -6,7 +6,10 @@ export default (attributes: {}): Command => ({ tr, state, dispatch }) => {
state.doc.nodesBetween(from, to, (node, pos) => {
if (!node.type.isText && dispatch) {
tr.setNodeMarkup(pos, undefined, attributes)
tr.setNodeMarkup(pos, undefined, {
...node.attrs,
...attributes,
})
}
})