| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- tinymce.PluginManager.add('kityformula-editor', function (editor, url) {
- var baseURL = '/tinymce/plugins/kityformula-editor/kityFormula.html'
- editor.on('dblclick', function () {
- var sel = editor.selection.getContent()
- var path = /^<img\s+[^>]*src="data:image\/png;base64,[A-Za-z0-9+\/=]*"[^>]*data-latex="([^"]+)"[^>]*>$/
- 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: ''
- }
- }
- }
- })
|