@wiris/mathtype-ckeditor5 8.12.0 → 8.13.1
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.js +1229 -159
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +1238 -163
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/browser/telemeter_wasm_bg.wasm +0 -0
- package/dist/index.js +17 -89
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/index.js +3 -0
- package/src/integration.js +8 -9
- package/src/plugin.js +8 -7
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import Listeners from '@wiris/mathtype-html-integration-devkit/src/listeners.js'
|
|
|
12
12
|
import MathML from '@wiris/mathtype-html-integration-devkit/src/mathml.js';
|
|
13
13
|
import Latex from '@wiris/mathtype-html-integration-devkit/src/latex.js';
|
|
14
14
|
import StringManager from '@wiris/mathtype-html-integration-devkit/src/stringmanager.js';
|
|
15
|
+
import '@wiris/mathtype-html-integration-devkit/src/md5.js';
|
|
15
16
|
import Telemeter from '@wiris/mathtype-html-integration-devkit/src/telemeter.js';
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -218,15 +219,15 @@ import Telemeter from '@wiris/mathtype-html-integration-devkit/src/telemeter.js'
|
|
|
218
219
|
// When Latex is next to image/formula.
|
|
219
220
|
if (latexRange.startContainer.nodeType === 3 && latexRange.startContainer.previousSibling?.nodeType === 1) {
|
|
220
221
|
// Get the position of the latex to be replaced.
|
|
221
|
-
|
|
222
|
+
const latexEdited = `$$${Latex.getLatexFromMathML(MathML.safeXmlDecode(this.core.editionProperties.temporalImage.dataset.mathml))}$$`;
|
|
222
223
|
let data = latexRange.startContainer.data;
|
|
223
224
|
// Remove invisible characters.
|
|
224
225
|
data = data.replaceAll(String.fromCharCode(8288), "");
|
|
225
226
|
// Get to the start of the latex we are editing.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
const offset = data.indexOf(latexEdited);
|
|
228
|
+
const dataOffset = data.substring(offset);
|
|
229
|
+
const second$ = dataOffset.substring(2).indexOf("$$") + 4;
|
|
230
|
+
const substring = dataOffset.substr(0, second$);
|
|
230
231
|
data = data.replace(substring, "");
|
|
231
232
|
if (!data) {
|
|
232
233
|
startPosition = writer.createPositionBefore(startNode);
|
|
@@ -252,7 +253,7 @@ import Telemeter from '@wiris/mathtype-html-integration-devkit/src/telemeter.js'
|
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
// Build the telemeter payload separated to delete null/undefined entries.
|
|
255
|
-
|
|
256
|
+
const payload = {
|
|
256
257
|
mathml_origin: mathmlOrigin ? MathML.safeXmlDecode(mathmlOrigin) : mathmlOrigin,
|
|
257
258
|
mathml: mathml ? MathML.safeXmlDecode(mathml) : mathml,
|
|
258
259
|
elapsed_time: Date.now() - this.core.editionProperties.editionStartTime,
|
|
@@ -358,82 +359,9 @@ var mathIcon = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adob
|
|
|
358
359
|
|
|
359
360
|
var chemIcon = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 40.3 49.5\" style=\"enable-background:new 0 0 40.3 49.5;\" xml:space=\"preserve\">\n<style type=\"text/css\">\n\t.st0{fill:#A4CF61;}\n</style>\n<path class=\"st0\" d=\"M39.2,12.1c0-1.9-1.1-3.6-2.7-4.4L24.5,0.9l0,0c-0.7-0.4-1.5-0.6-2.4-0.6c-0.9,0-1.7,0.2-2.4,0.6l0,0L2.3,10.8\n\tl0,0C0.9,11.7,0,13.2,0,14.9h0v19.6h0c0,1.7,0.9,3.3,2.3,4.1l0,0l17.4,9.9l0,0c0.7,0.4,1.5,0.6,2.4,0.6c0.9,0,1.7-0.2,2.4-0.6l0,0\n\tl12.2-6.9h0c1.5-0.8,2.6-2.5,2.6-4.3c0-2.7-2.2-4.9-4.9-4.9c-0.9,0-1.8,0.3-2.5,0.7l0,0l-9.7,5.6l-12.3-7V17.8l12.3-7l9.9,5.7l0,0\n\tc0.7,0.4,1.5,0.6,2.4,0.6C37,17,39.2,14.8,39.2,12.1\"/>\n</svg>\n";
|
|
360
361
|
|
|
361
|
-
var
|
|
362
|
-
var version = "8.12.0";
|
|
363
|
-
var description = "MathType Web for CKEditor5 editor";
|
|
364
|
-
var keywords = [
|
|
365
|
-
"chem",
|
|
366
|
-
"chemistry",
|
|
367
|
-
"chemtype",
|
|
368
|
-
"ckeditor",
|
|
369
|
-
"ckeditor5",
|
|
370
|
-
"editor",
|
|
371
|
-
"equation",
|
|
372
|
-
"latex",
|
|
373
|
-
"math",
|
|
374
|
-
"mathml",
|
|
375
|
-
"maths",
|
|
376
|
-
"mathtype",
|
|
377
|
-
"wiris"
|
|
378
|
-
];
|
|
379
|
-
var repository = "https://github.com/wiris/html-integrations/tree/master/packages/ckeditor5";
|
|
380
|
-
var homepage = "https://www.wiris.com/";
|
|
381
|
-
var bugs = {
|
|
382
|
-
email: "support@wiris.com"
|
|
383
|
-
};
|
|
384
|
-
var license = "MIT";
|
|
385
|
-
var author = "WIRIS Team (http://www.wiris.com)";
|
|
386
|
-
var files = [
|
|
387
|
-
"dist",
|
|
388
|
-
"src",
|
|
389
|
-
"icons",
|
|
390
|
-
"theme",
|
|
391
|
-
"lang"
|
|
392
|
-
];
|
|
393
|
-
var main = "src/plugin.js";
|
|
394
|
-
var type = "module";
|
|
395
|
-
var exports = {
|
|
396
|
-
".": "./src/plugin.js",
|
|
397
|
-
"./dist/*": "./dist/*",
|
|
398
|
-
"./browser/*": null,
|
|
399
|
-
"./src/*": "./src/*",
|
|
400
|
-
"./theme/*": "./theme/*",
|
|
401
|
-
"./package.json": "./package.json"
|
|
402
|
-
};
|
|
403
|
-
var scripts = {
|
|
404
|
-
build: "node ./scripts/build-dist.mjs",
|
|
405
|
-
"build:dist": "node ./scripts/build-dist.mjs",
|
|
406
|
-
prepare: "npm run build:dist"
|
|
407
|
-
};
|
|
408
|
-
var dependencies = {
|
|
409
|
-
"@wiris/mathtype-html-integration-devkit": "1.17.6"
|
|
410
|
-
};
|
|
411
|
-
var devDependencies = {
|
|
412
|
-
"@ckeditor/ckeditor5-dev-build-tools": "^42.1.0",
|
|
413
|
-
ckeditor5: ">=43.0.0"
|
|
414
|
-
};
|
|
415
|
-
var peerDependencies = {
|
|
416
|
-
ckeditor5: ">=43.0.0"
|
|
417
|
-
};
|
|
362
|
+
var version = "8.13.1";
|
|
418
363
|
var packageInfo = {
|
|
419
|
-
|
|
420
|
-
version: version,
|
|
421
|
-
description: description,
|
|
422
|
-
keywords: keywords,
|
|
423
|
-
repository: repository,
|
|
424
|
-
homepage: homepage,
|
|
425
|
-
bugs: bugs,
|
|
426
|
-
license: license,
|
|
427
|
-
author: author,
|
|
428
|
-
files: files,
|
|
429
|
-
main: main,
|
|
430
|
-
type: type,
|
|
431
|
-
exports: exports,
|
|
432
|
-
scripts: scripts,
|
|
433
|
-
dependencies: dependencies,
|
|
434
|
-
devDependencies: devDependencies,
|
|
435
|
-
peerDependencies: peerDependencies
|
|
436
|
-
};
|
|
364
|
+
version: version};
|
|
437
365
|
|
|
438
366
|
// CKEditor imports
|
|
439
367
|
let currentInstance = null; // eslint-disable-line import/no-mutable-exports
|
|
@@ -465,7 +393,7 @@ class MathType extends Plugin {
|
|
|
465
393
|
* Inherited from Plugin class: Executed when CKEditor5 is destroyed
|
|
466
394
|
*/ destroy() {
|
|
467
395
|
// eslint-disable-line class-methods-use-this
|
|
468
|
-
currentInstance
|
|
396
|
+
currentInstance?.destroy();
|
|
469
397
|
}
|
|
470
398
|
/**
|
|
471
399
|
* Create the MathType API Integration object
|
|
@@ -671,7 +599,7 @@ class MathType extends Plugin {
|
|
|
671
599
|
const mathAttributes = [
|
|
672
600
|
...viewItem.getAttributes()
|
|
673
601
|
].map(([key, value])=>` ${key}="${value}"`).join("");
|
|
674
|
-
|
|
602
|
+
const htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
|
|
675
603
|
const modelNode = writer.createElement("mathml", {
|
|
676
604
|
htmlContent
|
|
677
605
|
});
|
|
@@ -792,18 +720,18 @@ class MathType extends Plugin {
|
|
|
792
720
|
function createDataString(modelItem, { writer: viewWriter }) {
|
|
793
721
|
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
|
|
794
722
|
// Load img element
|
|
795
|
-
|
|
723
|
+
const mathString = modelItem.getAttribute("htmlContent") || Parser.endParseSaveMode(modelItem.getAttribute("formula"));
|
|
796
724
|
const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
|
|
797
725
|
return clone(viewWriter, sourceMathElement);
|
|
798
726
|
}
|
|
799
727
|
// This stops the view selection getting into the <span>s and messing up caret movement
|
|
800
728
|
editor.editing.mapper.on("viewToModelPosition", viewToModelPositionOutsideModelElement(editor.model, (viewElement)=>viewElement.hasClass("ck-math-widget")));
|
|
801
729
|
// Keep a reference to the original get and set function.
|
|
802
|
-
editor.data;
|
|
730
|
+
const { get, set } = editor.data;
|
|
803
731
|
/**
|
|
804
732
|
* Hack to transform $$latex$$ into <math> in editor.getData()'s output.
|
|
805
733
|
*/ editor.data.on("get", (e)=>{
|
|
806
|
-
|
|
734
|
+
const output = e.return;
|
|
807
735
|
const parsedResult = Parser.endParse(output);
|
|
808
736
|
// Cleans all the semantics tag for safexml
|
|
809
737
|
// including the handwritten data points
|
|
@@ -828,14 +756,14 @@ class MathType extends Plugin {
|
|
|
828
756
|
formulas.forEach((formula)=>{
|
|
829
757
|
if (formula.includes('encoding="LaTeX"')) {
|
|
830
758
|
// LaTeX found.
|
|
831
|
-
|
|
759
|
+
const latex = `$$$${Latex.getLatexFromMathML(formula)}$$$`; // We add $$$ instead of $$ because the replace function ignores one $.
|
|
832
760
|
modifiedData = modifiedData.replace(formula, latex);
|
|
833
761
|
} else if (formula.includes("<img")) {
|
|
834
762
|
// If we found a formula image, we should find MathML data, and then substitute the entire image.
|
|
835
763
|
const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
|
|
836
764
|
const safexml = formula.match(regexp);
|
|
837
765
|
if (safexml !== null) {
|
|
838
|
-
|
|
766
|
+
const decodeXML = MathML.safeXmlDecode(safexml[0]);
|
|
839
767
|
modifiedData = modifiedData.replace(formula, decodeXML);
|
|
840
768
|
}
|
|
841
769
|
}
|
|
@@ -864,5 +792,5 @@ class MathType extends Plugin {
|
|
|
864
792
|
}
|
|
865
793
|
}
|
|
866
794
|
|
|
867
|
-
export { MathType as default };
|
|
795
|
+
export { CKEditor5Integration, ChemTypeCommand, MathTypeCommand, MathType as default };
|
|
868
796
|
//# sourceMappingURL=index.js.map
|