|
| 1 | +// Load styles. |
| 2 | +import "./static/style.css"; |
| 3 | + |
| 4 | +// Load the file that contains common imports between demos. |
| 5 | +import * as Generic from "resources/demos/imports"; |
| 6 | + |
| 7 | +// Apply specific demo names to all the objects. |
| 8 | +document.getElementById("header_title_name").innerHTML = "MathType for TinyMCE 7 on HTML"; |
| 9 | +document.getElementById("version_editor").innerHTML = "TinyMCE: "; |
| 10 | + |
| 11 | +// Copy the editor content before initializing it. |
| 12 | +// Currently disabled by decision of QA. |
| 13 | +// Generic.copyContentFromxToy('editor', 'transform_content'); |
| 14 | + |
| 15 | +// Set up the editor. |
| 16 | +tinymce.init({ |
| 17 | + selector: "#editor", |
| 18 | + license_key: "gpl", |
| 19 | + external_plugins: { |
| 20 | + tiny_mce_wiris: `${window.location.href}dist/plugin.min.js`, |
| 21 | + }, |
| 22 | + |
| 23 | + // This option allows us to introduce mathml formulas |
| 24 | + extended_valid_elements: "*[.*]", |
| 25 | + valid_elements: "*[*]", |
| 26 | + // We recommend to set 'draggable_modal' to true to avoid overlapping issues |
| 27 | + // with the different UI modal dialog windows implementations between core and third-party plugins on TinyMCE. |
| 28 | + // @see: https://github.com/wiris/html-integrations/issues/134#issuecomment-905448642 |
| 29 | + draggable_modal: true, |
| 30 | + plugins: ["image", "media"], |
| 31 | + toolbar: |
| 32 | + "undo redo | styleselect | bold italic | image media | tiny_mce_wiris_formulaEditor tiny_mce_wiris_formulaEditorChemistry", |
| 33 | + |
| 34 | + // language: 'fr_FR', |
| 35 | + // You could set a different language for MathType editor: |
| 36 | + // mathTypeParameters: { |
| 37 | + // editorParameters: { language: 'de' }, |
| 38 | + // }, |
| 39 | + |
| 40 | + // Handle events. |
| 41 | + setup(editor) { |
| 42 | + // Launch on init event. |
| 43 | + editor.on("init", () => { |
| 44 | + // Get and set the editor and wiris versions in this order. |
| 45 | + Generic.setEditorAndWirisVersion( |
| 46 | + `${tinymce.majorVersion}.${tinymce.minorVersion}`, |
| 47 | + WirisPlugin.currentInstance.version, |
| 48 | + ); //eslint-disable-line |
| 49 | + |
| 50 | + // Insert the initial content in the editor. |
| 51 | + editor.setContent(Generic.editorContentMathML); |
| 52 | + }); |
| 53 | + }, |
| 54 | +}); |
| 55 | + |
| 56 | +// Add listener on click button to launch updateContent function. |
| 57 | +document.getElementById("btn_update").addEventListener("click", (e) => { |
| 58 | + e.preventDefault(); |
| 59 | + Generic.updateContent(tinyMCE.activeEditor.getContent(), "transform_content"); // eslint-disable-line no-undef |
| 60 | +}); |
0 commit comments