获取CKEditor 5中类型的所有元素

获取CKEditor 5中类型的所有元素,ckeditor,ckeditor5,Ckeditor,Ckeditor5,“我的编辑器”包含自定义元素,创建方式如下: this.editor.model.change(writer=>{ const id=`a${Math.random().toString().replace('.','')}; const autocomplete=writer.createElement('autocomplete',{'data id':id); this.editor.model.insertContent(自动完成); } ); 我希望以后在我的插件中获得所有“自动完成

“我的编辑器”包含自定义元素,创建方式如下:

this.editor.model.change(writer=>{
const id=`a${Math.random().toString().replace('.','')};
const autocomplete=writer.createElement('autocomplete',{'data id':id);
this.editor.model.insertContent(自动完成);
} );
我希望以后在我的插件中获得所有“自动完成”元素,这样我就可以读取它们的内容(它们是可编辑的元素)


编辑器的模型是否有类似于
querySelectorAll('autocomplete')
的功能?

可以使用
range.getWalker

const findNodes=函数(writer、type、root){
常量节点=[];
const range=writer.createRangeIn(根);
for(range.getWalker({ignoreElementEnd:true})的常量值){
const节点=value.item;
if(node.is(type)){
nodes.push(节点);
}
}
返回节点;
};
this.editor.model.change(writer=>{
const autocompletes=findNodes(writer'autocomplete',this.editor.model.document.getRoot());
} );