From 7c30e2b4f6ed36923284ceef536d55781c6d27dc Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 2 Oct 2025 20:50:46 +0300 Subject: [PATCH] feat(math): inherit attributes from selection --- packages/ckeditor5-math/src/mathcommand.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/ckeditor5-math/src/mathcommand.ts b/packages/ckeditor5-math/src/mathcommand.ts index 63671f437..b6126f42f 100644 --- a/packages/ckeditor5-math/src/mathcommand.ts +++ b/packages/ckeditor5-math/src/mathcommand.ts @@ -33,10 +33,18 @@ export default class MathCommand extends Command { { equation, type, display } ); } else { + const selection = this.editor.model.document.selection; + // Create new model element mathtex = writer.createElement( display ? 'mathtex-display' : 'mathtex-inline', - { equation, type: outputType, display } + { + // Inherit all attributes from selection (e.g. color, background color, size). + ...Object.fromEntries( selection.getAttributes() ), + equation, + type: outputType, + display, + } ); } model.insertContent( mathtex );