feat(math): inherit attributes from selection

This commit is contained in:
Elian Doran 2025-10-02 20:50:46 +03:00
parent d49ce7c289
commit 7c30e2b4f6
No known key found for this signature in database

View File

@ -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 );