diff --git a/packages/core/src/commands/resetNodeAttributes.ts b/packages/core/src/commands/resetNodeAttributes.ts index dbf1fc65..c7988d18 100644 --- a/packages/core/src/commands/resetNodeAttributes.ts +++ b/packages/core/src/commands/resetNodeAttributes.ts @@ -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, }) } diff --git a/packages/core/src/commands/setNodeAttributes.ts b/packages/core/src/commands/setNodeAttributes.ts index 37b6fc5d..97c9d9c4 100644 --- a/packages/core/src/commands/setNodeAttributes.ts +++ b/packages/core/src/commands/setNodeAttributes.ts @@ -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, + }) } })