/** * bdmap (Enhancement 1.1v) * The tinymce-plugins is used to import baidu map (Enhancement) * * https://github.com/Five-great/tinymce-plugins * * Copyright 2020, Five(Li Hailong) The Chengdu, China https://www.fivecc.cn/ * * Licensed under MIT */ tinymce.PluginManager.add('bdmap', function(editor, url) { var pluginName='插入百度地图'; var bdmap_opt = editor.getParam('bdmap_options', {width: 560,height: 360,outputIframe: '/plugins/bdmap/bd.html'}); var baseURL= tinymce.baseURL || '.'; bdmap_opt.outputIframe = tinymce.baseURL + bdmap_opt.outputIframe var iframe1 = baseURL+'/plugins/bdmap/map.html'; window.tinymceLng=''; window.tinymceLat=''; window.tinymceBDZoom=''; window.tinymceBDW=''; window.tinymceBDH=''; window.tinymceBDBoxW=''; window.tinymceBDBoxH=''; window.tinymceBDBoxHtml=''; window.tinymceBDDH=''; window.tinymceBDSF = ''; window.tinymceBDBgColor = ''; window.tinymceBDDName = ''; var setContent = function (editor, html) { editor.focus(); editor.undoManager.transact(function () { editor.setContent(html); }); editor.nodeChanged(); }; var getContent = function (editor) { return editor.getContent({ source_view: true }); }; var openDialog = function() { return editor.windowManager.openUrl({ title: pluginName, size: 'large', url:iframe1, buttons: [ { type: 'cancel', text: 'Close' }, { type: 'custom', text: 'Save', name: 'save', primary: true }, ], onAction: function (api, details) { switch (details.name) { case 'save': tinymceBDBoxHtml = tinymceBDBoxHtml.replace(/\'/g,'¥').replace(/\"/g,'^').replace(/\>/g,'】').replace(/\'; editor.insertContent(html) // var editorContent = getContent(editor); // setContent(editor, editorContent); tinymceLng=''; tinymceLat=''; tinymceBDZoom=''; tinymceBDW=''; tinymceBDH=''; tinymceBDBoxW=''; tinymceBDBoxH=''; tinymceBDBoxHtml=''; tinymceBDDH=''; tinymceBDSF = ''; tinymceBDBgColor = ''; tinymceBDDName = ''; api.close(); break; default: break; } } }); }; editor.ui.registry.getAll().icons.bdmap || editor.ui.registry.addIcon('bdmap',''); editor.ui.registry.addButton('bdmap', { icon: 'bdmap', tooltip: pluginName, onAction: function() { openDialog(); } }); editor.ui.registry.addMenuItem('bdmap', { text: pluginName, onAction: function() { openDialog(); } }); return { getMetadata: function() { return { name: pluginName, url: "https://github.com/Five-great/tinymce-plugins", }; } }; });