Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: sync task list state at the very end

Abdullah Atta1aff6d0d55d6
diff --git a/packages/editor/src/extensions/task-list/task-list.ts b/packages/editor/src/extensions/task-list/task-list.ts
index cbf3a2abb..9c61f3f73 100644
--- a/packages/editor/src/extensions/task-list/task-list.ts
+++ b/packages/editor/src/extensions/task-list/task-list.ts
@@ -264,19 +264,6 @@ export const TaskListNode = TaskList.extend({
const roots = new WeakSet();
for (const edit of [...changedNodes, ...deletedNodes]) {
- // sync the stats with the new changes.
- // we add a small optimization here to avoid checking the same
- // root task list over and over again in case of multiple
- // node changes
- const root = findRootTaskList(tr.doc, edit.pos) || edit;
- if (root && !roots.has(root)) {
- roots.add(root);
-
- const stats = countCheckedItems(root.node);
- tr.setNodeMarkup(root.pos, undefined, { stats });
- changeCount++;
- }
-
// Case # 1
// if the user clicks on a task item that has children, we
// should automatically check/uncheck all its children
@@ -321,6 +308,19 @@ export const TaskListNode = TaskList.extend({
});
childPos = parentTaskItem.pos;
}
+
+ // sync the stats with the new changes.
+ // we add a small optimization here to avoid checking the same
+ // root task list over and over again in case of multiple
+ // node changes
+ const root = findRootTaskList(tr.doc, edit.pos) || edit;
+ if (root && !roots.has(root)) {
+ roots.add(root);
+
+ const stats = countCheckedItems(root.node);
+ tr.setNodeMarkup(root.pos, undefined, { stats });
+ changeCount++;
+ }
}
return changeCount > 0 ? tr : null;
}