@wiris/mathtype-ckeditor5 8.13.4 → 8.15.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.js +147 -71
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +147 -71
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/integration.js +10 -6
- package/src/plugin.js +24 -1
package/src/integration.js
CHANGED
|
@@ -43,11 +43,10 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
43
43
|
const languageObject = this.editorObject.config.get("language");
|
|
44
44
|
if (languageObject != null) {
|
|
45
45
|
if (typeof languageObject === "object") {
|
|
46
|
-
|
|
47
|
-
if (languageObject.hasOwnProperty("ui")) {
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(languageObject, "ui")) {
|
|
48
47
|
return languageObject.ui;
|
|
49
48
|
}
|
|
50
|
-
return
|
|
49
|
+
return this.editorObject.locale.uiLanguage;
|
|
51
50
|
}
|
|
52
51
|
return languageObject;
|
|
53
52
|
}
|
|
@@ -171,7 +170,10 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
171
170
|
// Remove selection
|
|
172
171
|
if (!viewSelection.isCollapsed) {
|
|
173
172
|
for (const range of viewSelection.getRanges()) {
|
|
174
|
-
|
|
173
|
+
const modelRange = this.editorObject.editing.mapper.toModelRange(range);
|
|
174
|
+
const modelSelection = this.editorObject.model.createSelection(modelRange);
|
|
175
|
+
|
|
176
|
+
this.editorObject.model.deleteContent(modelSelection);
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -190,7 +192,7 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
190
192
|
if (mathml) {
|
|
191
193
|
this.editorObject.model.insertObject(modelElementNew, position);
|
|
192
194
|
}
|
|
193
|
-
|
|
195
|
+
this.editorObject.model.deleteContent(this.editorObject.model.createSelection(modelElementOld,'on'));
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
// eslint-disable-next-line consistent-return
|
|
@@ -281,7 +283,9 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
281
283
|
}
|
|
282
284
|
}
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
const modelSelection = this.editorObject.model.createSelection(range);
|
|
287
|
+
|
|
288
|
+
this.editorObject.model.deleteContent(modelSelection);
|
|
285
289
|
writer.insertText(`$$${returnObject.latex}$$`, startNode.getAttributes(), startPosition);
|
|
286
290
|
});
|
|
287
291
|
} else {
|
package/src/plugin.js
CHANGED
|
@@ -43,7 +43,10 @@ export default class MathType extends Plugin {
|
|
|
43
43
|
currentInstance = integration;
|
|
44
44
|
|
|
45
45
|
// Add the MathType and ChemType commands to the editor
|
|
46
|
-
this._addCommands();
|
|
46
|
+
this._addCommands(integration);
|
|
47
|
+
|
|
48
|
+
// Add the track changes feature integration
|
|
49
|
+
this._addTrackChangesIntegration(integration);
|
|
47
50
|
|
|
48
51
|
// Add the buttons for MathType and ChemType
|
|
49
52
|
this._addViews(integration);
|
|
@@ -579,4 +582,24 @@ export default class MathType extends Plugin {
|
|
|
579
582
|
Latex,
|
|
580
583
|
};
|
|
581
584
|
}
|
|
585
|
+
|
|
586
|
+
_addTrackChangesIntegration(integration) {
|
|
587
|
+
const { editor } = this;
|
|
588
|
+
|
|
589
|
+
if (editor.plugins.has("TrackChangesEditing")) {
|
|
590
|
+
const trackChangesEditing = editor.plugins.get("TrackChangesEditing");
|
|
591
|
+
|
|
592
|
+
// Makes MathType and ChemType buttons available when editor is in the track changes mode
|
|
593
|
+
trackChangesEditing.enableCommand("MathType");
|
|
594
|
+
trackChangesEditing.enableCommand("ChemType");
|
|
595
|
+
|
|
596
|
+
// Adds custom label replacing the default 'mathml'.
|
|
597
|
+
// Handles both singular and plural forms.
|
|
598
|
+
trackChangesEditing.descriptionFactory.registerElementLabel(
|
|
599
|
+
"mathml",
|
|
600
|
+
quantity => (quantity > 1 ? quantity + ' ' : '') +
|
|
601
|
+
StringManager.get(quantity > 1 ? "formulas" : "formula", integration.getLanguage()),
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
582
605
|
}
|