@wiris/mathtype-ckeditor5 8.11.1 → 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/dist/browser/index-editor.css +23 -102
- package/dist/browser/index.css +41 -111
- package/dist/browser/index.css.map +1 -1
- package/dist/browser/index.js +2555 -2106
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +11706 -11252
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/browser/telemeter_wasm_bg.wasm +0 -0
- package/dist/index.js +21 -93
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/index.js +3 -0
- package/src/integration.js +8 -9
- package/src/plugin.js +16 -14
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
|
-
|
|
65
|
-
|
|
65
|
+
// eslint-disable-line class-methods-use-this
|
|
66
|
+
currentInstance?.destroy();
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -91,7 +92,7 @@ export default class MathType extends Plugin {
|
|
|
91
92
|
// etc
|
|
92
93
|
|
|
93
94
|
// There are platforms like Drupal that initialize CKEditor but they hide or remove the container element.
|
|
94
|
-
// To avoid a wrong
|
|
95
|
+
// To avoid a wrong behavior, this integration only starts if the workspace container exists.
|
|
95
96
|
let integration;
|
|
96
97
|
if (integrationProperties.target) {
|
|
97
98
|
// Instance of the integration associated to this editor instance
|
|
@@ -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
|
-
|
|
319
|
+
const htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
|
|
319
320
|
|
|
320
321
|
const modelNode = writer.createElement("mathml", { htmlContent });
|
|
321
322
|
|
|
@@ -393,7 +394,7 @@ export default class MathType extends Plugin {
|
|
|
393
394
|
const formula = modelItem.getAttribute("formula");
|
|
394
395
|
const htmlContent = modelItem.getAttribute("htmlContent");
|
|
395
396
|
|
|
396
|
-
if(!formula && !htmlContent){
|
|
397
|
+
if (!formula && !htmlContent) {
|
|
397
398
|
return null;
|
|
398
399
|
}
|
|
399
400
|
|
|
@@ -401,7 +402,7 @@ export default class MathType extends Plugin {
|
|
|
401
402
|
|
|
402
403
|
if (htmlContent) {
|
|
403
404
|
imgElement = htmlDataProcessor.toView(htmlContent).getChild(0);
|
|
404
|
-
} else if(formula) {
|
|
405
|
+
} else if (formula) {
|
|
405
406
|
const mathString = formula.replaceAll('ref="<"', 'ref="<"');
|
|
406
407
|
|
|
407
408
|
const imgHtml = Parser.initParse(mathString, integration.getLanguage());
|
|
@@ -412,9 +413,9 @@ export default class MathType extends Plugin {
|
|
|
412
413
|
}
|
|
413
414
|
|
|
414
415
|
/* Although we use the HtmlDataProcessor to obtain the attributes,
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
* we must create a new EmptyElement which is independent of the
|
|
417
|
+
* DataProcessor being used by this editor instance
|
|
418
|
+
*/
|
|
418
419
|
if (imgElement) {
|
|
419
420
|
return viewWriter.createEmptyElement("img", imgElement.getAttributes(), {
|
|
420
421
|
renderUnsafeAttributes: ["src"],
|
|
@@ -463,7 +464,8 @@ export default class MathType extends Plugin {
|
|
|
463
464
|
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
|
|
464
465
|
|
|
465
466
|
// Load img element
|
|
466
|
-
|
|
467
|
+
const mathString =
|
|
468
|
+
modelItem.getAttribute("htmlContent") || Parser.endParseSaveMode(modelItem.getAttribute("formula"));
|
|
467
469
|
|
|
468
470
|
const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
|
|
469
471
|
|
|
@@ -485,7 +487,7 @@ export default class MathType extends Plugin {
|
|
|
485
487
|
editor.data.on(
|
|
486
488
|
"get",
|
|
487
489
|
(e) => {
|
|
488
|
-
|
|
490
|
+
const output = e.return;
|
|
489
491
|
const parsedResult = Parser.endParse(output);
|
|
490
492
|
|
|
491
493
|
// Cleans all the semantics tag for safexml
|
|
@@ -517,14 +519,14 @@ export default class MathType extends Plugin {
|
|
|
517
519
|
formulas.forEach((formula) => {
|
|
518
520
|
if (formula.includes('encoding="LaTeX"')) {
|
|
519
521
|
// LaTeX found.
|
|
520
|
-
|
|
522
|
+
const latex = `$$$${Latex.getLatexFromMathML(formula)}$$$`; // We add $$$ instead of $$ because the replace function ignores one $.
|
|
521
523
|
modifiedData = modifiedData.replace(formula, latex);
|
|
522
524
|
} else if (formula.includes("<img")) {
|
|
523
525
|
// If we found a formula image, we should find MathML data, and then substitute the entire image.
|
|
524
526
|
const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
|
|
525
527
|
const safexml = formula.match(regexp);
|
|
526
|
-
if(safexml !== null) {
|
|
527
|
-
|
|
528
|
+
if (safexml !== null) {
|
|
529
|
+
const decodeXML = MathML.safeXmlDecode(safexml[0]);
|
|
528
530
|
modifiedData = modifiedData.replace(formula, decodeXML);
|
|
529
531
|
}
|
|
530
532
|
}
|