Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 创建或转换TinyMCE下拉工具栏菜单_Php_Javascript_Plugins_Tinymce - Fatal编程技术网

Php 创建或转换TinyMCE下拉工具栏菜单

Php 创建或转换TinyMCE下拉工具栏菜单,php,javascript,plugins,tinymce,Php,Javascript,Plugins,Tinymce,我一直在尝试在我的jQuery版本的TinyMCE中实现这个插件: 本例中的插件加载了TinyMCE,但这不适用于jQuery 我想做的是将其创建为一个单独的TinyMCE插件,但我不确定如何实现这一点。使用TinyMCE创建插件的教程都是关于对话框窗口的,但这不是我需要的,因为我只想有一个小片段的下拉菜单,这些片段将添加到光标所在的位置 有人能给我举个例子,说明如何创建这样一个工具栏下拉列表吗?我已经疯狂地浏览过谷歌,找不到任何类似的东西,我上面发布的示例从技术上讲不是一个插件,因为我需要用

我一直在尝试在我的jQuery版本的TinyMCE中实现这个插件:

本例中的插件加载了TinyMCE,但这不适用于jQuery

我想做的是将其创建为一个单独的TinyMCE插件,但我不确定如何实现这一点。使用TinyMCE创建插件的教程都是关于对话框窗口的,但这不是我需要的,因为我只想有一个小片段的下拉菜单,这些片段将添加到光标所在的位置

有人能给我举个例子,说明如何创建这样一个工具栏下拉列表吗?我已经疯狂地浏览过谷歌,找不到任何类似的东西,我上面发布的示例从技术上讲不是一个插件,因为我需要用PHP生成内容。

这项任务不是那么容易(也必须努力完成)。 您需要在自己的一个自定义插件中设置函数createControl。 我将向您展示我自己的一个插件的一些代码,它将为您指明正确的方向

    /**
     * Creates control instances based in the incomming name. This method is normally not
     * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
     * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
     * method can be used to create those.
     *
     * @param {String} n Name of the control to create.
     * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
     * @return {tinymce.ui.Control} New control instance or null if no control was created.
     */
    // Creates a custom listbox
    createControl: function(n, cm) {

        switch (n) {
            // you may define more than one listbox here!
            // make sure this string is in your buttonconfig
            case 'my_new_listbox':

                var listboxIdPart = 'my_new_listbox';

                // Listbox erzeugen
                var ctrl = cm.createListBox(listboxIdPart, {
                title : 'Title',

                    // v could be 'value1_here' or "value2_here", it isbest to use simple numers as values
                    //need to specify what shall happen depending on the value
                  onselect : function(v) {

                    if (v == 0){
                        return;
                    }
                    else {
                                              // alert('value choosen:' + v)
                                              // your actions here
                      return;
                      }                     
                  }
                }); // closing bracket

                                    // Add entries to the dropdown
                ctrl.add('entry1', 'value1_here');
                ctrl.add('entry2', 'value2_here');
                ctrl.add('entry3', 'value3_here');

                // Return new listbox
                return ctrl;
        }
        return null;
    },
这项任务不是那么容易(我也不得不努力完成)。 您需要在自己的一个自定义插件中设置函数createControl。 我将向您展示我自己的一个插件的一些代码,它将为您指明正确的方向

    /**
     * Creates control instances based in the incomming name. This method is normally not
     * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
     * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
     * method can be used to create those.
     *
     * @param {String} n Name of the control to create.
     * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
     * @return {tinymce.ui.Control} New control instance or null if no control was created.
     */
    // Creates a custom listbox
    createControl: function(n, cm) {

        switch (n) {
            // you may define more than one listbox here!
            // make sure this string is in your buttonconfig
            case 'my_new_listbox':

                var listboxIdPart = 'my_new_listbox';

                // Listbox erzeugen
                var ctrl = cm.createListBox(listboxIdPart, {
                title : 'Title',

                    // v could be 'value1_here' or "value2_here", it isbest to use simple numers as values
                    //need to specify what shall happen depending on the value
                  onselect : function(v) {

                    if (v == 0){
                        return;
                    }
                    else {
                                              // alert('value choosen:' + v)
                                              // your actions here
                      return;
                      }                     
                  }
                }); // closing bracket

                                    // Add entries to the dropdown
                ctrl.add('entry1', 'value1_here');
                ctrl.add('entry2', 'value2_here');
                ctrl.add('entry3', 'value3_here');

                // Return new listbox
                return ctrl;
        }
        return null;
    },

@塔里亚马:+1。非常有用。谢谢一个简短的编辑:在cm.createListBox()函数后面缺少一个右括号。我已经编辑了答案。希望你得到更正。@Thariama:+1。非常有用。谢谢一个简短的编辑:在cm.createListBox()函数后面缺少一个右括号。我已经编辑了答案。希望你得到纠正。