fix(ckeditor/math): math can be inserted in code blocks (closes #7913)

This commit is contained in:
Elian Doran 2025-12-02 12:13:40 +02:00
parent 1a03c0ca9f
commit 5ae67fda7f
No known key found for this signature in database

View File

@ -62,6 +62,16 @@ export default class MathEditing extends Plugin {
allowAttributes: [ 'equation', 'type', 'display', 'fontSize', 'fontColor', 'fontBackgroundColor' ]
} );
// Prevent <mathtex-inline> from being inserted inside <codeBlock>
schema.addChildCheck( ( context, childDefinition ) => {
if ( childDefinition && childDefinition.name === 'mathtex-inline' ) {
// If the context is inside a codeBlock, disallow it
if ( context.endsWith( 'codeBlock' ) ) {
return false;
}
}
});
schema.register( 'mathtex-display', {
inheritAllFrom: '$blockObject',
allowAttributes: [ 'equation', 'type', 'display', 'fontSize', 'fontColor' ]