MathquillBasedEditor是一款所见即所得的jQuery数学公式编辑器插件。该数学公式编辑器依赖于mathquill,可以通过点击图标来直接生成乘方和开方等数学公式。
使用方法
在页面中引入mathquill和matheditor的相关文件。
<link href="lib/mathquill.css" rel="stylesheet">
<link href="lib/matheditor.css" rel="stylesheet">
<script src="lib/jquery.min.js"></script>
<script src="lib/mathquill.min.js"></script>
<script src="lib/matheditor.js"></script>
HTML结构
使用一个<div>作为公式编辑器的容器。
<div id="answer"></div>
初始化插件
可以通过下面的方法来实例化MathEditor对象。
var mathEditor = new MathEditor('some_id');
mathEditor.buttons(["fraction","square_root","cube_root","root",'superscript','subscript']);
// If you dont write this line editor will display default buttons.
mathEditor.removeButtons(["fraction","square_root"])
// If you want to remove some buttons from default list.
mathEditor.styleMe({
width: '500',
height: '80'
});
// List of other options are mentioned bellow.
mathEditor.setTemplate('keypad');
// It will make button toolbar look like keypad.
// More options would be added.
mathEditor.getValue();
// It will return letex for input formula.
配置参数
在styleMe()方法中可用的配置参数如下:
| 参数 | 类型 | 默认值 | 描述 |
| width | string | 500 | 编辑器的最小宽度。 |
| height | string | 40 | 编辑器的最小高度。 |
| textarea_background | string | #FFFFFF | 编辑器文本区域的背景颜色。 |
| textarea_foreground | string | #000000 | 编辑器文本区域的前景颜色。 |
| textarea_border | string | #000000 | 编辑器文本区域的边框颜色。 |
| toolbar_background | string | #FFFFFF | 编辑器工具栏的背景颜色。 |
| toolbar_foreground | string | #000000 | 编辑器工具栏的文本颜色。 |
| toolbar_border | string | #000000 | 编辑器工具栏的边框颜色。 |
| button_background | string | #FFFFFF | 编辑器工具栏按钮的背景颜色。 |
| button_border | string | #000000 | 编辑器工具栏按钮的边框颜色。 |
MathquillBasedEditor数学公式编辑器插件的github地址为:https://github.com/karan101292/MathquillBasedEditor