执行不同的插件命令

问题描述

图像插件具有imageInsert命令,负责将图像插入编辑器。我有自己的插件,并且根据情况,我不想使用该插件,而是插入一个图像(不同的插件认为CKEditor-Image)

    // TOKEN PLUGIN
    function createPlaceholderView(item,writer,placeholderFormat) {
      const name = item.getAttribute('name');
      const label = item.getAttribute('label');
      const value = item.getAttribute('value');
      const tokenIsImage = tokenIsImage(name);

      if(tokenIsImage) {
        // HERE I'D LIKE TO PLUG OUT FROM TOKEN PLUGIN AND USE THE Image plugin FROM CKEDITOR
        editor.execute('imageInsert',{src: value});

        return;
      }

      const placeholderView = writer.createContainerElement(...getCreateElementSettings(
        name,label,value
      ));
      let innerText;

      if(valueMode && value) {
        innerText = writer.createText(tokenIsCompanylogo ? '' : value);
      } else {
        innerText = writer.createText(placeholderFormat.replace(TOKEN_FORMAT_PLACEHOLDER,label));
      }

      writer.insert(writer.createPositionAt(placeholderView,0),innerText);

      return placeholderView;
    }

不幸的是,我得到一个错误。我以为错误可能是由于返回空值而出现的,但是即使没有返回,错误仍然会出现。

CKEditorError: unexpected-error {"originalError":{"message":"Cannot read property 'name' of undefined","stack":"TypeError: Cannot read property 'name' of undefined\n at Gr.getModelLength (http://elzoy-demo21072020.localhost:4200/main.js:113952:227295)\n at Gr._findPositionIn (http://elzoy-demo21072020.localhost:4200/main.js:113952:227654)\n at Gr.on.priority (http://elzoy-demo21072020.localhost:4200/main.js:113952:224462)\n at Gr.fire (http://elzoy-demo21072020.localhost:4200/main.js:113952:108684)\n at Gr.toViewPosition (http://elzoy-demo21072020.localhost:4200/main.js:113952:226594)\n at Gr.toViewRange (http://elzoy-demo21072020.localhost:4200/main.js:113952:226350)\n at Jr.Aa.downcastdispatcher.on.priority (http://elzoy-demo21072020.localhost:4200/main.js:113952:258265)\n at Jr.fire (http://elzoy-demo21072020.localhost:4200/main.js:113952:108684)\n at Jr.convertSelection (http://elzoy-demo21072020.localhost:4200/main.js:113952:230938)\n at http://elzoy-demo21072020.localhost:4200/main.js:113952:256937","name":"TypeError"}}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...