@wiris/mathtype-ckeditor5 8.11.0 → 8.11.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 +124 -39
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +125 -40
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/index.js +92 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.js +1 -1
- package/src/plugin.js +110 -31
|
@@ -559,6 +559,7 @@
|
|
|
559
559
|
'accumulate',
|
|
560
560
|
'additive',
|
|
561
561
|
'alignment-baseline',
|
|
562
|
+
'amplitude',
|
|
562
563
|
'ascent',
|
|
563
564
|
'attributename',
|
|
564
565
|
'attributetype',
|
|
@@ -591,6 +592,7 @@
|
|
|
591
592
|
'edgemode',
|
|
592
593
|
'elevation',
|
|
593
594
|
'end',
|
|
595
|
+
'exponent',
|
|
594
596
|
'fill',
|
|
595
597
|
'fill-opacity',
|
|
596
598
|
'fill-rule',
|
|
@@ -619,6 +621,7 @@
|
|
|
619
621
|
'image-rendering',
|
|
620
622
|
'in',
|
|
621
623
|
'in2',
|
|
624
|
+
'intercept',
|
|
622
625
|
'k',
|
|
623
626
|
'k1',
|
|
624
627
|
'k2',
|
|
@@ -683,6 +686,7 @@
|
|
|
683
686
|
'scale',
|
|
684
687
|
'seed',
|
|
685
688
|
'shape-rendering',
|
|
689
|
+
'slope',
|
|
686
690
|
'specularconstant',
|
|
687
691
|
'specularexponent',
|
|
688
692
|
'spreadmethod',
|
|
@@ -703,6 +707,7 @@
|
|
|
703
707
|
'surfacescale',
|
|
704
708
|
'systemlanguage',
|
|
705
709
|
'tabindex',
|
|
710
|
+
'tablevalues',
|
|
706
711
|
'targetx',
|
|
707
712
|
'targety',
|
|
708
713
|
'transform',
|
|
@@ -889,7 +894,7 @@
|
|
|
889
894
|
/**
|
|
890
895
|
* Version label, exposed for easier checks
|
|
891
896
|
* if DOMPurify is up to date or not
|
|
892
|
-
*/ DOMPurify.version = '3.1.
|
|
897
|
+
*/ DOMPurify.version = '3.1.7';
|
|
893
898
|
/**
|
|
894
899
|
* Array of elements that DOMPurify removed during sanitation.
|
|
895
900
|
* Empty if nothing was removed.
|
|
@@ -1262,7 +1267,6 @@
|
|
|
1262
1267
|
'mtext'
|
|
1263
1268
|
]);
|
|
1264
1269
|
const HTML_INTEGRATION_POINTS = addToSet({}, [
|
|
1265
|
-
'foreignobject',
|
|
1266
1270
|
'annotation-xml'
|
|
1267
1271
|
]);
|
|
1268
1272
|
// Certain elements are allowed in both SVG and HTML
|
|
@@ -1657,10 +1661,6 @@
|
|
|
1657
1661
|
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
|
1658
1662
|
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
|
1659
1663
|
value = hookEvent.attrValue;
|
|
1660
|
-
/* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
1661
|
-
_removeAttribute(name, currentNode);
|
|
1662
|
-
continue;
|
|
1663
|
-
}
|
|
1664
1664
|
/* Did the hooks approve of the attribute? */ if (hookEvent.forceKeepAttr) {
|
|
1665
1665
|
continue;
|
|
1666
1666
|
}
|
|
@@ -1693,6 +1693,10 @@
|
|
|
1693
1693
|
// Prefix the value and later re-create the attribute with the sanitized value
|
|
1694
1694
|
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
|
1695
1695
|
}
|
|
1696
|
+
/* Work around a security issue with comments inside attributes */ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
|
1697
|
+
_removeAttribute(name, currentNode);
|
|
1698
|
+
continue;
|
|
1699
|
+
}
|
|
1696
1700
|
/* Handle attributes that require Trusted Types */ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
|
1697
1701
|
if (namespaceURI) ;
|
|
1698
1702
|
else {
|
|
@@ -2268,6 +2272,19 @@
|
|
|
2268
2272
|
return mathml.replace(semanticsStartingTagRegex, "").replace(semanticsEndingTagRegex, "");
|
|
2269
2273
|
}
|
|
2270
2274
|
/**
|
|
2275
|
+
* Removes semantics tag to element that contains mathml.
|
|
2276
|
+
* When using Hand to create formulas, it adds the mrow tag due to the semantics one, this one is also removed.
|
|
2277
|
+
* @param {string} element - Inner HTML text string.
|
|
2278
|
+
* @returns {string} - 'mathml' without semantics tag.
|
|
2279
|
+
*/ static removeSafeXMLSemantics(element) {
|
|
2280
|
+
// If `mrow` is found right before the `semantics` starting tag, it's removed as well
|
|
2281
|
+
const semanticsSafeStartingTagRegex = /«semantics»\s*?(«mrow»)?/gm;
|
|
2282
|
+
// If `mrow` is found right after the `annotation` ending tag, it's removed as well
|
|
2283
|
+
// alongside `semantics` closing tag and the whole `annotation` tag and its contents.
|
|
2284
|
+
const semanticsSafeEndingTagRegex = /(«\/mrow»)?\s*«annotation[\W\w]*?«\/semantics»/gm;
|
|
2285
|
+
return element.replace(semanticsSafeStartingTagRegex, "").replace(semanticsSafeEndingTagRegex, "");
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2271
2288
|
* Transforms all xml mathml occurrences that contain semantics to the same
|
|
2272
2289
|
* xml mathml occurrences without semantics.
|
|
2273
2290
|
* @param {string} text - string that can contain xml mathml occurrences.
|
|
@@ -3590,6 +3607,9 @@
|
|
|
3590
3607
|
var nl = {
|
|
3591
3608
|
latex: "LaTeX",
|
|
3592
3609
|
cancel: "Annuleren",
|
|
3610
|
+
accept: "Invoegen",
|
|
3611
|
+
manual: "Handmatig",
|
|
3612
|
+
insert_math: "Een wiskundige vergelijking invoegen - MathType",
|
|
3593
3613
|
insert_chem: "Een scheikundige formule invoegen - ChemType",
|
|
3594
3614
|
minimize: "Minimaliseer",
|
|
3595
3615
|
maximize: "Maximaliseer",
|
|
@@ -5519,12 +5539,14 @@
|
|
|
5519
5539
|
* @param {string} code - HTML code to be parsed
|
|
5520
5540
|
* @returns {string} HTML code parsed.
|
|
5521
5541
|
*/ static endParseSaveMode(code) {
|
|
5522
|
-
|
|
5523
|
-
|
|
5542
|
+
const savemode = Configuration.get("saveMode");
|
|
5543
|
+
const base64savemode = Configuration.get("base64savemode");
|
|
5544
|
+
if (savemode) {
|
|
5545
|
+
if (savemode === "safeXml") {
|
|
5524
5546
|
code = Parser.codeImgTransform(code, "img2mathml");
|
|
5525
|
-
} else if (
|
|
5547
|
+
} else if (savemode === "xml") {
|
|
5526
5548
|
code = Parser.codeImgTransform(code, "img2mathml");
|
|
5527
|
-
} else if (
|
|
5549
|
+
} else if (savemode === "base64" && base64savemode === "image") {
|
|
5528
5550
|
code = Parser.codeImgTransform(code, "img264");
|
|
5529
5551
|
}
|
|
5530
5552
|
}
|
|
@@ -6694,7 +6716,7 @@
|
|
|
6694
6716
|
async function __wbg_init(input) {
|
|
6695
6717
|
if (wasm !== undefined) return wasm;
|
|
6696
6718
|
if (typeof input === "undefined") {
|
|
6697
|
-
input = new URL("telemeter_wasm_bg.wasm", (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.umd.js', document.baseURI).href)));
|
|
6719
|
+
input = new URL("telemeter_wasm_bg.wasm", (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.umd.js', document.baseURI).href)));
|
|
6698
6720
|
}
|
|
6699
6721
|
const imports = __wbg_get_imports();
|
|
6700
6722
|
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
|
|
@@ -10771,7 +10793,7 @@
|
|
|
10771
10793
|
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";
|
|
10772
10794
|
|
|
10773
10795
|
var name = "@wiris/mathtype-ckeditor5";
|
|
10774
|
-
var version = "8.11.
|
|
10796
|
+
var version = "8.11.1";
|
|
10775
10797
|
var description = "MathType Web for CKEditor5 editor";
|
|
10776
10798
|
var keywords = [
|
|
10777
10799
|
"chem",
|
|
@@ -10818,7 +10840,7 @@
|
|
|
10818
10840
|
prepare: "npm run build:dist"
|
|
10819
10841
|
};
|
|
10820
10842
|
var dependencies = {
|
|
10821
|
-
"@wiris/mathtype-html-integration-devkit": "1.17.
|
|
10843
|
+
"@wiris/mathtype-html-integration-devkit": "1.17.5"
|
|
10822
10844
|
};
|
|
10823
10845
|
var devDependencies = {
|
|
10824
10846
|
"@ckeditor/ckeditor5-dev-build-tools": "^42.1.0",
|
|
@@ -10987,7 +11009,8 @@
|
|
|
10987
11009
|
schema.register("mathml", {
|
|
10988
11010
|
inheritAllFrom: "$inlineObject",
|
|
10989
11011
|
allowAttributes: [
|
|
10990
|
-
"formula"
|
|
11012
|
+
"formula",
|
|
11013
|
+
"htmlContent"
|
|
10991
11014
|
]
|
|
10992
11015
|
});
|
|
10993
11016
|
}
|
|
@@ -11071,6 +11094,50 @@
|
|
|
11071
11094
|
data.modelCursor = data.modelRange.end;
|
|
11072
11095
|
}
|
|
11073
11096
|
});
|
|
11097
|
+
// Data view -> Model
|
|
11098
|
+
editor.data.upcastDispatcher.on("element:img", (evt, data, conversionApi)=>{
|
|
11099
|
+
const { consumable, writer } = conversionApi;
|
|
11100
|
+
const { viewItem } = data;
|
|
11101
|
+
// Only upcast when is wiris formula
|
|
11102
|
+
if (viewItem.getClassNames().next().value !== "Wirisformula") {
|
|
11103
|
+
return;
|
|
11104
|
+
}
|
|
11105
|
+
const mathAttributes = [
|
|
11106
|
+
...viewItem.getAttributes()
|
|
11107
|
+
].map(([key, value])=>` ${key}="${value}"`).join("");
|
|
11108
|
+
let htmlContent = Util.htmlSanitize(`<img${mathAttributes}>`);
|
|
11109
|
+
const modelNode = writer.createElement("mathml", {
|
|
11110
|
+
htmlContent
|
|
11111
|
+
});
|
|
11112
|
+
// Find allowed parent for element that we are going to insert.
|
|
11113
|
+
// If current parent does not allow to insert element but one of the ancestors does
|
|
11114
|
+
// then split nodes to allowed parent.
|
|
11115
|
+
const splitResult = conversionApi.splitToAllowedParent(modelNode, data.modelCursor);
|
|
11116
|
+
// When there is no split result it means that we can't insert element to model tree, so let's skip it.
|
|
11117
|
+
if (!splitResult) {
|
|
11118
|
+
return;
|
|
11119
|
+
}
|
|
11120
|
+
// Insert element on allowed position.
|
|
11121
|
+
conversionApi.writer.insert(modelNode, splitResult.position);
|
|
11122
|
+
// Consume appropriate value from consumable values list.
|
|
11123
|
+
consumable.consume(viewItem, {
|
|
11124
|
+
name: true
|
|
11125
|
+
});
|
|
11126
|
+
const parts = conversionApi.getSplitParts(modelNode);
|
|
11127
|
+
// Set conversion result range.
|
|
11128
|
+
data.modelRange = writer.createRange(conversionApi.writer.createPositionBefore(modelNode), conversionApi.writer.createPositionAfter(parts[parts.length - 1]));
|
|
11129
|
+
// Now we need to check where the `modelCursor` should be.
|
|
11130
|
+
if (splitResult.cursorParent) {
|
|
11131
|
+
// If we split parent to insert our element then we want to continue conversion in the new part of the split parent.
|
|
11132
|
+
//
|
|
11133
|
+
// before: <allowed><notAllowed>foo[]</notAllowed></allowed>
|
|
11134
|
+
// after: <allowed><notAllowed>foo</notAllowed><converted></converted><notAllowed>[]</notAllowed></allowed>
|
|
11135
|
+
data.modelCursor = conversionApi.writer.createPositionAt(splitResult.cursorParent, 0);
|
|
11136
|
+
} else {
|
|
11137
|
+
// Otherwise just continue after inserted element.
|
|
11138
|
+
data.modelCursor = data.modelRange.end;
|
|
11139
|
+
}
|
|
11140
|
+
});
|
|
11074
11141
|
/**
|
|
11075
11142
|
* Whether the given view <math> element has a LaTeX annotation element.
|
|
11076
11143
|
* @param {*} math
|
|
@@ -11099,12 +11166,25 @@
|
|
|
11099
11166
|
}
|
|
11100
11167
|
function createViewImage(modelItem, { writer: viewWriter }) {
|
|
11101
11168
|
const htmlDataProcessor = new ckeditor5.HtmlDataProcessor(viewWriter.document);
|
|
11102
|
-
const
|
|
11103
|
-
const
|
|
11104
|
-
|
|
11169
|
+
const formula = modelItem.getAttribute("formula");
|
|
11170
|
+
const htmlContent = modelItem.getAttribute("htmlContent");
|
|
11171
|
+
if (!formula && !htmlContent) {
|
|
11172
|
+
return null;
|
|
11173
|
+
}
|
|
11174
|
+
let imgElement = null;
|
|
11175
|
+
if (htmlContent) {
|
|
11176
|
+
imgElement = htmlDataProcessor.toView(htmlContent).getChild(0);
|
|
11177
|
+
} else if (formula) {
|
|
11178
|
+
const mathString = formula.replaceAll('ref="<"', 'ref="<"');
|
|
11179
|
+
const imgHtml = Parser.initParse(mathString, integration.getLanguage());
|
|
11180
|
+
imgElement = htmlDataProcessor.toView(imgHtml).getChild(0);
|
|
11181
|
+
// Add HTML element (<img>) to model
|
|
11182
|
+
viewWriter.setAttribute("htmlContent", imgHtml, modelItem);
|
|
11183
|
+
}
|
|
11105
11184
|
/* Although we use the HtmlDataProcessor to obtain the attributes,
|
|
11106
|
-
|
|
11107
|
-
|
|
11185
|
+
* we must create a new EmptyElement which is independent of the
|
|
11186
|
+
* DataProcessor being used by this editor instance
|
|
11187
|
+
*/ if (imgElement) {
|
|
11108
11188
|
return viewWriter.createEmptyElement("img", imgElement.getAttributes(), {
|
|
11109
11189
|
renderUnsafeAttributes: [
|
|
11110
11190
|
"src"
|
|
@@ -11145,7 +11225,8 @@
|
|
|
11145
11225
|
}
|
|
11146
11226
|
function createDataString(modelItem, { writer: viewWriter }) {
|
|
11147
11227
|
const htmlDataProcessor = new ckeditor5.HtmlDataProcessor(viewWriter.document);
|
|
11148
|
-
|
|
11228
|
+
// Load img element
|
|
11229
|
+
let mathString = modelItem.getAttribute("htmlContent");
|
|
11149
11230
|
const sourceMathElement = htmlDataProcessor.toView(mathString).getChild(0);
|
|
11150
11231
|
return clone(viewWriter, sourceMathElement);
|
|
11151
11232
|
}
|
|
@@ -11157,36 +11238,40 @@
|
|
|
11157
11238
|
* Hack to transform $$latex$$ into <math> in editor.getData()'s output.
|
|
11158
11239
|
*/ editor.data.on("get", (e)=>{
|
|
11159
11240
|
let output = e.return;
|
|
11160
|
-
|
|
11161
|
-
//
|
|
11162
|
-
|
|
11241
|
+
const parsedResult = Parser.endParse(output);
|
|
11242
|
+
// Cleans all the semantics tag for safexml
|
|
11243
|
+
// including the handwritten data points
|
|
11244
|
+
e.return = MathML.removeSafeXMLSemantics(parsedResult);
|
|
11163
11245
|
}, {
|
|
11164
11246
|
priority: "low"
|
|
11165
11247
|
});
|
|
11166
11248
|
/**
|
|
11167
|
-
* Hack to transform <math> with LaTeX into $$LaTeX$$ in editor.setData().
|
|
11249
|
+
* Hack to transform <math> with LaTeX into $$LaTeX$$ and formula images in editor.setData().
|
|
11168
11250
|
*/ editor.data.on("set", (e, args)=>{
|
|
11169
11251
|
// Retrieve the data to be set on the CKEditor.
|
|
11170
11252
|
let modifiedData = args[0];
|
|
11171
11253
|
// Regex to find all mathml formulas.
|
|
11172
|
-
const regexp =
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
//
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
] : [
|
|
11181
|
-
...modifiedData.matchAll(regexp)
|
|
11182
|
-
];
|
|
11183
|
-
// Loop to find LaTeX formulas and replace the MathML for the LaTeX notation.
|
|
11254
|
+
const regexp = /(<img\b[^>]*>)|(<math(.*?)<\/math>)/gm;
|
|
11255
|
+
const formulas = [];
|
|
11256
|
+
let formula;
|
|
11257
|
+
// Both data.set from the source plugin and console command are taken into account as the data received is MathML or an image containing the MathML.
|
|
11258
|
+
while((formula = regexp.exec(modifiedData)) !== null){
|
|
11259
|
+
formulas.push(formula[0]);
|
|
11260
|
+
}
|
|
11261
|
+
// Loop to find LaTeX and formula images and replace the MathML for the both.
|
|
11184
11262
|
formulas.forEach((formula)=>{
|
|
11185
|
-
|
|
11186
|
-
if (mathml.includes('encoding="LaTeX"')) {
|
|
11263
|
+
if (formula.includes('encoding="LaTeX"')) {
|
|
11187
11264
|
// LaTeX found.
|
|
11188
|
-
let latex = "$$$" + Latex.getLatexFromMathML(
|
|
11189
|
-
modifiedData = modifiedData.replace(
|
|
11265
|
+
let latex = "$$$" + Latex.getLatexFromMathML(formula) + "$$$"; // We add $$$ instead of $$ because the replace function ignores one $.
|
|
11266
|
+
modifiedData = modifiedData.replace(formula, latex);
|
|
11267
|
+
} else if (formula.includes("<img")) {
|
|
11268
|
+
// If we found a formula image, we should find MathML data, and then substitute the entire image.
|
|
11269
|
+
const regexp = /«math\b[^»]*»(.*?)«\/math»/g;
|
|
11270
|
+
const safexml = formula.match(regexp);
|
|
11271
|
+
if (safexml !== null) {
|
|
11272
|
+
let decodeXML = MathML.safeXmlDecode(safexml[0]);
|
|
11273
|
+
modifiedData = modifiedData.replace(formula, decodeXML);
|
|
11274
|
+
}
|
|
11190
11275
|
}
|
|
11191
11276
|
});
|
|
11192
11277
|
args[0] = modifiedData;
|