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,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 445.878 445.878">
|
||||
<path d="M426.024 86.447H209.705l-84.911 298.911c-2.568 7.967-9.854 13.482-18.22 13.771-.236 0-.464.006-.688.006a19.868 19.868 0 01-18.436-12.478l-34.714-86.782H19.851C8.884 299.876 0 290.986 0 280.022c0-10.965 8.893-19.854 19.851-19.854H66.18a19.862 19.862 0 0118.436 12.483l19.237 48.09 72.472-260.218a19.855 19.855 0 0118.903-13.781h230.798c10.97 0 19.854 8.89 19.854 19.851s-8.892 19.854-19.856 19.854zm10.699 266.78l-78.259-87.904 74.576-82.783c1.318-1.454 1.638-3.547.857-5.341a4.977 4.977 0 00-4.54-2.946h-47.18a4.995 4.995 0 00-3.759 1.72l-50.059 58.047-49.674-58.029a4.95 4.95 0 00-3.771-1.738H225.58a4.947 4.947 0 00-4.521 2.929 4.939 4.939 0 00.824 5.332l73.743 82.81-77.641 87.923a4.977 4.977 0 00-.813 5.325 4.978 4.978 0 004.528 2.92h48.9c1.472 0 2.867-.65 3.807-1.785l51.819-62.181 53.05 62.229a4.972 4.972 0 003.782 1.743h49.97a4.938 4.938 0 004.527-2.926 4.966 4.966 0 00-.832-5.345z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 986 B |
@@ -0,0 +1,25 @@
|
||||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user