Skip to content

Build your personal knowledge base with Trilium Notes

feat(math): inherit attributes from selection

Elian Doran7c30e2b4f6ed
diff --git a/packages/ckeditor5-math/src/mathcommand.ts b/packages/ckeditor5-math/src/mathcommand.ts
index 63671f4374..b6126f42f3 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 );