tinymce.PluginManager.add('bdmap', function(editor, url) {
var pluginName='插入百度地图';
var bdmap_opt = editor.getParam('bdmap_options', {width: 560,height: 360,outputIframe: 'https://unpkg.com/@npkg/tinymce-plugins/plugins/bdmap/bd.html',apiKey:'ONwdanPtvCDLHBSm184T2ynP'});
var baseURL = bdmap_opt.outputIframe || 'https://unpkg.com/@npkg/tinymce-plugins/plugins/bdmap/bd.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 openDialog = function() {
return editor.windowManager.open({
title: pluginName,
size: 'large',
body: {
type: 'panel', // The root body type - a Panel or TabPanel
items: [ // A list of panel components
{
type: 'iframe', // component type
name: 'bdmap_iframe', // identifier
label: ' ', // text for the iframe's title attribute
sandboxed: true,
}
]
},
initialData: {
bdmap_iframe: `
Baidu Maps
`
},
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);
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()
document.querySelector('.tox-dialog__body-content').style.padding=0;
}
});
editor.ui.registry.addMenuItem('bdmap', {
text: pluginName,
onAction: function() {
openDialog();
document.querySelector('.tox-dialog__body-content').style.padding=0;
}
});
return {
getMetadata: function() {
return {
name: pluginName,
url: "https://github.com/Five-great/tinymce-plugins",
};
}
};
});