mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
editor: fix task list title getting reset
This commit is contained in:
committed by
Abdullah Atta
parent
006a239680
commit
f34060c4e0
@@ -111,12 +111,14 @@ export function TaskListComponent(
|
|||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
const toggleState = !node.attrs.readonly;
|
const toggleState = !node.attrs.readonly;
|
||||||
tr.setNodeMarkup(tr.mapping.map(parentPos), null, {
|
tr.setNodeMarkup(tr.mapping.map(parentPos), null, {
|
||||||
|
...node.attrs,
|
||||||
readonly: toggleState
|
readonly: toggleState
|
||||||
});
|
});
|
||||||
node.descendants((node, pos) => {
|
node.descendants((node, pos) => {
|
||||||
if (node.type.name === TaskList.name) {
|
if (node.type.name === TaskList.name) {
|
||||||
const actualPos = pos + parentPos + 1;
|
const actualPos = pos + parentPos + 1;
|
||||||
tr.setNodeMarkup(tr.mapping.map(actualPos), null, {
|
tr.setNodeMarkup(tr.mapping.map(actualPos), null, {
|
||||||
|
...node.attrs,
|
||||||
readonly: toggleState
|
readonly: toggleState
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ export const TaskListNode = TaskList.extend({
|
|||||||
tr.doc.descendants((node, pos) => {
|
tr.doc.descendants((node, pos) => {
|
||||||
if (node.type.name === TaskList.name) {
|
if (node.type.name === TaskList.name) {
|
||||||
tr.setNodeMarkup(pos, undefined, {
|
tr.setNodeMarkup(pos, undefined, {
|
||||||
|
...node.attrs,
|
||||||
stats: countCheckedItems(node)
|
stats: countCheckedItems(node)
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -304,6 +305,7 @@ export const TaskListNode = TaskList.extend({
|
|||||||
|
|
||||||
changeCount++;
|
changeCount++;
|
||||||
tr.setNodeMarkup(tr.mapping.map(parentTaskItem.pos), undefined, {
|
tr.setNodeMarkup(tr.mapping.map(parentTaskItem.pos), undefined, {
|
||||||
|
...parentTaskItem.node.attrs,
|
||||||
checked: allChecked
|
checked: allChecked
|
||||||
});
|
});
|
||||||
childPos = parentTaskItem.pos;
|
childPos = parentTaskItem.pos;
|
||||||
@@ -318,7 +320,10 @@ export const TaskListNode = TaskList.extend({
|
|||||||
roots.add(root);
|
roots.add(root);
|
||||||
|
|
||||||
const stats = countCheckedItems(root.node);
|
const stats = countCheckedItems(root.node);
|
||||||
tr.setNodeMarkup(root.pos, undefined, { stats });
|
tr.setNodeMarkup(root.pos, undefined, {
|
||||||
|
...root.node.attrs,
|
||||||
|
stats
|
||||||
|
});
|
||||||
changeCount++;
|
changeCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user