一位客戶要求我插入一個插件來插入電話鏈接,我知道這可以通過鏈接插件完成,但他希望有一個專門設計來做到這一點。我已經有了彈出窗口的插件,您可以在其中插入需要的數據,下面是代碼,我想要的是添加鏈接插件的相同功能,因此當用戶點擊鏈接文本時,內容可以是在我的插件的窗口管理器中編輯。Tinymce定製插件
這是我的代碼至今:
tinymce.PluginManager.add('phonelink', function(editor, url) {
// Add a button that opens a window
tinymce.DOM.loadCSS(url + '/css/phonelink.css');
editor.addButton('phonelink', {
text: false,
icon: 'phonelink',
onclick: function() {
// Open window
editor.windowManager.open({
title: 'Enlace teléfono',
body: [
{type: 'textbox', name: 'phone', label: 'Teléfono'},
{type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
{type: 'textbox', name: 'title', label: 'Título'}
],
onsubmit: function(e) {
// Insert content when the window form is submitted
editor.insertContent('<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>');
}
});
}
});
// Adds a menu item to the tools menu
editor.addMenuItem('phonelink', {
text: 'Teléfono',
context: 'tools',
onclick: function() {
// Open window with a specific url
editor.windowManager.open({
title: 'Enlace teléfono',
body: [
{type: 'textbox', name: 'phone', label: 'Teléfono'},
{type: 'textbox', name: 'showtext', label: 'Texto a mostrar'},
{type: 'textbox', name: 'title', label: 'Título'}
],
onsubmit: function(e) {
// Insert content when the window form is submitted
editor.insertContent('<a title="' + e.data.title + '" href="tel:+34' + e.data.phone + '">' + e.data.showtext + '</a>');
}
});
}
});
});