Skip to content

Commit

Permalink
优化 EditorStore 中的 diffNode 处理逻辑,增加错误捕获以恢复节点状态
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 16, 2024
1 parent f099070 commit 2b16574
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/MarkdownEditor/editor/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,14 @@ export class EditorStore {
updateMap.set(index, node);
});

updateMap.forEach((node, key) => {
this.diffNode(node, childrenList[key], [key]);
});
try {
updateMap.forEach((node, key) => {
this.diffNode(node, childrenList[key], [key]);
});
} catch (error) {
this.editor.children = nodeList;
}

const maxSize = childrenList.length - nodeList.length;
if (maxSize > 0) {
childrenList.forEach((node, index) => {
Expand Down

1 comment on commit 2b16574

@vercel
Copy link

@vercel vercel bot commented on 2b16574 Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.