TinyMCE custom button with popup

旧城冷巷雨未停 提交于 2019-12-10 16:01:54

问题


I'm adding a button to my TinyMCE setup like this:

        setup : function(ed) {
        // Add a custom button
        ed.addButton('mybutton', {
            title : 'My button',
            image : 'mybutton.jpg',
            onclick : function() {
                // Add you own code to execute something on click
                ed.focus();
                ed.selection.setContent('Hello world!');
            }
        });
    },

I wan't to know if it's possible in the onclick event to open a popup and get some input from the popup. Which then can be pasted into the editor. Exactly like if you're doing a plugin i just want to create my own without all the plugin style and functions..

Thanks in advance.


回答1:


There are 2 options:

First you can set or disable all css for the regular popup.

Second option is to open a classical popup or modal dialogue of your own using a button click or a click onto a specified element in the editor. When closing the popup you can write something back to the editor using a command like

tinyMCE.get("my_editor_id").execCommand("mceInsertContent",false,'whatever');


来源:https://stackoverflow.com/questions/6328285/tinymce-custom-button-with-popup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!