math.js
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
KindEditor.plugin('math', function (K) {
var self = this, name = 'math', lang = self.lang(name + '.');
self.clickToolbar(name, function () {
var img = self.plugin.getSelectedImage();
var latex = $(img).data("latex") || '';
var html = [
'<div class="ke-dialog-content-inner">',
'<div class="tabs"></div>',
'<div class="ke-formula" style="width:510px;height:380px;"></div>',
'</div>'
].join('');
var iframe = K('<iframe class="" frameborder="0" src="' + self.pluginsPath + 'math/formula.html?latex=' + encodeURIComponent(latex) + '&previewUrl=' + encodeURIComponent(self.options.formulaPreviewUrl) + '" style="width:100%;height:300px;"></iframe>');
var dialog = self.createDialog({
name: name,
width: Math.min(document.body.clientWidth, 500),
height: 380,
title: "插入公式",
body: html,
yesBtn: {
name: '插入',
click: function (e) {
var win = iframe[0].contentWindow;
var url = win.$("#codecogslink").attr("href");
var latex = win.$("#latex-source").val();
if (latex == '') {
Layer.msg("请选择或输入公式");
return false;
}
self.insertHtml("<img src='" + url + "' data-latex='" + latex + "'>");
self.hideDialog().focus();
}
},
noBtn: {
name: self.lang('no'),
click: function (e) {
self.hideDialog().focus();
}
}
}),
div = dialog.div;
K('.ke-formula', div).replaceWith(iframe);
return;
});
});