Inital
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
/* ===========================================================
|
||||
* trumbowyg.mathMl.js v1.0
|
||||
* MathML plugin for Trumbowyg
|
||||
* http://alex-d.github.com/Trumbowyg
|
||||
* ===========================================================
|
||||
* Author : loclamor
|
||||
*/
|
||||
|
||||
/* globals MathJax */
|
||||
(function($) {
|
||||
'use strict';
|
||||
$.extend(true, $.trumbowyg, {
|
||||
langs: {
|
||||
// jshint camelcase:false
|
||||
en: {
|
||||
mathml: 'Insert Formulas',
|
||||
formulas: 'Formulas',
|
||||
inline: 'Inline'
|
||||
},
|
||||
da: {
|
||||
mathml: 'Indsæt formler',
|
||||
formulas: 'Formler',
|
||||
inline: 'Inline'
|
||||
},
|
||||
et: {
|
||||
mathml: 'Sisesta valem',
|
||||
formulas: 'Valemid',
|
||||
inline: 'Teksti sees'
|
||||
},
|
||||
fr: {
|
||||
mathml: 'Inserer une formule',
|
||||
formulas: 'Formule',
|
||||
inline: 'En ligne'
|
||||
},
|
||||
hu: {
|
||||
mathml: 'Formulák beszúrás',
|
||||
formulas: 'Formulák',
|
||||
inline: 'Inline'
|
||||
},
|
||||
ko: {
|
||||
mathml: '수식 넣기',
|
||||
formulas: '수식',
|
||||
inline: '글 안에 넣기'
|
||||
},
|
||||
pt_br: {
|
||||
mathml: 'Inserir fórmulas',
|
||||
formulas: 'Fórmulas',
|
||||
inline: 'Em linha'
|
||||
},
|
||||
tr: {
|
||||
mathml: 'Formül Ekle',
|
||||
formulas: 'Formüller',
|
||||
inline: 'Satır içi'
|
||||
},
|
||||
zh_tw: {
|
||||
mathml: '插入方程式',
|
||||
formulas: '方程式',
|
||||
inline: '內嵌'
|
||||
},
|
||||
},
|
||||
// jshint camelcase:true
|
||||
|
||||
plugins: {
|
||||
mathml: {
|
||||
init: function(trumbowyg) {
|
||||
var btnDef = {
|
||||
fn: function() {
|
||||
trumbowyg.saveRange();
|
||||
var mathMLoptions = {
|
||||
formulas: {
|
||||
label: trumbowyg.lang.formulas,
|
||||
required: true,
|
||||
value: ''
|
||||
},
|
||||
inline: {
|
||||
label: trumbowyg.lang.inline,
|
||||
attributes: {
|
||||
checked: true
|
||||
},
|
||||
type: 'checkbox',
|
||||
required: false,
|
||||
}
|
||||
};
|
||||
|
||||
var mathmlCallback = function(v) {
|
||||
var delimiter = v.inline ? '$' : '$$';
|
||||
if (trumbowyg.currentMathNode) {
|
||||
$(trumbowyg.currentMathNode)
|
||||
.html(delimiter + ' ' + v.formulas + ' ' + delimiter)
|
||||
.attr('formulas', v.formulas)
|
||||
.attr('inline', (v.inline ? 'true' : 'false'));
|
||||
} else {
|
||||
var html = '<span class="mathMlContainer" contenteditable="false" formulas="' + v.formulas + '" inline="' + (v.inline ? 'true' : 'false') + '" >' + delimiter + ' ' + v.formulas + ' ' + delimiter + '</span>';
|
||||
var node = $(html)[0];
|
||||
node.onclick = function() {
|
||||
trumbowyg.currentMathNode = this;
|
||||
mathMLoptions.formulas.value = $(this).attr('formulas');
|
||||
|
||||
if ($(this).attr('inline') === 'true') {
|
||||
mathMLoptions.inline.attributes.checked = true;
|
||||
} else {
|
||||
delete mathMLoptions.inline.attributes.checked;
|
||||
}
|
||||
|
||||
trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMLoptions, mathmlCallback);
|
||||
};
|
||||
|
||||
trumbowyg.range.deleteContents();
|
||||
trumbowyg.range.insertNode(node);
|
||||
}
|
||||
|
||||
trumbowyg.currentMathNode = false;
|
||||
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
|
||||
return true;
|
||||
};
|
||||
|
||||
mathMLoptions.formulas.value = trumbowyg.getRangeText();
|
||||
mathMLoptions.inline.attributes.checked = true;
|
||||
trumbowyg.openModalInsert(trumbowyg.lang.mathml, mathMLoptions, mathmlCallback);
|
||||
}
|
||||
};
|
||||
trumbowyg.addBtnDef('mathml', btnDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
@@ -0,0 +1 @@
|
||||
!function(e){"use strict";e.extend(!0,e.trumbowyg,{langs:{en:{mathml:"Insert Formulas",formulas:"Formulas",inline:"Inline"},da:{mathml:"Indsæt formler",formulas:"Formler",inline:"Inline"},et:{mathml:"Sisesta valem",formulas:"Valemid",inline:"Teksti sees"},fr:{mathml:"Inserer une formule",formulas:"Formule",inline:"En ligne"},hu:{mathml:"Formulák beszúrás",formulas:"Formulák",inline:"Inline"},ko:{mathml:"수식 넣기",formulas:"수식",inline:"글 안에 넣기"},pt_br:{mathml:"Inserir fórmulas",formulas:"Fórmulas",inline:"Em linha"},tr:{mathml:"Formül Ekle",formulas:"Formüller",inline:"Satır içi"},zh_tw:{mathml:"插入方程式",formulas:"方程式",inline:"內嵌"}},plugins:{mathml:{init:function(l){var n={fn:function(){l.saveRange();var n={formulas:{label:l.lang.formulas,required:!0,value:""},inline:{label:l.lang.inline,attributes:{checked:!0},type:"checkbox",required:!1}},a=function(t){var r=t.inline?"$":"$$";if(l.currentMathNode)e(l.currentMathNode).html(r+" "+t.formulas+" "+r).attr("formulas",t.formulas).attr("inline",t.inline?"true":"false");else{var i='<span class="mathMlContainer" contenteditable="false" formulas="'+t.formulas+'" inline="'+(t.inline?"true":"false")+'" >'+r+" "+t.formulas+" "+r+"</span>",m=e(i)[0];m.onclick=function(){l.currentMathNode=this,n.formulas.value=e(this).attr("formulas"),"true"===e(this).attr("inline")?n.inline.attributes.checked=!0:delete n.inline.attributes.checked,l.openModalInsert(l.lang.mathml,n,a)},l.range.deleteContents(),l.range.insertNode(m)}return l.currentMathNode=!1,MathJax.Hub.Queue(["Typeset",MathJax.Hub]),!0};n.formulas.value=l.getRangeText(),n.inline.attributes.checked=!0,l.openModalInsert(l.lang.mathml,n,a)}};l.addBtnDef("mathml",n)}}}})}(jQuery);
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Trumbowyg v2.25.1 - A lightweight WYSIWYG editor
|
||||
* Default stylesheet for Trumbowyg editor plugin
|
||||
* ------------------------
|
||||
* @link http://alex-d.github.io/Trumbowyg
|
||||
* @license MIT
|
||||
* @author Alexandre Demode (Alex-D)
|
||||
* Twitter : @AlexandreDemode
|
||||
* Website : alex-d.fr
|
||||
*/
|
||||
|
||||
.mathMlContainer {
|
||||
position: relative;
|
||||
|
||||
&[inline="false"] {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
pointer-events: none;
|
||||
|
||||
&::after {
|
||||
content: '\270E';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(255, 255, 255, 0.83);
|
||||
box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83);
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Trumbowyg v2.25.1 - A lightweight WYSIWYG editor
|
||||
* Trumbowyg plugin stylesheet
|
||||
* ------------------------
|
||||
* @link http://alex-d.github.io/Trumbowyg
|
||||
* @license MIT
|
||||
* @author Alexandre Demode (Alex-D)
|
||||
* Twitter : @AlexandreDemode
|
||||
* Website : alex-d.fr
|
||||
*/
|
||||
|
||||
.mathMlContainer {
|
||||
position: relative; }
|
||||
.mathMlContainer[inline="false"] {
|
||||
display: block;
|
||||
width: 100%; }
|
||||
.mathMlContainer:hover {
|
||||
pointer-events: none; }
|
||||
.mathMlContainer:hover::after {
|
||||
content: '\270E';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: rgba(255, 255, 255, 0.83);
|
||||
-webkit-box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83);
|
||||
box-shadow: 0 0 5px 5px rgba(255, 255, 255, 0.83);
|
||||
cursor: pointer;
|
||||
pointer-events: auto; }
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Trumbowyg v2.25.1 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */
|
||||
.mathMlContainer{position:relative}.mathMlContainer[inline=false]{display:block;width:100%}.mathMlContainer:hover{pointer-events:none}.mathMlContainer:hover::after{content:'\270E';position:absolute;top:0;right:0;bottom:0;left:0;background-color:rgba(255,255,255,.83);-webkit-box-shadow:0 0 5px 5px rgba(255,255,255,.83);box-shadow:0 0 5px 5px rgba(255,255,255,.83);cursor:pointer;pointer-events:auto}
|
||||
Reference in New Issue
Block a user