首页 > 解决方案 > 如何在插件初始化期间访问editing.view.getDomRoot()?

问题描述

我想对无法通过引擎视图的 API 完成的编辑视图 DOM 根目录做一些事情。为此,我需要在插件的init()回调中访问 DOM 根。

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

如何从我的插件访问它?

标签: javascriptckeditorckeditor5

解决方案


UI确实在插件初始化后初始化。看到这两行

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

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

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

推荐阅读