【问题标题】:TinyMCE How to access right-click target from context menu?TinyMCE 如何从上下文菜单访问右键单击目标?
【发布时间】:2019-03-06 11:41:48
【问题描述】:

我正在尝试为 TinyMCE (4.7.0) 创建自己的图像处理插件。我想在右键 > 上下文菜单 > imageplugin 时设置表单中的当前图像属性。

要复制我需要访问我右键单击的元素的属性。但是我找不到目标。

console.log() 事件但它的目标是上下文菜单项而不是右键单击目标...

editor.addMenuItem('imageplugin', {
        text: 'imageplugin',
        context: 'tools',
        onclick: function(e) {
            console.log(e); //target is incorrect...
            editor.windowManager.open({
                title: 'Afbeelding instellingen',
                body: [
                    {
                        type: 'textbox',
                        name: 'title',
                        label: 'Title',
                        value: e.src
                    },
                    {
                        type   : 'listbox',
                        name   : 'width',
                        label  : 'Breedte',
                        values : [
                            { text: '100%', value: '100' },
                            { text: '50%', value: '50' },
                            { text: '33%', value: '33' },
                            { text: '25%', value: '25' },
                        ],
                        value : 'test2'
                    },
                    {
                        type   : 'listbox',
                        name   : 'float',
                        label  : 'Uitlijnen',
                        values : [
                            { text: 'Geen', value: 'none' },
                            { text: 'Links', value: 'left' },
                            { text: 'Rechts', value: 'right' },
                        ],
                        value : 'test2',
                    },
                ],
                onsubmit: function(e) {
                    editor.insertContent('Title: ' + e.data.title);
                }
            });
        }
    });

【问题讨论】:

    标签: javascript tinymce target tinymce-4


    【解决方案1】:

    使用editor.selection.getNode() 访问当前选定的项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-09
      • 2011-01-17
      相关资源
      最近更新 更多