Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/pull/17840

Vanessad5b50c3697a3
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 803cf0e38e..b0e91a25f3 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -3080,12 +3080,7 @@ export class WYSIWYG {
} else {
if (actionElement.classList.contains("protyle-action--task")) {
if (!protyle.disabled) {
- const taskItemElement = actionElement.parentElement;
- const html = taskItemElement.outerHTML;
- toggleTaskListItem(taskItemElement);
- taskItemElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- taskItemElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
- updateTransaction(protyle, taskItemElement, html);
+ toggleTaskListItem(protyle, actionElement.parentElement);
}
} else if (window.siyuan.config.editor.listItemDotNumberClickFocus) {
if (protyle.block.showAll && protyle.block.id === actionId) {
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index e75cfe2ab0..58cd207c72 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1712,10 +1712,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!taskItemElement) {
return;
}
- const html = taskItemElement.outerHTML;
- toggleTaskListItem(taskItemElement);
- taskItemElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
- updateTransaction(protyle, taskItemElement, html);
+ toggleTaskListItem(protyle, taskItemElement);
event.preventDefault();
event.stopPropagation();
return;
diff --git a/app/src/protyle/wysiwyg/list.ts b/app/src/protyle/wysiwyg/list.ts
index 18868060b0..ad9a032da3 100644
--- a/app/src/protyle/wysiwyg/list.ts
+++ b/app/src/protyle/wysiwyg/list.ts
@@ -58,7 +58,8 @@ export const updateListOrder = (listElement: Element, sIndex?: number) => {
});
};
-export const toggleTaskListItem = (taskItemElement: Element): void => {
+export const toggleTaskListItem = (protyle: IProtyle, taskItemElement: Element): void => {
+ const html = taskItemElement.outerHTML;
const marker = taskItemElement.getAttribute("data-task");
const useElement = taskItemElement.querySelector("use");
if (marker !== null && marker !== " ") {
@@ -70,6 +71,9 @@ export const toggleTaskListItem = (taskItemElement: Element): void => {
taskItemElement.classList.add("protyle-task--done");
useElement?.setAttribute("xlink:href", "#iconCheck");
}
+ taskItemElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
+ taskItemElement.setAttribute(Constants.ATTRIBUTE_EDITING, "true");
+ updateTransaction(protyle, taskItemElement, html);
};
export const genListItemElement = (listItemElement: Element, offset = 0, wbr = false, startIndex?: number) => {