@wiris/mathtype-ckeditor5 8.9.1 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/plugin.js CHANGED
@@ -1,33 +1,29 @@
1
1
  // CKEditor imports
2
- import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
3
- import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
4
- import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';
5
- import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
6
- import XmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/xmldataprocessor';
7
- import UpcastWriter from '@ckeditor/ckeditor5-engine/src/view/upcastwriter';
8
- import { toWidget, viewToModelPositionOutsideModelElement } from '@ckeditor/ckeditor5-widget/src/utils';
9
- import Widget from '@ckeditor/ckeditor5-widget/src/widget';
2
+ import { Plugin } from 'ckeditor5/src/core.js';
3
+ import { ButtonView } from 'ckeditor5/src/ui.js';
4
+ import { ClickObserver, HtmlDataProcessor, XmlDataProcessor, UpcastWriter } from 'ckeditor5/src/engine.js';
5
+ import { Widget, toWidget, viewToModelPositionOutsideModelElement } from 'ckeditor5/src/widget.js';
10
6
 
11
7
  // MathType API imports
12
- import IntegrationModel from '@wiris/mathtype-html-integration-devkit/src/integrationmodel';
13
- import Core from '@wiris/mathtype-html-integration-devkit/src/core.src';
14
- import Parser from '@wiris/mathtype-html-integration-devkit/src/parser';
15
- import Util from '@wiris/mathtype-html-integration-devkit/src/util';
16
- import Image from '@wiris/mathtype-html-integration-devkit/src/image';
17
- import Configuration from '@wiris/mathtype-html-integration-devkit/src/configuration';
18
- import Listeners from '@wiris/mathtype-html-integration-devkit/src/listeners';
19
- import MathML from '@wiris/mathtype-html-integration-devkit/src/mathml';
20
- import Latex from '@wiris/mathtype-html-integration-devkit/src/latex';
21
- import StringManager from '@wiris/mathtype-html-integration-devkit/src/stringmanager';
8
+ import IntegrationModel from "@wiris/mathtype-html-integration-devkit/src/integrationmodel.js";
9
+ import Core from "@wiris/mathtype-html-integration-devkit/src/core.src.js";
10
+ import Parser from "@wiris/mathtype-html-integration-devkit/src/parser.js";
11
+ import Util from "@wiris/mathtype-html-integration-devkit/src/util.js";
12
+ import Image from "@wiris/mathtype-html-integration-devkit/src/image.js";
13
+ import Configuration from "@wiris/mathtype-html-integration-devkit/src/configuration.js";
14
+ import Listeners from "@wiris/mathtype-html-integration-devkit/src/listeners.js";
15
+ import MathML from "@wiris/mathtype-html-integration-devkit/src/mathml.js";
16
+ import Latex from "@wiris/mathtype-html-integration-devkit/src/latex.js";
17
+ import StringManager from "@wiris/mathtype-html-integration-devkit/src/stringmanager.js";
22
18
 
23
19
  // Local imports
24
- import { MathTypeCommand, ChemTypeCommand } from './commands';
25
- import CKEditor5Integration from './integration';
20
+ import { MathTypeCommand, ChemTypeCommand } from "./commands.js";
21
+ import CKEditor5Integration from "./integration.js";
26
22
 
27
- import mathIcon from '../theme/icons/ckeditor5-formula.svg';
28
- import chemIcon from '../theme/icons/ckeditor5-chem.svg';
23
+ import mathIcon from "../theme/icons/ckeditor5-formula.svg";
24
+ import chemIcon from "../theme/icons/ckeditor5-chem.svg";
29
25
 
30
- import packageInfo from '../package.json';
26
+ import packageInfo from "../package.json";
31
27
 
32
28
  export let currentInstance = null; // eslint-disable-line import/no-mutable-exports
33
29
 
@@ -37,7 +33,7 @@ export default class MathType extends Plugin {
37
33
  }
38
34
 
39
35
  static get pluginName() {
40
- return 'MathType';
36
+ return "MathType";
41
37
  }
42
38
 
43
39
  init() {
@@ -64,14 +60,15 @@ export default class MathType extends Plugin {
64
60
  /**
65
61
  * Inherited from Plugin class: Executed when CKEditor5 is destroyed
66
62
  */
67
- destroy() { // eslint-disable-line class-methods-use-this
63
+ destroy() {
64
+ // eslint-disable-line class-methods-use-this
68
65
  currentInstance.destroy();
69
66
  }
70
67
 
71
68
  /**
72
- * Create the MathType API Integration object
73
- * @returns {CKEditor5Integration} the integration object
74
- */
69
+ * Create the MathType API Integration object
70
+ * @returns {CKEditor5Integration} the integration object
71
+ */
75
72
  _addIntegration() {
76
73
  const { editor } = this;
77
74
 
@@ -81,15 +78,15 @@ export default class MathType extends Plugin {
81
78
  */
82
79
  const integrationProperties = {};
83
80
  integrationProperties.environment = {};
84
- integrationProperties.environment.editor = 'CKEditor5';
85
- integrationProperties.environment.editorVersion = '5.x';
81
+ integrationProperties.environment.editor = "CKEditor5";
82
+ integrationProperties.environment.editorVersion = "5.x";
86
83
  integrationProperties.version = packageInfo.version;
87
84
  integrationProperties.editorObject = editor;
88
85
  integrationProperties.serviceProviderProperties = {};
89
- integrationProperties.serviceProviderProperties.URI = 'https://www.wiris.net/demo/plugins/app';
90
- integrationProperties.serviceProviderProperties.server = 'java';
86
+ integrationProperties.serviceProviderProperties.URI = "https://www.wiris.net/demo/plugins/app";
87
+ integrationProperties.serviceProviderProperties.server = "java";
91
88
  integrationProperties.target = editor.sourceElement;
92
- integrationProperties.scriptName = 'bundle.js';
89
+ integrationProperties.scriptName = "bundle.js";
93
90
  integrationProperties.managesLanguage = true;
94
91
  // etc
95
92
 
@@ -100,59 +97,64 @@ export default class MathType extends Plugin {
100
97
  // Instance of the integration associated to this editor instance
101
98
  integration = new CKEditor5Integration(integrationProperties);
102
99
  integration.init();
103
- integration.listeners.fire('onTargetReady', {});
100
+ integration.listeners.fire("onTargetReady", {});
104
101
 
105
102
  integration.checkElement();
106
103
 
107
- this.listenTo(editor.editing.view.document, 'click', (evt, data) => {
108
- // Is Double-click
109
- if (data.domEvent.detail === 2) {
110
- integration.doubleClickHandler(data.domTarget, data.domEvent);
111
- evt.stop();
112
- }
113
- }, { priority: 'highest' });
104
+ this.listenTo(
105
+ editor.editing.view.document,
106
+ "click",
107
+ (evt, data) => {
108
+ // Is Double-click
109
+ if (data.domEvent.detail === 2) {
110
+ integration.doubleClickHandler(data.domTarget, data.domEvent);
111
+ evt.stop();
112
+ }
113
+ },
114
+ { priority: "highest" },
115
+ );
114
116
  }
115
117
 
116
118
  return integration;
117
119
  }
118
120
 
119
121
  /**
120
- * Add the MathType and ChemType commands to the editor
121
- */
122
+ * Add the MathType and ChemType commands to the editor
123
+ */
122
124
  _addCommands() {
123
125
  const { editor } = this;
124
126
 
125
127
  // Add command to open the formula editor
126
- editor.commands.add('MathType', new MathTypeCommand(editor));
128
+ editor.commands.add("MathType", new MathTypeCommand(editor));
127
129
 
128
130
  // Add command to open the chemistry formula editor
129
- editor.commands.add('ChemType', new ChemTypeCommand(editor));
131
+ editor.commands.add("ChemType", new ChemTypeCommand(editor));
130
132
  }
131
133
 
132
134
  /**
133
- * Add the buttons for MathType and ChemType
134
- * @param {CKEditor5Integration} integration the integration object
135
- */
135
+ * Add the buttons for MathType and ChemType
136
+ * @param {CKEditor5Integration} integration the integration object
137
+ */
136
138
  _addViews(integration) {
137
139
  const { editor } = this;
138
140
 
139
141
  // Check if MathType editor is enabled
140
- if (Configuration.get('editorEnabled')) {
142
+ if (Configuration.get("editorEnabled")) {
141
143
  // Add button for the formula editor
142
- editor.ui.componentFactory.add('MathType', (locale) => {
144
+ editor.ui.componentFactory.add("MathType", (locale) => {
143
145
  const view = new ButtonView(locale);
144
146
 
145
147
  // View is enabled iff command is enabled
146
- view.bind('isEnabled').to(editor.commands.get('MathType'), 'isEnabled');
148
+ view.bind("isEnabled").to(editor.commands.get("MathType"), "isEnabled");
147
149
  view.set({
148
- label: StringManager.get('insert_math', integration.getLanguage()),
150
+ label: StringManager.get("insert_math", integration.getLanguage()),
149
151
  icon: mathIcon,
150
152
  tooltip: true,
151
153
  });
152
154
 
153
155
  // Callback executed once the image is clicked.
154
- view.on('execute', () => {
155
- editor.execute('MathType', {
156
+ view.on("execute", () => {
157
+ editor.execute("MathType", {
156
158
  integration, // Pass integration as parameter
157
159
  });
158
160
  });
@@ -162,23 +164,23 @@ export default class MathType extends Plugin {
162
164
  }
163
165
 
164
166
  // Check if ChemType editor is enabled
165
- if (Configuration.get('chemEnabled')) {
167
+ if (Configuration.get("chemEnabled")) {
166
168
  // Add button for the chemistry formula editor
167
- editor.ui.componentFactory.add('ChemType', (locale) => {
169
+ editor.ui.componentFactory.add("ChemType", (locale) => {
168
170
  const view = new ButtonView(locale);
169
171
 
170
172
  // View is enabled iff command is enabled
171
- view.bind('isEnabled').to(editor.commands.get('ChemType'), 'isEnabled');
173
+ view.bind("isEnabled").to(editor.commands.get("ChemType"), "isEnabled");
172
174
 
173
175
  view.set({
174
- label: StringManager.get('insert_chem', integration.getLanguage()),
176
+ label: StringManager.get("insert_chem", integration.getLanguage()),
175
177
  icon: chemIcon,
176
178
  tooltip: true,
177
179
  });
178
180
 
179
181
  // Callback executed once the image is clicked.
180
- view.on('execute', () => {
181
- editor.execute('ChemType', {
182
+ view.on("execute", () => {
183
+ editor.execute("ChemType", {
182
184
  integration, // Pass integration as parameter
183
185
  });
184
186
  });
@@ -192,39 +194,39 @@ export default class MathType extends Plugin {
192
194
  }
193
195
 
194
196
  /**
195
- * Registers the <mathml> element in the schema
196
- */
197
+ * Registers the <mathml> element in the schema
198
+ */
197
199
  _addSchema() {
198
200
  const { schema } = this.editor.model;
199
201
 
200
- schema.register('mathml', {
201
- inheritAllFrom: '$inlineObject',
202
- allowAttributes: ['formula'],
202
+ schema.register("mathml", {
203
+ inheritAllFrom: "$inlineObject",
204
+ allowAttributes: ["formula"],
203
205
  });
204
206
  }
205
207
 
206
208
  /**
207
- * Add the downcast and upcast converters
208
- */
209
+ * Add the downcast and upcast converters
210
+ */
209
211
  _addConverters(integration) {
210
212
  const { editor } = this;
211
213
 
212
214
  // Editing view -> Model
213
- editor.conversion.for('upcast').elementToElement({
215
+ editor.conversion.for("upcast").elementToElement({
214
216
  view: {
215
- name: 'span',
216
- classes: 'ck-math-widget',
217
+ name: "span",
218
+ classes: "ck-math-widget",
217
219
  },
218
220
  model: (viewElement, { writer: modelWriter }) => {
219
- const formula = MathML.safeXmlDecode(viewElement.getChild(0).getAttribute('data-mathml'));
220
- return modelWriter.createElement('mathml', {
221
+ const formula = MathML.safeXmlDecode(viewElement.getChild(0).getAttribute("data-mathml"));
222
+ return modelWriter.createElement("mathml", {
221
223
  formula,
222
224
  });
223
225
  },
224
226
  });
225
227
 
226
228
  // Data view -> Model
227
- editor.data.upcastDispatcher.on('element:math', (evt, data, conversionApi) => {
229
+ editor.data.upcastDispatcher.on("element:math", (evt, data, conversionApi) => {
228
230
  const { consumable, writer } = conversionApi;
229
231
  const { viewItem } = data;
230
232
 
@@ -246,28 +248,23 @@ export default class MathType extends Plugin {
246
248
  const viewDocumentFragment = upcastWriter.createDocumentFragment(viewItem.getChildren());
247
249
 
248
250
  // and obtain the attributes of <math> too!
249
- const mathAttributes = [...viewItem.getAttributes()]
250
- .map(([key, value]) => ` ${key}="${value}"`)
251
- .join('');
251
+ const mathAttributes = [...viewItem.getAttributes()].map(([key, value]) => ` ${key}="${value}"`).join("");
252
252
 
253
253
  // We process the document fragment
254
- let formula = processor.toData(viewDocumentFragment) || '';
254
+ let formula = processor.toData(viewDocumentFragment) || "";
255
255
 
256
256
  // And obtain the complete formula
257
257
  formula = Util.htmlSanitize(`<math${mathAttributes}>${formula}</math>`);
258
258
 
259
259
  // Replaces the < & > characters to its HTMLEntity to avoid render issues.
260
- formula = formula.replaceAll('"<"', '"&lt;"')
261
- .replaceAll('">"', '"&gt;"')
262
- .replaceAll('><<', '>&lt;<');
263
-
260
+ formula = formula.replaceAll('"<"', '"&lt;"').replaceAll('">"', '"&gt;"').replaceAll("><<", ">&lt;<");
264
261
 
265
262
  /* Model node that contains what's going to actually be inserted. This can be either:
266
263
  - A <mathml> element with a formula attribute set to the given formula, or
267
264
  - If the original <math> had a LaTeX annotation, then the annotation surrounded by "$$...$$" */
268
265
  const modelNode = isLatex
269
266
  ? writer.createText(Parser.initParse(formula, integration.getLanguage()))
270
- : writer.createElement('mathml', { formula });
267
+ : writer.createElement("mathml", { formula });
271
268
 
272
269
  // Find allowed parent for element that we are going to insert.
273
270
  // If current parent does not allow to insert element but one of the ancestors does
@@ -308,15 +305,15 @@ export default class MathType extends Plugin {
308
305
  });
309
306
 
310
307
  /**
311
- * Whether the given view <math> element has a LaTeX annotation element.
312
- * @param {*} math
313
- * @returns {bool}
314
- */
308
+ * Whether the given view <math> element has a LaTeX annotation element.
309
+ * @param {*} math
310
+ * @returns {bool}
311
+ */
315
312
  function mathIsLatex(math) {
316
313
  const semantics = math.getChild(0);
317
- if (!semantics || semantics.name !== 'semantics') return false;
314
+ if (!semantics || semantics.name !== "semantics") return false;
318
315
  for (const child of semantics.getChildren()) {
319
- if (child.name === 'annotation' && child.getAttribute('encoding') === 'LaTeX') {
316
+ if (child.name === "annotation" && child.getAttribute("encoding") === "LaTeX") {
320
317
  return true;
321
318
  }
322
319
  }
@@ -324,8 +321,8 @@ export default class MathType extends Plugin {
324
321
  }
325
322
 
326
323
  function createViewWidget(modelItem, { writer: viewWriter }) {
327
- const widgetElement = viewWriter.createContainerElement('span', {
328
- class: 'ck-math-widget',
324
+ const widgetElement = viewWriter.createContainerElement("span", {
325
+ class: "ck-math-widget",
329
326
  });
330
327
 
331
328
  const mathUIElement = createViewImage(modelItem, { writer: viewWriter }); // eslint-disable-line no-use-before-define
@@ -340,7 +337,7 @@ export default class MathType extends Plugin {
340
337
  function createViewImage(modelItem, { writer: viewWriter }) {
341
338
  const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
342
339
 
343
- const mathString = modelItem.getAttribute('formula').replaceAll('ref="<"', 'ref="&lt;"');
340
+ const mathString = modelItem.getAttribute("formula").replaceAll('ref="<"', 'ref="&lt;"');
344
341
  const imgHtml = Parser.initParse(mathString, integration.getLanguage());
345
342
  const imgElement = htmlDataProcessor.toView(imgHtml).getChild(0);
346
343
 
@@ -348,8 +345,8 @@ export default class MathType extends Plugin {
348
345
  we must create a new EmptyElement which is independent of the
349
346
  DataProcessor being used by this editor instance */
350
347
  if (imgElement) {
351
- return viewWriter.createEmptyElement('img', imgElement.getAttributes(), {
352
- renderUnsafeAttributes: ['src'],
348
+ return viewWriter.createEmptyElement("img", imgElement.getAttributes(), {
349
+ renderUnsafeAttributes: ["src"],
353
350
  });
354
351
  }
355
352
 
@@ -357,14 +354,14 @@ export default class MathType extends Plugin {
357
354
  }
358
355
 
359
356
  // Model -> Editing view
360
- editor.conversion.for('editingDowncast').elementToElement({
361
- model: 'mathml',
357
+ editor.conversion.for("editingDowncast").elementToElement({
358
+ model: "mathml",
362
359
  view: createViewWidget,
363
360
  });
364
361
 
365
362
  // Model -> Data view
366
- editor.conversion.for('dataDowncast').elementToElement({
367
- model: 'mathml',
363
+ editor.conversion.for("dataDowncast").elementToElement({
364
+ model: "mathml",
368
365
  view: createDataString, // eslint-disable-line no-use-before-define
369
366
  });
370
367
 
@@ -374,26 +371,27 @@ export default class MathType extends Plugin {
374
371
  * @returns {module:engine/view/node~Node} Copy of the node.
375
372
  */
376
373
  function clone(viewWriter, sourceNode) {
377
- if (sourceNode.is('text')) {
374
+ if (sourceNode.is("text")) {
378
375
  return viewWriter.createText(sourceNode.data);
379
- } if (sourceNode.is('element')) {
380
- if (sourceNode.is('emptyElement')) {
376
+ }
377
+ if (sourceNode.is("element")) {
378
+ if (sourceNode.is("emptyElement")) {
381
379
  return viewWriter.createEmptyElement(sourceNode.name, sourceNode.getAttributes());
382
380
  }
383
381
  const element = viewWriter.createContainerElement(sourceNode.name, sourceNode.getAttributes());
384
382
  for (const child of sourceNode.getChildren()) {
385
- viewWriter.insert(viewWriter.createPositionAt(element, 'end'), clone(viewWriter, child));
383
+ viewWriter.insert(viewWriter.createPositionAt(element, "end"), clone(viewWriter, child));
386
384
  }
387
385
  return element;
388
386
  }
389
387
 
390
- throw new Exception('Given node has unsupported type.'); // eslint-disable-line no-undef
388
+ throw new Exception("Given node has unsupported type."); // eslint-disable-line no-undef
391
389
  }
392
390
 
393
391
  function createDataString(modelItem, { writer: viewWriter }) {
394
392
  const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
395
393
 
396
- let mathString = Parser.endParseSaveMode(modelItem.getAttribute('formula'));
394
+ let mathString = Parser.endParseSaveMode(modelItem.getAttribute("formula"));
397
395
 
398
396
  const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
399
397
 
@@ -402,8 +400,8 @@ export default class MathType extends Plugin {
402
400
 
403
401
  // This stops the view selection getting into the <span>s and messing up caret movement
404
402
  editor.editing.mapper.on(
405
- 'viewToModelPosition',
406
- viewToModelPositionOutsideModelElement(editor.model, (viewElement) => viewElement.hasClass('ck-math-widget')),
403
+ "viewToModelPosition",
404
+ viewToModelPositionOutsideModelElement(editor.model, (viewElement) => viewElement.hasClass("ck-math-widget")),
407
405
  );
408
406
 
409
407
  // Keep a reference to the original get and set function.
@@ -412,54 +410,56 @@ export default class MathType extends Plugin {
412
410
  /**
413
411
  * Hack to transform $$latex$$ into <math> in editor.getData()'s output.
414
412
  */
415
- editor.data.get = (options) => {
416
- let output = get.bind(editor.data)(options);
417
-
418
- // CKEditor 5 replaces all the time the &lt; and &gt; for < and >, which our render can't understand.
419
- // We replace the values inserted for CKEditro5 to be able to render the formulas with the mentioned characters.
420
- output = output.replaceAll('"<"', '"&lt;"')
421
- .replaceAll('">"', '"&gt;"')
422
- .replaceAll('><<', '>&lt;<');
423
-
424
- // Ckeditor retrieves editor data and removes the image information on the formulas
425
- // We transform all the retrieved data to images and then we Parse the data.
426
- let imageFormula = Parser.initParse(output);
427
- return Parser.endParse(imageFormula);
428
- };
413
+ editor.data.on(
414
+ "get",
415
+ (e) => {
416
+ let output = e.return;
417
+ // This line cleans all the semantics stuff, including the handwritten data points and returns the MathML IF there is any.
418
+ // For text or latex formulas, it returns the original output.
419
+ e.return = MathML.removeSemantics(output, "application/json");
420
+ },
421
+ { priority: "low" },
422
+ );
429
423
 
430
424
  /**
431
- * Hack to transform <math> with LaTeX into $$LaTeX$$ in editor.setData().
432
- */
433
- editor.data.set = (data) => {
434
- // Retrieve the data to be set on the CKEditor.
435
- let modifiedData = data;
436
- // Regex to find all mathml formulas.
437
- const regexp = /<math(.*?)<\/math>/gm;
438
-
439
- // Get all MathML formulas and store them in an array.
440
- // Using the conditional operator on data.main because the data patameter has different types depeding on:
441
- // editor.data.set can be used directly or by the source editing plugin.
442
- // With the source editor plugin, data is an object with the key `main` wich contains the source code string.
443
- // When using the editor.data.set method, the data is a string with the content to be set to the editor.
444
- let formulas = Object.values(data)[0] ? [...Object.values(data)[0].matchAll(regexp)] : [...data.matchAll(regexp)];
445
-
446
- // Loop to find LaTeX formulas and replace the MathML for the LaTeX notation.
447
- formulas.forEach((formula) => {
448
- let mathml = formula[0];
449
- if (mathml.includes('encoding="LaTeX"')) { // LaTeX found.
450
- let latex = '$$$' + Latex.getLatexFromMathML(mathml) + '$$$'; // We add $$$ instead of $$ because the replace function ignores one $.
451
- modifiedData = modifiedData.replace(mathml, latex);
452
- }
453
- });
425
+ * Hack to transform <math> with LaTeX into $$LaTeX$$ in editor.setData().
426
+ */
427
+ editor.data.on(
428
+ "set",
429
+ (e, args) => {
430
+ // Retrieve the data to be set on the CKEditor.
431
+ let modifiedData = args[0];
432
+ // Regex to find all mathml formulas.
433
+ const regexp = /<math(.*?)<\/math>/gm;
434
+
435
+ // Get all MathML formulas and store them in an array.
436
+ // Using the conditional operator on data.main because the data parameter has different types depending on:
437
+ // editor.data.set can be used directly or by the source editing plugin.
438
+ // With the source editor plugin, data is an object with the key `main` which contains the source code string.
439
+ // When using the editor.data.set method, the data is a string with the content to be set to the editor.
440
+ let formulas = Object.values(modifiedData)[0]
441
+ ? [...Object.values(modifiedData)[0].matchAll(regexp)]
442
+ : [...modifiedData.matchAll(regexp)];
443
+
444
+ // Loop to find LaTeX formulas and replace the MathML for the LaTeX notation.
445
+ formulas.forEach((formula) => {
446
+ let mathml = formula[0];
447
+ if (mathml.includes('encoding="LaTeX"')) {
448
+ // LaTeX found.
449
+ let latex = "$$$" + Latex.getLatexFromMathML(mathml) + "$$$"; // We add $$$ instead of $$ because the replace function ignores one $.
450
+ modifiedData = modifiedData.replace(mathml, latex);
451
+ }
452
+ });
454
453
 
455
- // Run the setData code from CKEditor5 with the modified string.
456
- set.bind(editor.data)(modifiedData);
457
- };
454
+ args[0] = modifiedData;
455
+ },
456
+ { priority: "high" },
457
+ );
458
458
  }
459
459
 
460
460
  /**
461
- * Expose the WirisPlugin variable to the window
462
- */
461
+ * Expose the WirisPlugin variable to the window
462
+ */
463
463
  // eslint-disable-next-line class-methods-use-this
464
464
  _exposeWiris() {
465
465
  window.WirisPlugin = {