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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
| tinymce.PluginManager.add('kityformula-editor', function(editor, url) {
|
| // var baseURL = tinymce.baseURL+'/tinymce/plugins/kityformula-editor/kityFormula.html';
| var baseURL = 'https://jsek.bnuic.com/books/book/mathBook' + '/tinymce/plugins/kityformula-editor/kityFormula.html';
|
| editor.on('dblclick',function(){
| var sel=editor.selection.getContent();
| var path=/\<img(.*?)src="data:image\/png;base64,[A-Za-z0-9+/=]*"(.*?)data-latex="(.*?)" \/>/g;
| var path2=/data-latex="(.*?)"/g;
|
| if(sel.search(path)==0){
| sel.replace(path2,function($0,$1){
| var param=encodeURIComponent($1);
| openDialog(param);
| return $0;
| });
| };
| });
|
| var openDialog = function(param) {
| return editor.windowManager.openUrl({
| title: '插入公式',
| size: 'large',
| width: 785,
| height: 475,
| url:param?baseURL+"?c="+param:baseURL,
| buttons: [
| {
| type: 'cancel',
| text: 'Close'
| },
| {
| type: 'custom',
| text: 'Save',
| name: 'save',
| primary: true
| },
| ],
| onAction: function (api, details) {
| switch (details.name) {
| case 'save':
| api.sendMessage("save");
| break;
| default:
| break;
| };
| }
| });
| };
|
|
| editor.ui.registry.addButton('kityformula-editor', {
| text: '公式',
| tooltip: '插入公式',
| onAction: function() {
| openDialog();
| }
| });
| editor.ui.registry.addMenuItem('kityformula-editor', {
| text: '公式',
| onAction: function() {
| openDialog();
| }
| });
| return {
| getMetadata: function() {
| return {
| name: "公式",
| url: "http://hgcserver.gitee.io",
| };
| }
| };
| });
|
|