@wiris/mathtype-ckeditor5 8.7.0 → 8.7.2

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/plugin.js +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiris/mathtype-ckeditor5",
3
- "version": "8.7.0",
3
+ "version": "8.7.2",
4
4
  "description": "MathType Web for CKEditor5 editor",
5
5
  "keywords": [
6
6
  "chem",
@@ -39,6 +39,6 @@
39
39
  "@ckeditor/ckeditor5-engine": ">=23.0.0",
40
40
  "@ckeditor/ckeditor5-ui": ">=23.0.0",
41
41
  "@ckeditor/ckeditor5-widget": ">=23.0.0",
42
- "@wiris/mathtype-html-integration-devkit": "1.14.1"
42
+ "@wiris/mathtype-html-integration-devkit": "1.14.2"
43
43
  }
44
44
  }
package/src/plugin.js CHANGED
@@ -258,9 +258,9 @@ export default class MathType extends Plugin {
258
258
  formula = Util.htmlSanitize(`<math${mathAttributes}>${formula}</math>`);
259
259
 
260
260
  // Replaces the < & > characters to its HTMLEntity to avoid render issues.
261
- formula = formula.replace('"<"', '"&lt;"')
262
- .replace('">"', '"&gt;"')
263
- .replace('><<', '>&lt;<');
261
+ formula = formula.replaceAll('"<"', '"&lt;"')
262
+ .replaceAll('">"', '"&gt;"')
263
+ .replaceAll('><<', '>&lt;<');
264
264
 
265
265
 
266
266
  /* Model node that contains what's going to actually be inserted. This can be either:
@@ -341,7 +341,7 @@ export default class MathType extends Plugin {
341
341
  function createViewImage(modelItem, { writer: viewWriter }) {
342
342
  const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
343
343
 
344
- const mathString = modelItem.getAttribute('formula').replace('ref="<"', 'ref="&lt;"');
344
+ const mathString = modelItem.getAttribute('formula').replaceAll('ref="<"', 'ref="&lt;"');
345
345
  const imgHtml = Parser.initParse(mathString, editor.config.get('language'));
346
346
  const imgElement = htmlDataProcessor.toView(imgHtml).getChild(0);
347
347
 
@@ -415,6 +415,13 @@ export default class MathType extends Plugin {
415
415
  */
416
416
  editor.data.get = (options) => {
417
417
  let output = get.bind(editor.data)(options);
418
+
419
+ // CKEditor 5 replaces all the time the &lt; and &gt; for < and >, which our render can't understand.
420
+ // We replace the values inserted for CKEditro5 to be able to render the formulas with the mentioned characters.
421
+ output = output.replaceAll('"<"', '"&lt;"')
422
+ .replaceAll('">"', '"&gt;"')
423
+ .replaceAll('><<', '>&lt;<');
424
+
418
425
  // Ckeditor retrieves editor data and removes the image information on the formulas
419
426
  // We transform all the retrieved data to images and then we Parse the data.
420
427
  let imageFormula = Parser.initParse(output);