Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/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
如何在自定义ckeditor5小部件中创建上下文菜单?_Ckeditor_Ckeditor5 - Fatal编程技术网

如何在自定义ckeditor5小部件中创建上下文菜单?

如何在自定义ckeditor5小部件中创建上下文菜单?,ckeditor,ckeditor5,Ckeditor,Ckeditor5,我制作了一个类似占位符(ckeditor4)的内联小部件,但现在我想在选择小部件时呈现一个下拉列表,以显示替换占位符的选项值。我尝试使用BallookPanelView,但直到现在都没有成功,有人知道如何制作吗 this.editor.editing.view.document.on('click', (evt, data) => { evt.stop(); const element = data.target; if (element && el

我制作了一个类似占位符(ckeditor4)的内联小部件,但现在我想在选择小部件时呈现一个下拉列表,以显示替换占位符的选项值。我尝试使用BallookPanelView,但直到现在都没有成功,有人知道如何制作吗

this.editor.editing.view.document.on('click', (evt, data) => {
    evt.stop();
    const element = data.target;
    if (element && element.hasClass('placeholder')) {
        if (!element.getAttribute('data-is-fixed')) {
            const balloonPanelView = new BalloonPanelView();
            balloonPanelView.render();
            ['option1', 'option2', 'option3'].forEach((value) => {
                const view = new View();
                view.set({
                    label: value,
                    withText: true
                });
                balloonPanelView.content.add(view);
            });
            balloonPanelView.pin({
                target: element
            });
        }
    }
});

我使用ContextualAlloon类找到了解决方案:

import ContextualBalloon from "@ckeditor/ckeditor5-ui/src/panel/balloon/contextualballoon";

// Define ballon
const balloon = editor.plugins.get(ContextualBalloon);

const placeholderOptions = // Here I defined list with buttons '<li><button></li>' 

// Finnaly render ballon
balloon.add({
    view: placeholderOptions,
    singleViewMode: true,
    position: {
         target: data.domTarget
    }
});

从“@ckeditor/ckeditor5ui/src/panel/balloon/contextualballon”导入contextualballon;
//定义气球
const balloon=editor.plugins.get(ContextualBalloon);
const placeholder options=//我在这里用按钮“
  • ”定义了列表 //Finnaly渲染气球 气球。添加({ 视图:占位符选项, singleViewMode:true, 职位:{ 目标:data.domTarget } });
    hello@Tiago我也面临同样的问题,你最终找到解决方案了吗?我给我贴了一份解决方案的简历