/** * Copyright meystack * Licensed Apache2.0 * Version: 0.0.1 付费内容插入 */ (function () { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); var pluginNama = '插入付费内容'; var setContent = function (editor, html) { editor.focus(); editor.undoManager.transact(function () { editor.setContent(html); }); editor.selection.setCursorLocation(); editor.nodeChanged(); }; var getContent = function (editor) { return editor.getContent({ source_view: true }); }; var open = function (editor) { var editorContent = getContent(editor); editor.windowManager.open({ title: pluginNama, size: 'small', body: { type: 'panel', items: [{ type: 'textarea', name: 'code' }] }, buttons: [ { type: 'cancel', name: 'cancel', text: 'Cancel' }, { type: 'submit', name: 'save', text: 'Insert', primary: true } ], initialData: { code: editorContent }, onSubmit: function (api) { setContent(editor, api.getData().code); api.close(); } }); }; // 付费内容图标 global.ui.registry.getAll().icons.ajaximages || global.ui.registry.addIcon('ajaximages',''); var register$1 = function (editor) { editor.addCommand('mceCodeEditor', function () { open(editor); }); }; var register = function (editor) { var onAction = function () { return editor.execCommand('mceCodeEditor'); }; editor.ui.registry.addButton('ajaximages', { icon: 'sourcecode', tooltip: pluginName, onAction: onAction }); editor.ui.registry.addMenuItem('ajaximages', { icon: 'sourcecode', text: pluginName, onAction: onAction }); }; function Plugin () { global.add('code', function (editor) { register$1(editor); register(editor); return {}; }); } Plugin(); }()); // tinymce.PluginManager.add('ajaximages', function(editor, url) { // var pluginName='插入付费内容'; // var baseURL=tinymce.baseURL; // var iframe1 = baseURL+'/plugins/ajaximages/map.html'; // var ajaximages_width = function (editor) { // return editor.getParam('ajaximages_width', 560); // }; // var ajaximages_height = function (editor) { // return editor.getParam('ajaximages_height', 362); // }; // // window.tinymceLng=''; // window.tinymceLat=''; // // var openDialog = function() { // console.log(editor.windowManager) // return editor.windowManager.open({ // title: pluginName, // size: 'small', // body: { // type: 'panel', // items: [{ // type: 'textarea', // name: 'code' // }] // }, // buttons: [ // { // type: 'cancel', // text: 'Close' // }, // { // type: 'custom', // text: 'Insert', // name: 'save', // primary: true // }, // ], // onAction: function (api, details) { // switch (details.name) { // case 'save': // // html='