插件初始化期间如何访问edit.view.getDomRoot()?

时间:2019-04-18 07:45:35

标签: javascript ckeditor ckeditor5

我想对编辑视图DOM根目录执行某些操作,而该操作无法通过引擎视图的API完成。为此,我需要在插件的init()回调中访问DOM根。

但是,事实证明,DOM根是在初始化插件之后创建的。

如何从插件访问它?

1 个答案:

答案 0 :(得分:0)

在初始化插件之后,UI确实已初始化。参见these two lines

但是,editor.ui会触发#ready事件,因此它将起作用:

editor.ui.on( 'ready', () => {
    const domRoot = editingView.getDomRoot();

    // Do something with the DOM root...
} );