Skip to content

Commit

Permalink
fix: preserve format after inline formula in CKEditor 5
Browse files Browse the repository at this point in the history
  • Loading branch information
xripoll-at-wiris authored and icaparros-at-wiris committed Oct 23, 2023
1 parent 7e8d3b5 commit bd4f06e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/ckeditor5/src/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span><img ... /></span> object corresponding to the formula
if (core.editionProperties.isNewElement) {
Expand Down

0 comments on commit bd4f06e

Please sign in to comment.