当我使用下面的javascript代码时,一个自定义节点被插入到模型中。但我不明白为什么当该类型(mtnote)没有注册到模式中时,这会起作用。
model.change(writer => {
const noteElement=writer.createElement('mtnote',{ 'noteText': 'Hello first note' } );
const insertNotePos=model.document.selection.getFirstPosition();
writer.append(noteElement,insertNotePos);
});
我知道节点是被插入的,因为我可以在模型上迭代时看到它,如果我添加了editor.conversion.for(“downcast”),我可以将mtnote元素向下强制转换为我想要的任何视图元素。
那么,writer.append是否没有检查模式,或者我是否误解了模式应该做什么?