File modules/editor/trumbowyg/plugins/mathml/trumbowyg.mathml.js

Last commit: Tue Aug 28 00:33:27 2018 +0200	Jan Dankert	Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.
1 /* =========================================================== 2 * trumbowyg.mathMl.js v1.0 3 * MathML plugin for Trumbowyg 4 * https://github.com/loclamor/Trumbowyg/tree/mathml-plugin/plugins/mathml 5 * =========================================================== 6 * Author : loclamor 7 */ 8 9 /* globals MathJax */ 10 (function($) { 11 'use strict'; 12 $.extend(true, $.trumbowyg, { 13 langs: { 14 en: { 15 mathml: 'Insert Formulas', 16 formulas: 'Formulas', 17 inline: 'Inline' 18 }, 19 fr: { 20 mathml: 'Inserer une formule', 21 formulas: 'Formule', 22 inline: 'En ligne' 23 }, 24 tr: { 25 mathml: 'Formül Ekle', 26 formulas: 'Formüller', 27 inline: 'Satır içi' 28 } 29 }, 30 plugins: { 31 mathml: { 32 init: function(trumbowyg) { 33 var btnDef = { 34 fn: function() { 35 trumbowyg.saveRange(); 36 var mathMLoptions = { 37 formulas: { 38 label: trumbowyg.lang.formulas, 39 required: true, 40 value: '' 41 }, 42 inline: { 43 label: trumbowyg.lang.inline, 44 attributes: { 45 checked: true 46 }, 47 type: 'checkbox', 48 required: false, 49 } 50 }; 51 52 var mathmlCallback = function(v) { 53 var delimitor = v.inline ? '$' : '$$'; 54 if (trumbowyg.currentMathNode) { 55 $(trumbowyg.currentMathNode).html(delimitor + ' ' + v.formulas + ' ' + delimitor).attr('formulas', v.formulas).attr('inline', (v.inline ? 'true' : 'false')); 56 } else { 57 var html = '<span class="mathMlContainer" contenteditable="false" formulas="' + v.formulas + '" inline="' + (v.inline ? 'true' : 'false') + '" >' + delimitor + ' ' + v.formulas + ' ' + delimitor + '</span>'; 58 var node = $(html)[0]; 59 node.onclick = function(e) { 60 trumbowyg.currentMathNode = this; 61 mathMLoptions.formulas.value = $(this).attr('formulas'); 62 if ($(this).attr('inline') === "true") { 63 mathMLoptions.inline.attributes.checked = true; 64 } else { 65 delete mathMLoptions.inline.attributes.checked; 66 } 67 trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMLoptions, mathmlCallback); 68 }; 69 trumbowyg.range.deleteContents(); 70 trumbowyg.range.insertNode(node); 71 } 72 73 trumbowyg.currentMathNode = false; 74 MathJax.Hub.Queue(['Typeset', MathJax.Hub]); 75 return true; 76 }; 77 78 mathMLoptions.formulas.value = trumbowyg.getRangeText(); 79 mathMLoptions.inline.attributes.checked = true; 80 trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMLoptions, mathmlCallback); 81 } 82 }; 83 trumbowyg.addBtnDef('mathml', btnDef); 84 } 85 } 86 } 87 }); 88 })(jQuery);
Download modules/editor/trumbowyg/plugins/mathml/trumbowyg.mathml.js
History Tue, 28 Aug 2018 00:33:27 +0200 Jan Dankert Editoren für Markdown (SimpleMDE) und HTML (Trumbowyg) installiert.