Equation improvements (#7174)

This commit is contained in:
Elian Doran
2025-10-02 21:43:58 +03:00
committed by GitHub
5 changed files with 38 additions and 20 deletions

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

View File

@@ -59,12 +59,12 @@ export default class MathEditing extends Plugin {
allowWhere: '$text',
isInline: true,
isObject: true,
allowAttributes: [ 'equation', 'type', 'display' ]
allowAttributes: [ 'equation', 'type', 'display', 'fontSize', 'fontColor', 'fontBackgroundColor' ]
} );
schema.register( 'mathtex-display', {
inheritAllFrom: '$blockObject',
allowAttributes: [ 'equation', 'type', 'display' ]
allowAttributes: [ 'equation', 'type', 'display', 'fontSize', 'fontColor' ]
} );
}