@wiris/mathtype-ckeditor5 8.12.0 → 8.13.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
@@ -15,6 +15,7 @@ import Listeners from "@wiris/mathtype-html-integration-devkit/src/listeners.js"
15
15
  import MathML from "@wiris/mathtype-html-integration-devkit/src/mathml.js";
16
16
  import Latex from "@wiris/mathtype-html-integration-devkit/src/latex.js";
17
17
  import StringManager from "@wiris/mathtype-html-integration-devkit/src/stringmanager.js";
18
+ import "@wiris/mathtype-html-integration-devkit/src/md5.js";
18
19
 
19
20
  // Local imports
20
21
  import { MathTypeCommand, ChemTypeCommand } from "./commands.js";
@@ -61,8 +62,8 @@ export default class MathType extends Plugin {
61
62
  * Inherited from Plugin class: Executed when CKEditor5 is destroyed
62
63
  */
63
64
  destroy() {
64
- // eslint-disable-line class-methods-use-this
65
- currentInstance.destroy();
65
+ // eslint-disable-line class-methods-use-this
66
+ currentInstance?.destroy();
66
67
  }
67
68
 
68
69
  /**
@@ -315,7 +316,7 @@ export default class MathType extends Plugin {
315
316
  }
316
317
 
317
318
  const mathAttributes = [...viewItem.getAttributes()].map(([key, value]) => ` ${key}="${value}"`).join("");
318
- let htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
319
+ const htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
319
320
 
320
321
  const modelNode = writer.createElement("mathml", { htmlContent });
321
322
 
@@ -463,7 +464,7 @@ export default class MathType extends Plugin {
463
464
  const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
464
465
 
465
466
  // Load img element
466
- let mathString =
467
+ const mathString =
467
468
  modelItem.getAttribute("htmlContent") || Parser.endParseSaveMode(modelItem.getAttribute("formula"));
468
469
 
469
470
  const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
@@ -486,7 +487,7 @@ export default class MathType extends Plugin {
486
487
  editor.data.on(
487
488
  "get",
488
489
  (e) => {
489
- let output = e.return;
490
+ const output = e.return;
490
491
  const parsedResult = Parser.endParse(output);
491
492
 
492
493
  // Cleans all the semantics tag for safexml
@@ -518,14 +519,14 @@ export default class MathType extends Plugin {
518
519
  formulas.forEach((formula) => {
519
520
  if (formula.includes('encoding="LaTeX"')) {
520
521
  // LaTeX found.
521
- let latex = "$$$" + Latex.getLatexFromMathML(formula) + "$$$"; // We add $$$ instead of $$ because the replace function ignores one $.
522
+ const latex = `$$$${Latex.getLatexFromMathML(formula)}$$$`; // We add $$$ instead of $$ because the replace function ignores one $.
522
523
  modifiedData = modifiedData.replace(formula, latex);
523
524
  } else if (formula.includes("<img")) {
524
525
  // If we found a formula image, we should find MathML data, and then substitute the entire image.
525
526
  const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
526
527
  const safexml = formula.match(regexp);
527
528
  if (safexml !== null) {
528
- let decodeXML = MathML.safeXmlDecode(safexml[0]);
529
+ const decodeXML = MathML.safeXmlDecode(safexml[0]);
529
530
  modifiedData = modifiedData.replace(formula, decodeXML);
530
531
  }
531
532
  }