From cd9f94924d2ea77092757a43f5925608cdfb39fe Mon Sep 17 00:00:00 2001 From: Xavier Ripoll Date: Tue, 10 Oct 2023 12:22:14 +0200 Subject: [PATCH] fix: preserve format after inline formula in CKEditor 5 --- packages/ckeditor5/src/integration.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/ckeditor5/src/integration.js b/packages/ckeditor5/src/integration.js index 98d54dd86..23ed65d12 100644 --- a/packages/ckeditor5/src/integration.js +++ b/packages/ckeditor5/src/integration.js @@ -146,9 +146,12 @@ export default class CKEditor5Integration extends IntegrationModel { // This returns the value returned by the callback function (writer => {...}) return this.editorObject.model.change((writer) => { const core = this.getCore(); + const selection = this.editorObject.model.document.selection; - const modelElementNew = writer.createElement('mathml', { formula: mathml }); - modelElementNew.data = mathml; + const modelElementNew = writer.createElement('mathml', { + formula: mathml, + ...Object.fromEntries(selection.getAttributes()), // To keep the format, such as style and font + }); // Obtain the DOM object corresponding to the formula if (core.editionProperties.isNewElement) {