diff --git a/README.md b/README.md
index 4a593b1..980df0a 100644
--- a/README.md
+++ b/README.md
@@ -35,11 +35,12 @@ Add the formula plugin to your tinyMCE configuration
plugins: "... formula",
```
-Add configuration options for the formula plugin. `path` is the only setting and is optional.
+Add configuration options for the formula plugin. The setting is optional.
```javascript
formula: {
- path: 'path/to/public/plugin/folder'
+ path: 'path/to/public/plugin/folder',
+ mlang: 'mml'
},
```
@@ -47,9 +48,13 @@ formula: {
###path (optional if plugin installed inside `tinymce/plugins` folder, required otherwise)
-If you have installed the plugin in a different folder than the ```tinymce/plugins``` folder then you need to specify
+If you have installed the plugin in a different folder than the ```tinymce/plugins``` folder then you need to specify
the path (public) where the plugin is installed.
+###mlang (optional, defaults to 'latex')
+
+If you want to default the editor to MathML instead of latex, define ```mlang: 'mml'``` in the options. The only two supported variables are ```latex``` and ```mml```.
+
##License
MIT licensed
diff --git a/plugin.js b/plugin.js
index ca7d608..b91758e 100644
--- a/plugin.js
+++ b/plugin.js
@@ -1,12 +1,14 @@
(function(tinymce){
tinymce.create('tinymce.plugins.Formula', {
init: function(editor, url) {
- var options = editor.getParam('formula') || {};
- var path = options.path || url;
+ var options = editor.getParam('formula') || {},
+ fOptions = {};
+ fOptions.path = options.path || url;
+ fOptions.mlang = options.mlang || 'latex';
editor.addButton('formula', {
- image: path + '/img/formula.png',
+ image: fOptions.path + '/img/formula.png',
tooltip: 'Insert Formula',
- onclick: showFormulaDialog.bind(this, editor, path),
+ onclick: showFormulaDialog.bind(this, editor, fOptions),
onPostRender: function() {
var _this = this; // reference to the button itself
editor.on('NodeChange', function(e) {
@@ -20,12 +22,13 @@
tinymce.PluginManager.add('formula', tinymce.plugins.Formula);
- function showFormulaDialog(editor, url) {
+ function showFormulaDialog(editor, fOptions) {
+ var url = fOptions.path;
editor.windowManager.open({
title: "Formula",
width : 900,
height : 610,
- html: buildIFrame(editor, url),
+ html: buildIFrame(editor, fOptions),
buttons: [
{
text: 'Cancel',
@@ -54,10 +57,11 @@
});
}
- function buildIFrame(editor, url){
+ function buildIFrame(editor, fOptions){
+ var url = fOptions.path;
var currentNode = editor.selection.getNode();
var lang = editor.getParam('language') || 'en';
- var mlangParam = '';
+ var mlangParam = "&mlang=" + fOptions.mlang;
var equationParam = '';
if (currentNode.nodeName.toLowerCase() == 'img' && currentNode.className.indexOf('fm-editor-equation')>-1) {
if (currentNode.getAttribute('data-mlang')) mlangParam = "&mlang=" + currentNode.getAttribute('data-mlang');
diff --git a/plugin.min.js b/plugin.min.js
index 1e04f84..ec4237c 100644
--- a/plugin.min.js
+++ b/plugin.min.js
@@ -1 +1 @@
-!function(e){function t(e,t){e.windowManager.open({title:"Formula",width:900,height:610,html:a(e,t),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Formula",subtype:"primary",onclick:function(t){var a=this;window.frames.tinymceFormula&&window.frames.tinymceFormula.getData?window.frames.tinymceFormula.getData(function(t,n,i){t&&e.insertContent('
'),a.parent().parent().close()}):a.parent().parent().close()}}]})}function a(e,t){var a=e.selection.getNode(),n=e.getParam("language")||"en",i="",o="";"img"==a.nodeName.toLowerCase()&&a.className.indexOf("fm-editor-equation")>-1&&(a.getAttribute("data-mlang")&&(i="&mlang="+a.getAttribute("data-mlang")),a.getAttribute("data-equation")&&(o="&equation="+a.getAttribute("data-equation")));var r='';return r}e.create("tinymce.plugins.Formula",{init:function(e,a){var n=e.getParam("formula")||{},i=n.path||a;e.addButton("formula",{image:i+"/img/formula.png",tooltip:"Insert Formula",onclick:t.bind(this,e,i),onPostRender:function(){var t=this;e.on("NodeChange",function(e){t.active(e.element.className.indexOf("fm-editor-equation")>-1&&"img"==e.element.nodeName.toLowerCase())})}})}}),e.PluginManager.requireLangPack("formula","en,es,fr_FR"),e.PluginManager.add("formula",e.plugins.Formula)}(window.tinymce);
\ No newline at end of file
+!function(t){function e(t,e){e.path;t.windowManager.open({title:"Formula",width:900,height:610,html:a(t,e),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Formula",subtype:"primary",onclick:function(e){var a=this;window.frames.tinymceFormula&&window.frames.tinymceFormula.getData?window.frames.tinymceFormula.getData(function(e,n,i){e&&t.insertContent('
'),a.parent().parent().close()}):a.parent().parent().close()}}]})}function a(t,e){var a=e.path,n=t.selection.getNode(),i=t.getParam("language")||"en",o="&mlang="+e.mlang,r="";return"img"==n.nodeName.toLowerCase()&&n.className.indexOf("fm-editor-equation")>-1&&(n.getAttribute("data-mlang")&&(o="&mlang="+n.getAttribute("data-mlang")),n.getAttribute("data-equation")&&(r="&equation="+n.getAttribute("data-equation"))),''}t.create("tinymce.plugins.Formula",{init:function(t,a){var n=t.getParam("formula")||{},i={};i.path=n.path||a,i.mlang=n.mlang||"latex",t.addButton("formula",{image:i.path+"/img/formula.png",tooltip:"Insert Formula",onclick:e.bind(this,t,i),onPostRender:function(){var e=this;t.on("NodeChange",function(t){e.active(t.element.className.indexOf("fm-editor-equation")>-1&&"img"==t.element.nodeName.toLowerCase())})}})}}),t.PluginManager.requireLangPack("formula","en,es,fr_FR"),t.PluginManager.add("formula",t.plugins.Formula)}(window.tinymce);
\ No newline at end of file