wangeidtor常见报错解决

1,075 阅读1分钟

1.Error:Cannot apply an "insert_node" operation at path [74,2] because

the destination is past the end of the node.

出了这个error会导致渲染不了,直接整个直接白屏

一般常见于自定义的注册插件,newEditor,有时候是setHtml的时候会发生

而且也找不到什么方案去掉这个报错

我的意见是:

直接在会导致这个问题的代码中加try catch

不影响实际的json to html 以及html to json效果

至少我是目前没发现有任何影响,只要catch掉就不会有什么问题

比如:

newEditor.normalizeNode = ([node, path]) => {    const type = DomEditor.getNodeType(node);    if (type !== "link-card") {      // 未命中 link-card ,执行默认的 normalizeNode      // return normalizeNode([node, path]);      try {        normalizeNode([node, path]);      } catch (e) {        // console.log(e);      }      return;    }

2.Error: Duplicated key 'xxx' in menu items

在我另一篇文章有详细说明

juejin.cn/post/711191…

后续如果有更多的会增加