diff --git a/packages/ckeditor5-math/src/mathcommand.ts b/packages/ckeditor5-math/src/mathcommand.ts index b6126f42f..e91350e1f 100644 --- a/packages/ckeditor5-math/src/mathcommand.ts +++ b/packages/ckeditor5-math/src/mathcommand.ts @@ -30,7 +30,12 @@ export default class MathCommand extends Command { mathtex = writer.createElement( display ? 'mathtex-display' : 'mathtex-inline', - { equation, type, display } + { + ...Object.fromEntries(selection.getAttributes()), + equation, + type, + display + } ); } else { const selection = this.editor.model.document.selection; @@ -40,7 +45,7 @@ export default class MathCommand extends Command { display ? 'mathtex-display' : 'mathtex-inline', { // Inherit all attributes from selection (e.g. color, background color, size). - ...Object.fromEntries( selection.getAttributes() ), + ...Object.fromEntries(selection.getAttributes()), equation, type: outputType, display,