Wordpress TinyMCE为弹出窗体添加说明

时间:2014-05-05 15:39:30

标签: javascript wordpress tinymce dropdownbox

我今天在wordpress中为TinyMCE编辑器创建了自定义按钮,它们与短代码相关联,点击它们时会打开一个弹出窗口,用户可以在其中填写给定短代码的参数。这一切都很好,但我觉得它需要为用户提供更多指导,所以我想在每个参数下的弹出窗口中添加说明。

以下是处理弹出窗口的javascript示例 - 您将看到这会创建一个包含5个项目的下拉列表供用户选择。

(function() {
tinymce.PluginManager.add('skizzar_container', function( editor, url ) {
    editor.addButton( 'skizzar_container', {
        title: 'Add a Container',
        icon: 'icon dashicons-media-text',
        onclick: function() {
editor.windowManager.open( {
    title: 'Container',
    body: [{
        type: 'listbox',
        name: 'style',
        label: 'Style',
        'values': [
            {text: 'Clear', value: 'clear'},
            {text: 'White', value: 'white'},                
            {text: 'Colour 1', value: 'colour1'},
            {text: 'Colour 2', value: 'colour2'},
            {text: 'Colour 3', value: 'colour3'},
        ]
    }],
    onsubmit: function( e ) {
        editor.insertContent( '[container style="' + e.data.style + '"]<br /><br />[/container]');
    }
});
}

    });
});
})();

我想要做的是在下拉列表下方添加一些描述文字 - 我该如何实现?

1 个答案:

答案 0 :(得分:1)

在您的选择列表之后,您可以添加一个容器并将html放入其中。

editor.windowManager.open( {
title: 'Container',
body: [{
    type: 'listbox',
    name: 'style',
    label: 'Style',
    'values': [
        {text: 'Clear', value: 'clear'},
        {text: 'White', value: 'white'},                
        {text: 'Colour 1', value: 'colour1'},
        {text: 'Colour 2', value: 'colour2'},
        {text: 'Colour 3', value: 'colour3'},
    ]
} /*add in the following with the comma */ ,
{   type: 'container',
    html: '<p>Enter your Text here</p>'
    }
],
onsubmit: function( e ) {
    editor.insertContent( '[container style="' + e.data.style + '"]<br /><br />[/container]');
}