@wiris/mathtype-ckeditor5 8.14.0 → 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 +32 -7
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.js +32 -7
- package/dist/browser/index.umd.js.map +1 -1
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/integration.js +8 -3
- package/src/plugin.js +24 -1
package/src/integration.js
CHANGED
|
@@ -170,7 +170,10 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
170
170
|
// Remove selection
|
|
171
171
|
if (!viewSelection.isCollapsed) {
|
|
172
172
|
for (const range of viewSelection.getRanges()) {
|
|
173
|
-
|
|
173
|
+
const modelRange = this.editorObject.editing.mapper.toModelRange(range);
|
|
174
|
+
const modelSelection = this.editorObject.model.createSelection(modelRange);
|
|
175
|
+
|
|
176
|
+
this.editorObject.model.deleteContent(modelSelection);
|
|
174
177
|
}
|
|
175
178
|
}
|
|
176
179
|
|
|
@@ -189,7 +192,7 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
189
192
|
if (mathml) {
|
|
190
193
|
this.editorObject.model.insertObject(modelElementNew, position);
|
|
191
194
|
}
|
|
192
|
-
|
|
195
|
+
this.editorObject.model.deleteContent(this.editorObject.model.createSelection(modelElementOld,'on'));
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
// eslint-disable-next-line consistent-return
|
|
@@ -280,7 +283,9 @@ export default class CKEditor5Integration extends IntegrationModel {
|
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
285
|
|
|
283
|
-
|
|
286
|
+
const modelSelection = this.editorObject.model.createSelection(range);
|
|
287
|
+
|
|
288
|
+
this.editorObject.model.deleteContent(modelSelection);
|
|
284
289
|
writer.insertText(`$$${returnObject.latex}$$`, startNode.getAttributes(), startPosition);
|
|
285
290
|
});
|
|
286
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
|
}
|