@wiris/mathtype-tinymce6 8.9.0 → 8.9.2

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.
@@ -1,11 +1,11 @@
1
- import IntegrationModel from '@wiris/mathtype-html-integration-devkit/src/integrationmodel';
2
- import Configuration from '@wiris/mathtype-html-integration-devkit/src/configuration';
3
- import Parser from '@wiris/mathtype-html-integration-devkit/src/parser';
4
- import Util from '@wiris/mathtype-html-integration-devkit/src/util';
5
- import Listeners from '@wiris/mathtype-html-integration-devkit/src/listeners';
6
- import StringManager from '@wiris/mathtype-html-integration-devkit/src/stringmanager';
1
+ import IntegrationModel from "@wiris/mathtype-html-integration-devkit/src/integrationmodel";
2
+ import Configuration from "@wiris/mathtype-html-integration-devkit/src/configuration";
3
+ import Parser from "@wiris/mathtype-html-integration-devkit/src/parser";
4
+ import Util from "@wiris/mathtype-html-integration-devkit/src/util";
5
+ import Listeners from "@wiris/mathtype-html-integration-devkit/src/listeners";
6
+ import StringManager from "@wiris/mathtype-html-integration-devkit/src/stringmanager";
7
7
 
8
- import packageInfo from './package.json';
8
+ import packageInfo from "./package.json";
9
9
 
10
10
  /**
11
11
  * TinyMCE integration class. This class extends IntegrationModel class.
@@ -38,13 +38,14 @@ export class TinyMceIntegration extends IntegrationModel {
38
38
  */
39
39
  getPath() {
40
40
  if (this.isMoodle) {
41
- const search = 'lib/editor/tinymce';
41
+ const search = "lib/editor/tinymce";
42
42
  const pos = tinymce.baseURL.indexOf(search);
43
43
  const baseURL = tinymce.baseURL.substr(0, pos + search.length);
44
44
  return `${baseURL}/plugins/tiny_mce_wiris/tinymce/`;
45
- } if (this.isExternal) {
46
- const externalUrl = this.editorObject.options.get('external_plugins').tiny_mce_wiris;
47
- return externalUrl.substring(0, externalUrl.lastIndexOf('/') + 1);
45
+ }
46
+ if (this.isExternal) {
47
+ const externalUrl = this.editorObject.options.get("external_plugins").tiny_mce_wiris;
48
+ return externalUrl.substring(0, externalUrl.lastIndexOf("/") + 1);
48
49
  }
49
50
  return `${tinymce.baseURL}/plugins/tiny_mce_wiris/`;
50
51
  }
@@ -66,14 +67,14 @@ export class TinyMceIntegration extends IntegrationModel {
66
67
  const editorSettings = this.editorObject;
67
68
  // Try to get editorParameters.language, fail silently otherwise
68
69
  try {
69
- return editorSettings.options.get('mathTypeParameters').editorParameters.language;
70
+ return editorSettings.options.get("mathTypeParameters").editorParameters.language;
70
71
  } catch (e) {}
71
72
  // Get the deprecated wirisformulaeditorlang
72
- if (editorSettings.options.get('wirisformulaeditorlang')) {
73
- console.warn('Deprecated property wirisformulaeditorlang. Use mathTypeParameters on instead.');
74
- return editorSettings.options.get('wirisformulaeditorlang');
73
+ if (editorSettings.options.get("wirisformulaeditorlang")) {
74
+ console.warn("Deprecated property wirisformulaeditorlang. Use mathTypeParameters on instead.");
75
+ return editorSettings.options.get("wirisformulaeditorlang");
75
76
  }
76
- const langParam = this.editorObject.options.get('language');
77
+ const langParam = this.editorObject.options.get("language");
77
78
  return langParam || super.getLanguage();
78
79
  }
79
80
 
@@ -86,15 +87,19 @@ export class TinyMceIntegration extends IntegrationModel {
86
87
  super.callbackFunction();
87
88
 
88
89
  // Avoid to change class of image formulas.
89
- const imageClassName = Configuration.get('imageClassName');
90
+ const imageClassName = Configuration.get("imageClassName");
90
91
  if (this.isIframe) {
91
92
  // Attaching observers to wiris images.
92
- if (typeof Parser.observer !== 'undefined') {
93
- Array.prototype.forEach.call(this.target.contentDocument.getElementsByClassName(imageClassName), (wirisImages) => {
94
- Parser.observer.observe(wirisImages);
95
- });
93
+ if (typeof Parser.observer !== "undefined") {
94
+ Array.prototype.forEach.call(
95
+ this.target.contentDocument.getElementsByClassName(imageClassName),
96
+ (wirisImages) => {
97
+ Parser.observer.observe(wirisImages);
98
+ },
99
+ );
96
100
  }
97
- } else { // Inline.
101
+ } else {
102
+ // Inline.
98
103
  // Attaching observers to wiris images.
99
104
  Array.prototype.forEach.call(document.getElementsByClassName(imageClassName), (wirisImages) => {
100
105
  Parser.observer.observe(wirisImages);
@@ -103,9 +108,9 @@ export class TinyMceIntegration extends IntegrationModel {
103
108
 
104
109
  // When a formula is updated TinyMCE 'Change' event must be fired.
105
110
  // See https://www.tiny.cloud/docs/advanced/events/#change for further information.
106
- const listener = Listeners.newListener('onAfterFormulaInsertion', () => {
107
- if (typeof this.editorObject.fire !== 'undefined') {
108
- this.editorObject.fire('Change');
111
+ const listener = Listeners.newListener("onAfterFormulaInsertion", () => {
112
+ if (typeof this.editorObject.fire !== "undefined") {
113
+ this.editorObject.fire("Change");
109
114
  }
110
115
  });
111
116
  this.getCore().addListener(listener);
@@ -114,11 +119,11 @@ export class TinyMceIntegration extends IntegrationModel {
114
119
  // Avoid filter formulas with performance enabled.
115
120
  dataImgFiltered[this.editorObject.id] = this.editorObject.images_dataimg_filter;
116
121
  this.editorObject.images_dataimg_filter = (img) => {
117
- if (img.hasAttribute('class') && img.getAttribute('class').indexOf(Configuration.get('imageClassName')) !== -1) {
118
- return img.hasAttribute('internal-blob');
122
+ if (img.hasAttribute("class") && img.getAttribute("class").indexOf(Configuration.get("imageClassName")) !== -1) {
123
+ return img.hasAttribute("internal-blob");
119
124
  }
120
125
  // If the client put an image data filter, run. Otherwise default behaviour (put blob).
121
- if (typeof dataImgFiltered[this.editorObject.id] !== 'undefined') {
126
+ if (typeof dataImgFiltered[this.editorObject.id] !== "undefined") {
122
127
  return dataImgFiltered[this.editorObject.id](img);
123
128
  }
124
129
  return true;
@@ -130,8 +135,11 @@ export class TinyMceIntegration extends IntegrationModel {
130
135
  * @param {string} mathml - MathML to generate the formula and can be caught with the event.
131
136
  */
132
137
  updateFormula(mathml) {
133
- if (typeof this.editorObject.fire !== 'undefined') {
134
- this.editorObject.fire('ExecCommand', { command: 'updateFormula', value: mathml });
138
+ if (typeof this.editorObject.fire !== "undefined") {
139
+ this.editorObject.fire("ExecCommand", {
140
+ command: "updateFormula",
141
+ value: mathml,
142
+ });
135
143
  }
136
144
  super.updateFormula(mathml);
137
145
  }
@@ -154,22 +162,22 @@ export class TinyMceIntegration extends IntegrationModel {
154
162
  * @param {string} editor - Editor instance.
155
163
  * @param {string} pluginName - TinyMCE 6 plugin name.
156
164
  */
157
- registerMoodleOption (editor, pluginName) {
165
+ registerMoodleOption(editor, pluginName) {
158
166
  const registerOption = editor.options.register;
159
167
 
160
168
  registerOption(`${pluginName}:filterEnabled`, {
161
- processor: 'boolean',
162
- 'default': false,
169
+ processor: "boolean",
170
+ default: false,
163
171
  });
164
172
 
165
173
  registerOption(`${pluginName}:editorEnabled`, {
166
- processor: 'boolean',
167
- 'default': false,
174
+ processor: "boolean",
175
+ default: false,
168
176
  });
169
177
 
170
178
  registerOption(`${pluginName}:chemistryEnabled`, {
171
- processor: 'boolean',
172
- 'default': false,
179
+ processor: "boolean",
180
+ default: false,
173
181
  });
174
182
  }
175
183
  }
@@ -193,23 +201,24 @@ export const currentInstance = null;
193
201
  with the TinyMCE instance and using the `external_plugins` option.
194
202
  */
195
203
  (function () {
196
- const isMoodle = !!((typeof M === 'object' && M !== null)); // eslint-disable-line no-undef;
197
- const pluginName = isMoodle ? 'tiny_wiris/plugin' : 'tiny_mce_wiris';
204
+ const isMoodle = !!(typeof M === "object" && M !== null); // eslint-disable-line no-undef;
205
+ const pluginName = isMoodle ? "tiny_wiris/plugin" : "tiny_mce_wiris";
198
206
 
199
- tinymce.PluginManager.add(pluginName, (editor, url) => ({ // eslint-disable-line no-unused-vars
207
+ tinymce.PluginManager.add(pluginName, (editor, url) => ({
208
+ // eslint-disable-line no-unused-vars
200
209
  init(editor) {
201
210
  const callbackMethodArguments = {};
202
211
 
203
212
  /**
204
- * Integration model properties
205
- * @type {Object}
206
- * @property {Object} target - Integration DOM target.
207
- * @property {String} configurationService - Configuration integration service.
208
- * @property {String} version - Plugin version.
209
- * @property {String} scriptName - Integration script name.
210
- * @property {Object} environment - Integration environment properties.
211
- * @property {String} editor - Editor name.
212
- */
213
+ * Integration model properties
214
+ * @type {Object}
215
+ * @property {Object} target - Integration DOM target.
216
+ * @property {String} configurationService - Configuration integration service.
217
+ * @property {String} version - Plugin version.
218
+ * @property {String} scriptName - Integration script name.
219
+ * @property {Object} environment - Integration environment properties.
220
+ * @property {String} editor - Editor name.
221
+ */
213
222
  const integrationModelProperties = {};
214
223
  integrationModelProperties.serviceProviderProperties = {
215
224
  URI: process.env.SERVICE_PROVIDER_URI,
@@ -219,30 +228,37 @@ export const currentInstance = null;
219
228
  integrationModelProperties.isMoodle = isMoodle; // eslint-disable-line no-undef
220
229
  if (integrationModelProperties.isMoodle) {
221
230
  // eslint-disable-next-line no-undef
222
- integrationModelProperties.configurationService = M.cfg.wwwroot + '/filter/wiris/integration/configurationjs.php'; // eslint-disable-line prefer-template
231
+ integrationModelProperties.configurationService =
232
+ M.cfg.wwwroot + "/filter/wiris/integration/configurationjs.php"; // eslint-disable-line prefer-template
223
233
  }
224
- if (typeof (editor.options.get('wiriscontextpath')) !== 'undefined') {
225
- integrationModelProperties.configurationService = Util.concatenateUrl(editor.options.get('wiriscontextpath'), integrationModelProperties.configurationService);
226
- `${editor.options.get('wiriscontextpath')}/${integrationModelProperties.configurationService}`; // eslint-disable-line no-unused-expressions
227
- console.warn('Deprecated property wiriscontextpath. Use mathTypeParameters instead.', editor.opts.wiriscontextpath);
234
+ if (typeof editor.options.get("wiriscontextpath") !== "undefined") {
235
+ integrationModelProperties.configurationService = Util.concatenateUrl(
236
+ editor.options.get("wiriscontextpath"),
237
+ integrationModelProperties.configurationService,
238
+ );
239
+ `${editor.options.get("wiriscontextpath")}/${integrationModelProperties.configurationService}`; // eslint-disable-line no-unused-expressions
240
+ console.warn(
241
+ "Deprecated property wiriscontextpath. Use mathTypeParameters instead.",
242
+ editor.opts.wiriscontextpath,
243
+ );
228
244
  }
229
245
 
230
246
  // Overriding MathType integration parameters.
231
247
 
232
248
  // Register our custom parameters inside TinyMCE's options
233
- editor.options.register('mathTypeParameters', {
234
- processor: 'object',
249
+ editor.options.register("mathTypeParameters", {
250
+ processor: "object",
235
251
  default: {},
236
252
  });
237
253
 
238
- if (editor.options.isRegistered('mathTypeParameters')) {
239
- integrationModelProperties.integrationParameters = editor.options.get('mathTypeParameters');
254
+ if (editor.options.isRegistered("mathTypeParameters")) {
255
+ integrationModelProperties.integrationParameters = editor.options.get("mathTypeParameters");
240
256
  }
241
257
 
242
- integrationModelProperties.scriptName = 'plugin.min.js';
258
+ integrationModelProperties.scriptName = "plugin.min.js";
243
259
  integrationModelProperties.environment = {};
244
260
 
245
- integrationModelProperties.environment.editor = 'TinyMCE 6.x';
261
+ integrationModelProperties.environment.editor = "TinyMCE 6.x";
246
262
  integrationModelProperties.environment.editorVersion = `${tinymce.majorVersion}.${tinymce.minorVersion}`;
247
263
 
248
264
  integrationModelProperties.callbackMethodArguments = callbackMethodArguments;
@@ -252,27 +268,31 @@ export const currentInstance = null;
252
268
  // However, as TinyMCE is not initialized at this point the HTML target is not created.
253
269
  // Here we create the target as null and onInit object the target is updated.
254
270
  integrationModelProperties.target = null;
255
- const isExternalPlugin = typeof (editor.options.get('external_plugins')) !== 'undefined' && 'tiny_mce_wiris' in editor.options.get('external_plugins');
271
+ const isExternalPlugin =
272
+ typeof editor.options.get("external_plugins") !== "undefined" &&
273
+ "tiny_mce_wiris" in editor.options.get("external_plugins");
256
274
  integrationModelProperties.isExternal = isExternalPlugin;
257
- integrationModelProperties.rtl = (editor.options.get('directionality') === 'rtl');
275
+ integrationModelProperties.rtl = editor.options.get("directionality") === "rtl";
258
276
 
259
277
  // Set Moodle configurations for Telemetry purposes.
260
278
  const registerOption = editor.options.register;
261
279
  registerOption(`${pluginName}:moodleCourseCategory`, {
262
- processor: 'integer',
263
- 'default': undefined
280
+ processor: "integer",
281
+ default: undefined,
264
282
  });
265
283
  registerOption(`${pluginName}:moodleCourseName`, {
266
- processor: 'string',
267
- 'default': undefined
284
+ processor: "string",
285
+ default: undefined,
268
286
  });
269
287
  registerOption(`${pluginName}:moodleVersion`, {
270
- processor: 'integer',
271
- 'default': undefined
288
+ processor: "integer",
289
+ default: undefined,
272
290
  });
273
291
 
274
292
  integrationModelProperties.environment.moodleVersion = editor.options.get(`${pluginName}:moodleVersion`);
275
- integrationModelProperties.environment.moodleCourseCategory = editor.options.get(`${pluginName}:moodleCourseCategory`);
293
+ integrationModelProperties.environment.moodleCourseCategory = editor.options.get(
294
+ `${pluginName}:moodleCourseCategory`,
295
+ );
276
296
  integrationModelProperties.environment.moodleCourseName = editor.options.get(`${pluginName}:moodleCourseName`);
277
297
 
278
298
  // GenericIntegration instance.
@@ -286,7 +306,8 @@ export const currentInstance = null;
286
306
  tinyMceIntegrationInstance.registerMoodleOption(editor, pluginName);
287
307
  }
288
308
 
289
- const onInit = function (editor) { // eslint-disable-line no-shadow
309
+ const onInit = function (editor) {
310
+ // eslint-disable-line no-shadow
290
311
  const integrationInstance = WirisPlugin.instances[tinyMceIntegrationInstance.editorObject.id];
291
312
  if (!editor.inline) {
292
313
  integrationInstance.setTarget(editor.getContentAreaContainer().firstChild);
@@ -294,28 +315,43 @@ export const currentInstance = null;
294
315
  integrationInstance.setTarget(editor.getElement());
295
316
  }
296
317
  integrationInstance.setEditorObject(editor);
297
- integrationInstance.listeners.fire('onTargetReady', {});
298
- if (editor.options.isRegistered('mathTypeParameters')) {
299
- Configuration.update('editorParameters', editor.options.get('mathTypeParameters'));
318
+ integrationInstance.listeners.fire("onTargetReady", {});
319
+ if (editor.options.isRegistered("mathTypeParameters")) {
320
+ Configuration.update("editorParameters", editor.options.get("mathTypeParameters"));
300
321
  }
301
322
 
302
323
  // Prevent TinyMCE attributes insertion.
303
324
  // TinyMCE insert attributes only when a new node is inserted.
304
325
  // For this reason, the mutation observer only acts on addedNodes.
305
- const mutationInstance = new MutationObserver(function (editor, mutations) { // eslint-disable-line no-shadow
306
- Array.prototype.forEach.call(mutations, function (editor, mutation) { // eslint-disable-line no-shadow
307
- Array.prototype.forEach.call(mutation.addedNodes, function (editor, node) { // eslint-disable-line no-shadow
308
- if (node.nodeType === 1) {
309
- // Act only in our own formulas.
310
- Array.prototype.forEach.call(node.querySelectorAll(`.${WirisPlugin.Configuration.get('imageClassName')}`), ((editor, image) => { // eslint-disable-line no-shadow
311
- // This only is executed due to init parse.
312
- image.removeAttribute('data-mce-src');
313
- image.removeAttribute('data-mce-style');
314
- }).bind(this, editor));
315
- }
316
- }.bind(this, editor));
317
- }.bind(this, editor));
318
- }.bind(this, editor));
326
+ const mutationInstance = new MutationObserver(
327
+ function (editor, mutations) {
328
+ // eslint-disable-line no-shadow
329
+ Array.prototype.forEach.call(
330
+ mutations,
331
+ function (editor, mutation) {
332
+ // eslint-disable-line no-shadow
333
+ Array.prototype.forEach.call(
334
+ mutation.addedNodes,
335
+ function (editor, node) {
336
+ // eslint-disable-line no-shadow
337
+ if (node.nodeType === 1) {
338
+ // Act only in our own formulas.
339
+ Array.prototype.forEach.call(
340
+ node.querySelectorAll(`.${WirisPlugin.Configuration.get("imageClassName")}`),
341
+ ((editor, image) => {
342
+ // eslint-disable-line no-shadow
343
+ // This only is executed due to init parse.
344
+ image.removeAttribute("data-mce-src");
345
+ image.removeAttribute("data-mce-style");
346
+ }).bind(this, editor),
347
+ );
348
+ }
349
+ }.bind(this, editor),
350
+ );
351
+ }.bind(this, editor),
352
+ );
353
+ }.bind(this, editor),
354
+ );
319
355
  mutationInstance.observe(editor.getBody(), {
320
356
  attributes: true,
321
357
  childList: true,
@@ -326,7 +362,7 @@ export const currentInstance = null;
326
362
  const content = editor.getContent();
327
363
  // We set content in html because other tiny plugins need data-mce
328
364
  // and this is not possible with raw format.
329
- editor.setContent(Parser.initParse(content, editor.options.get('language')), { format: 'html' });
365
+ editor.setContent(Parser.initParse(content, editor.options.get("language")), { format: "html" });
330
366
  // This clean undoQueue for prevent onChange and Dirty state.
331
367
  editor.undoManager.clear();
332
368
  // Init parsing OK. If a setContent method is called
@@ -336,62 +372,76 @@ export const currentInstance = null;
336
372
  WirisPlugin.instances[editor.id].initParsed = true;
337
373
  };
338
374
 
339
- if ('onInit' in editor) {
375
+ // Change the destroy behavior to also destroy the MathType instance.
376
+ const destroy = editor.destroy;
377
+
378
+ editor.destroy = function () {
379
+ WirisPlugin.instances[editor.id].listeners.fire("onDestroy", {});
380
+
381
+ // Destroy the Mathtype instance.
382
+ WirisPlugin.instances[editor.id].destroy();
383
+ destroy.call(editor);
384
+ };
385
+
386
+ if ("onInit" in editor) {
340
387
  editor.onInit.add(onInit);
341
388
  } else {
342
- editor.on('init', () => {
389
+ editor.on("init", () => {
343
390
  onInit(editor);
344
391
  });
345
392
  }
346
393
 
347
- if ('onActivate' in editor) {
348
- editor.onActivate.add((editor) => { // eslint-disable-line no-unused-vars, no-shadow
394
+ if ("onActivate" in editor) {
395
+ editor.onActivate.add((editor) => {
396
+ // eslint-disable-line no-unused-vars, no-shadow
349
397
  WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];
350
398
  });
351
399
  } else {
352
- editor.on('focus', (event) => { // eslint-disable-line no-unused-vars, no-shadow
400
+ editor.on("focus", (event) => {
401
+ // eslint-disable-line no-unused-vars, no-shadow
353
402
  WirisPlugin.currentInstance = WirisPlugin.instances[tinymce.activeEditor.id];
354
403
  });
355
404
  }
356
405
 
357
- const onSave = function (editor, params) { // eslint-disable-line no-shadow
406
+ const onSave = function (editor, params) {
407
+ // eslint-disable-line no-shadow
358
408
  if (integrationModelProperties.isMoodle) {
359
- params.content = Parser.endParseSaveMode(params.content, editor.getParam('language'));
409
+ params.content = Parser.endParseSaveMode(params.content, editor.getParam("language"));
360
410
  } else {
361
- params.content = Parser.endParse(params.content, editor.getParam('language'));
411
+ params.content = Parser.endParse(params.content, editor.getParam("language"));
362
412
  }
363
413
  };
364
414
 
365
- if ('onSaveContent' in editor) {
415
+ if ("onSaveContent" in editor) {
366
416
  editor.onSaveContent.add(onSave);
367
417
  } else {
368
- editor.on('saveContent', (params) => {
418
+ editor.on("saveContent", (params) => {
369
419
  onSave(editor, params);
370
420
  });
371
421
  }
372
422
 
373
- if ('onGetContent' in editor) {
423
+ if ("onGetContent" in editor) {
374
424
  editor.onGetContent.add(onSave);
375
425
  } else {
376
- editor.on('getContent', (params) => {
426
+ editor.on("getContent", (params) => {
377
427
  onSave(editor, params);
378
428
  });
379
429
  }
380
430
 
381
- if ('onBeforeSetContent' in editor) {
431
+ if ("onBeforeSetContent" in editor) {
382
432
  editor.onBeforeSetContent.add((e, params) => {
383
433
  if (integrationModelProperties.isMoodle) {
384
- params.content = Parser.initParseSaveMode(params.content, editor.getParam('language'));
434
+ params.content = Parser.initParseSaveMode(params.content, editor.getParam("language"));
385
435
  } else if (WirisPlugin.instances[editor.id].initParsed) {
386
- params.content = Parser.initParseSaveMode(params.content, editor.getParam('language'));
436
+ params.content = Parser.initParseSaveMode(params.content, editor.getParam("language"));
387
437
  }
388
438
  });
389
439
  } else {
390
- editor.on('beforeSetContent', (params) => {
440
+ editor.on("beforeSetContent", (params) => {
391
441
  if (integrationModelProperties.isMoodle) {
392
- params.content = Parser.initParseSaveMode(params.content, editor.getParam('language'));
442
+ params.content = Parser.initParseSaveMode(params.content, editor.getParam("language"));
393
443
  } else if (WirisPlugin.instances[editor.id].initParsed) {
394
- params.content = Parser.initParse(params.content, editor.getParam('language'));
444
+ params.content = Parser.initParse(params.content, editor.getParam("language"));
395
445
  }
396
446
  });
397
447
  }
@@ -404,34 +454,44 @@ export const currentInstance = null;
404
454
  }
405
455
 
406
456
  const commonEditor = editor.ui.registry;
407
- const mathTypeIcon = 'mathtypeicon';
408
- const chemTypeIcon = 'chemtypeicon';
409
- const mathTypeIconSvg = '<svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 300 261.7" style="enable-background:new 0 0 300 261.7;" xml:space="preserve"><g id=icon-wirisformula stroke="none" stroke-width="1" fill-rule="evenodd"><g><path class="st1" d="M90.2,257.7c-11.4,0-21.9-6.4-27-16.7l-60-119.9c-7.5-14.9-1.4-33.1,13.5-40.5c14.9-7.5,33.1-1.4,40.5,13.5l27.3,54.7L121.1,39c5.3-15.8,22.4-24.4,38.2-19.1c15.8,5.3,24.4,22.4,19.1,38.2l-59.6,179c-3.9,11.6-14.3,19.7-26.5,20.6C91.6,257.7,90.9,257.7,90.2,257.7"/></g></g><g><g><path class="st2" d="M300,32.8c0-16.4-13.4-29.7-29.9-29.7c-2.9,0-7.2,0.8-7.2,0.8c-37.9,9.1-71.3,14-112,14c-0.3,0-0.6,0-1,0c-16.5,0-29.9,13.3-29.9,29.7c0,16.4,13.4,29.7,29.9,29.7l0,0c45.3,0,83.1-5.3,125.3-15.3h0C289.3,59.5,300,47.4,300,32.8"/></g></g></svg>'; // eslint-disable-line max-len
410
- const chemTypeIconSvg = '<svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 40.3 49.5" style="enable-background:new 0 0 40.3 49.5;" xml:space="preserve"><g id=icon-wirisformula stroke="none" stroke-width="1" fill-rule="evenodd"><g><path class="st1" 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 l0,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 l12.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 c0.7,0.4,1.5,0.6,2.4,0.6C37,17,39.2,14.8,39.2,12.1"/></g></g></svg>'
457
+ const mathTypeIcon = "mathtypeicon";
458
+ const chemTypeIcon = "chemtypeicon";
459
+ const mathTypeIconSvg =
460
+ '<svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 300 261.7" style="enable-background:new 0 0 300 261.7;" xml:space="preserve"><g id=icon-wirisformula stroke="none" stroke-width="1" fill-rule="evenodd"><g><path class="st1" d="M90.2,257.7c-11.4,0-21.9-6.4-27-16.7l-60-119.9c-7.5-14.9-1.4-33.1,13.5-40.5c14.9-7.5,33.1-1.4,40.5,13.5l27.3,54.7L121.1,39c5.3-15.8,22.4-24.4,38.2-19.1c15.8,5.3,24.4,22.4,19.1,38.2l-59.6,179c-3.9,11.6-14.3,19.7-26.5,20.6C91.6,257.7,90.9,257.7,90.2,257.7"/></g></g><g><g><path class="st2" d="M300,32.8c0-16.4-13.4-29.7-29.9-29.7c-2.9,0-7.2,0.8-7.2,0.8c-37.9,9.1-71.3,14-112,14c-0.3,0-0.6,0-1,0c-16.5,0-29.9,13.3-29.9,29.7c0,16.4,13.4,29.7,29.9,29.7l0,0c45.3,0,83.1-5.3,125.3-15.3h0C289.3,59.5,300,47.4,300,32.8"/></g></g></svg>'; // eslint-disable-line max-len
461
+ const chemTypeIconSvg =
462
+ '<svg width="16" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"viewBox="0 0 40.3 49.5" style="enable-background:new 0 0 40.3 49.5;" xml:space="preserve"><g id=icon-wirisformula stroke="none" stroke-width="1" fill-rule="evenodd"><g><path class="st1" 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 l0,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 l12.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 c0.7,0.4,1.5,0.6,2.4,0.6C37,17,39.2,14.8,39.2,12.1"/></g></g></svg>';
411
463
 
412
464
  commonEditor.addIcon(mathTypeIcon, mathTypeIconSvg);
413
465
  commonEditor.addIcon(chemTypeIcon, chemTypeIconSvg);
414
466
 
415
467
  // Get editor language code
416
- let lang_code = editor.options.get('language');
417
- lang_code = (lang_code.split("-")[0]).split("_")[0];
468
+ let lang_code = editor.options.get("language");
469
+ lang_code = lang_code.split("-")[0].split("_")[0];
418
470
 
419
471
  // Check If MathType/ChemType are enabled on Moodle
420
- const editorEnabled = !isMoodle || (isMoodle && editor.options.get(`${pluginName}:editorEnabled`) && editor.options.get(`${pluginName}:filterEnabled`));
421
- const chemEnabled = !isMoodle || (isMoodle && editor.options.get(`${pluginName}:chemistryEnabled`) && editor.options.get(`${pluginName}:filterEnabled`));
472
+ const editorEnabled =
473
+ !isMoodle ||
474
+ (isMoodle &&
475
+ editor.options.get(`${pluginName}:editorEnabled`) &&
476
+ editor.options.get(`${pluginName}:filterEnabled`));
477
+ const chemEnabled =
478
+ !isMoodle ||
479
+ (isMoodle &&
480
+ editor.options.get(`${pluginName}:chemistryEnabled`) &&
481
+ editor.options.get(`${pluginName}:filterEnabled`));
422
482
 
423
483
  if (editorEnabled) {
424
484
  // The next two blocks create menu items to give the possibility
425
485
  // of add MathType in the menubar.
426
- commonEditor.addMenuItem('tiny_mce_wiris_formulaEditor', {
427
- text: 'MathType',
486
+ commonEditor.addMenuItem("tiny_mce_wiris_formulaEditor", {
487
+ text: "MathType",
428
488
  icon: mathTypeIcon,
429
489
  onAction: openFormulaEditorFunction,
430
490
  });
431
491
 
432
492
  // MathType button.
433
- commonEditor.addButton('tiny_mce_wiris_formulaEditor', {
434
- tooltip: StringManager.get('insert_math', lang_code),
493
+ commonEditor.addButton("tiny_mce_wiris_formulaEditor", {
494
+ tooltip: StringManager.get("insert_math", lang_code),
435
495
  image: `${WirisPlugin.instances[editor.id].getIconsPath()}formula.png`,
436
496
  onAction: openFormulaEditorFunction,
437
497
  icon: mathTypeIcon,
@@ -465,7 +525,7 @@ export const currentInstance = null;
465
525
  }
466
526
  editor.addCommand(cmd, commandFunction);
467
527
  commonEditor.addButton(`tiny_mce_wiris_formulaEditor${customEditors.editors[customEditor].name}`, {
468
- tooltip: StringManager.get('insert_chem', lang_code),
528
+ tooltip: StringManager.get("insert_chem", lang_code),
469
529
  onAction: commandFunction,
470
530
  image: WirisPlugin.instances[editor.id].getIconsPath() + customEditors.editors[customEditor].icon,
471
531
  icon: chemTypeIcon, // At the moment only chemTypeIcon because of the provisional solution for TinyMCE6.
@@ -478,11 +538,11 @@ export const currentInstance = null;
478
538
  // All versions.
479
539
  getMetadata() {
480
540
  return {
481
- longname: 'tiny_mce_wiris',
482
- name: 'Maths for More',
483
- url: 'http://www.wiris.com',
541
+ longname: "tiny_mce_wiris",
542
+ name: "Maths for More",
543
+ url: "http://www.wiris.com",
484
544
  version: packageInfo.version,
485
545
  };
486
546
  },
487
547
  }));
488
- }());
548
+ })();
package/global.js CHANGED
@@ -1,14 +1,14 @@
1
- import Core from '@wiris/mathtype-html-integration-devkit/src/core.src';
2
- import Parser from '@wiris/mathtype-html-integration-devkit/src/parser';
3
- import Util from '@wiris/mathtype-html-integration-devkit/src/util';
4
- import Image from '@wiris/mathtype-html-integration-devkit/src/image';
5
- import Configuration from '@wiris/mathtype-html-integration-devkit/src/configuration';
6
- import Listeners from '@wiris/mathtype-html-integration-devkit/src/listeners';
7
- import IntegrationModel from '@wiris/mathtype-html-integration-devkit/src/integrationmodel';
8
- import Latex from '@wiris/mathtype-html-integration-devkit/src/latex';
9
- import '@wiris/mathtype-html-integration-devkit/src/backwardslib';
10
- import Test from '@wiris/mathtype-html-integration-devkit/src/test';
11
- import { TinyMceIntegration, currentInstance, instances } from './editor_plugin.src';
1
+ import Core from "@wiris/mathtype-html-integration-devkit/src/core.src";
2
+ import Parser from "@wiris/mathtype-html-integration-devkit/src/parser";
3
+ import Util from "@wiris/mathtype-html-integration-devkit/src/util";
4
+ import Image from "@wiris/mathtype-html-integration-devkit/src/image";
5
+ import Configuration from "@wiris/mathtype-html-integration-devkit/src/configuration";
6
+ import Listeners from "@wiris/mathtype-html-integration-devkit/src/listeners";
7
+ import IntegrationModel from "@wiris/mathtype-html-integration-devkit/src/integrationmodel";
8
+ import Latex from "@wiris/mathtype-html-integration-devkit/src/latex";
9
+ import "@wiris/mathtype-html-integration-devkit/src/backwardslib";
10
+ import Test from "@wiris/mathtype-html-integration-devkit/src/test";
11
+ import { TinyMceIntegration, currentInstance, instances } from "./editor_plugin.src";
12
12
 
13
13
  // Expose WirisPlugin variable to the window.
14
14
  window.WirisPlugin = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiris/mathtype-tinymce6",
3
- "version": "8.9.0",
3
+ "version": "8.9.2",
4
4
  "description": "MathType Web for TinyMCE6 editor",
5
5
  "keywords": [
6
6
  "chem",
@@ -32,17 +32,15 @@
32
32
  "prepack": "yarn && npm run build"
33
33
  },
34
34
  "dependencies": {
35
- "@wiris/mathtype-html-integration-devkit": "1.17.0"
35
+ "@wiris/mathtype-html-integration-devkit": "1.17.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@babel/core": "^7.15.0",
39
- "@babel/preset-env": "^7.15.0",
40
- "babel-loader": "^8.2.2",
41
- "css-loader": "^5.2.4",
42
- "raw-loader": "^4.0.2",
43
- "shx": "^0.3.3",
44
- "style-loader": "^3.3.0",
45
- "terser-webpack-plugin": "^5.3.0",
46
- "url-loader": "^4.1.1"
38
+ "@babel/core": "^7.24.4",
39
+ "@babel/preset-env": "^7.24.4",
40
+ "babel-loader": "^9.1.3",
41
+ "css-loader": "^7.1.0",
42
+ "shx": "^0.3.4",
43
+ "style-loader": "^4.0.0",
44
+ "terser-webpack-plugin": "^5.3.10"
47
45
  }
48
46
  }