@wiris/mathtype-ckeditor5 8.3.1 → 8.5.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/package.json +2 -2
- package/src/integration.js +10 -10
- package/src/plugin.js +4 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wiris/mathtype-ckeditor5",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.0",
|
|
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.
|
|
42
|
+
"@wiris/mathtype-html-integration-devkit": "1.13.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/integration.js
CHANGED
|
@@ -2,7 +2,6 @@ import IntegrationModel from '@wiris/mathtype-html-integration-devkit/src/integr
|
|
|
2
2
|
import Util from '@wiris/mathtype-html-integration-devkit/src/util';
|
|
3
3
|
import Configuration from '@wiris/mathtype-html-integration-devkit/src/configuration';
|
|
4
4
|
import Latex from '@wiris/mathtype-html-integration-devkit/src/latex';
|
|
5
|
-
import Parser from '@wiris/mathtype-html-integration-devkit/src/parser';
|
|
6
5
|
import MathML from '@wiris/mathtype-html-integration-devkit/src/mathml';
|
|
7
6
|
import Telemeter from '@wiris/mathtype-html-integration-devkit/src/telemeter';
|
|
8
7
|
|
|
@@ -37,9 +36,10 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
37
36
|
*/
|
|
38
37
|
getLanguage() {
|
|
39
38
|
// Returns the CKEDitor instance language taking into account that the language can be an object.
|
|
39
|
+
// Try to get editorParameters.language, fail silently otherwise
|
|
40
40
|
try {
|
|
41
41
|
return this.editorParameters.language;
|
|
42
|
-
} catch (e) {
|
|
42
|
+
} catch (e) {}
|
|
43
43
|
const languageObject = this.editorObject.config.get('language');
|
|
44
44
|
if (languageObject != null) {
|
|
45
45
|
if (typeof (languageObject) === 'object') {
|
|
@@ -158,7 +158,7 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
158
158
|
const viewSelection = this.core.editionProperties.selection || this.editorObject.editing.view.document.selection;
|
|
159
159
|
const modelPosition = this.editorObject.editing.mapper.toModelPosition(viewSelection.getLastPosition());
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
this.editorObject.model.insertObject(modelElementNew, modelPosition);
|
|
162
162
|
|
|
163
163
|
// Remove selection
|
|
164
164
|
if (!viewSelection.isCollapsed) {
|
|
@@ -180,7 +180,7 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
180
180
|
|
|
181
181
|
// If the given MathML is empty, don't insert a new formula.
|
|
182
182
|
if (mathml) {
|
|
183
|
-
|
|
183
|
+
this.editorObject.model.insertObject(modelElementNew, position);
|
|
184
184
|
}
|
|
185
185
|
writer.remove(modelElementOld);
|
|
186
186
|
}
|
|
@@ -242,13 +242,13 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
242
242
|
|
|
243
243
|
let startPosition = writer.createPositionAt(startNode.parent, startNode.startOffset + latexRange.startOffset);
|
|
244
244
|
let endPosition = writer.createPositionAt(endNode.parent, endNode.startOffset + latexRange.endOffset);
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
let range = writer.createRange(
|
|
247
247
|
startPosition,
|
|
248
248
|
endPosition,
|
|
249
249
|
);
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
|
|
253
253
|
// When Latex is next to image/formula.
|
|
254
254
|
if (latexRange.startContainer.nodeType === 3 && latexRange.startContainer.previousSibling?.nodeType === 1) {
|
|
@@ -265,19 +265,19 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
265
265
|
let second$ = dataOffset.substring(2).indexOf("$$") + 4;
|
|
266
266
|
let substring = dataOffset.substr(0, second$);
|
|
267
267
|
data = data.replace(substring, '');
|
|
268
|
-
|
|
268
|
+
|
|
269
269
|
if (!data) {
|
|
270
270
|
startPosition = writer.createPositionBefore(startNode);
|
|
271
271
|
range = startNode;
|
|
272
272
|
} else {
|
|
273
273
|
startPosition = startPosition = writer.createPositionAt(startNode.parent, startNode.startOffset + offset);
|
|
274
|
-
endPosition = writer.createPositionAt(endNode.parent, endNode.startOffset + second$ + offset);
|
|
274
|
+
endPosition = writer.createPositionAt(endNode.parent, endNode.startOffset + second$ + offset);
|
|
275
275
|
range = writer.createRange(
|
|
276
276
|
startPosition,
|
|
277
277
|
endPosition,
|
|
278
278
|
);
|
|
279
279
|
}
|
|
280
|
-
}
|
|
280
|
+
}
|
|
281
281
|
|
|
282
282
|
writer.remove(range);
|
|
283
283
|
writer.insertText(`$$${returnObject.latex}$$`, startNode.getAttributes(), startPosition);
|
|
@@ -312,7 +312,7 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
312
312
|
Object.keys(payload).forEach(key => {
|
|
313
313
|
if (key === 'mathml_origin' || key === 'editor_origin') !payload[key] ? delete payload[key] : {}
|
|
314
314
|
});
|
|
315
|
-
|
|
315
|
+
|
|
316
316
|
try {
|
|
317
317
|
Telemeter.telemeter.track("INSERTED_FORMULA", {
|
|
318
318
|
...payload,
|
package/src/plugin.js
CHANGED
|
@@ -199,9 +199,7 @@ export default class MathType extends Plugin {
|
|
|
199
199
|
const { schema } = this.editor.model;
|
|
200
200
|
|
|
201
201
|
schema.register('mathml', {
|
|
202
|
-
|
|
203
|
-
isObject: true,
|
|
204
|
-
isInline: true,
|
|
202
|
+
inheritAllFrom: '$inlineObject',
|
|
205
203
|
allowAttributes: ['formula'],
|
|
206
204
|
});
|
|
207
205
|
}
|
|
@@ -337,7 +335,7 @@ export default class MathType extends Plugin {
|
|
|
337
335
|
function createViewImage(modelItem, { writer: viewWriter }) {
|
|
338
336
|
const htmlDataProcessor = new HtmlDataProcessor(viewWriter.document);
|
|
339
337
|
|
|
340
|
-
const mathString = modelItem.getAttribute('formula');
|
|
338
|
+
const mathString = modelItem.getAttribute('formula').replace('ref="<"', 'ref="<"');
|
|
341
339
|
const imgHtml = Parser.initParse(mathString, editor.config.get('language'));
|
|
342
340
|
const imgElement = htmlDataProcessor.toView(imgHtml).getChild(0);
|
|
343
341
|
|
|
@@ -410,8 +408,8 @@ export default class MathType extends Plugin {
|
|
|
410
408
|
* Hack to transform $$latex$$ into <math> in editor.getData()'s output.
|
|
411
409
|
*/
|
|
412
410
|
editor.data.get = (options) => {
|
|
413
|
-
|
|
414
|
-
return Parser.endParse(
|
|
411
|
+
let output = get.bind(editor.data)(options);
|
|
412
|
+
return Parser.endParse(output);
|
|
415
413
|
};
|
|
416
414
|
}
|
|
417
415
|
|