Skip to content

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

:art: Unify task status icons and character alignment https://github.com/siyuan-note/siyuan/issues/19534

Daniele2a01acb5786
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index d549ffd21b..a290e1b3d6 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -874,6 +874,12 @@
</svg>
iconUncheck
</div>
+ <div>
+ <svg>
+ <use xlink:href="#iconTaskInProgress"></use>
+ </svg>
+ iconTaskInProgress
+ </div>
<div>
<svg>
<use xlink:href="#iconDot"></use>
diff --git a/app/appearance/icons/litheness/icon.js b/app/appearance/icons/litheness/icon.js
index 318b03b231..e4c8f6fc3f 100644
--- a/app/appearance/icons/litheness/icon.js
+++ b/app/appearance/icons/litheness/icon.js
@@ -435,6 +435,10 @@ document.body.insertAdjacentHTML('afterbegin', `<svg id="iconsLitheness" style="
<symbol id="iconUncheck" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
<rect width="18" height="18" x="3" y="3" rx="2"/>
</symbol>
+ <symbol id="iconTaskInProgress" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect width="18" height="18" x="3" y="3" rx="2" />
+ <line x1="9" x2="15" y1="15" y2="9" />
+ </symbol>
<symbol id="iconListItem" viewBox="30 -930 900 900">
<path d="M360-440v-80h480v80H360ZM200-400q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Z"></path>
</symbol>
diff --git a/app/src/assets/icon/task-canceled.svg b/app/src/assets/icon/task-canceled.svg
new file mode 100644
index 0000000000..67cc07ef84
--- /dev/null
+++ b/app/src/assets/icon/task-canceled.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect width="18" height="18" x="3" y="3" rx="2"/><path d="M8 12h8"/>
+</svg>
diff --git a/app/src/assets/icon/task-icons.LICENSE b/app/src/assets/icon/task-icons.LICENSE
new file mode 100644
index 0000000000..3342e107d6
--- /dev/null
+++ b/app/src/assets/icon/task-icons.LICENSE
@@ -0,0 +1,10 @@
+task-in-progress.svg: https://github.com/lucide-icons/lucide/blob/main/icons/square-slash.svg
+task-unchecked.svg and task-canceled.svg reuse iconUncheck and iconIndeterminateCheck from app/appearance/icons/litheness/icon.js.
+
+ISC License
+
+Copyright (c) 2026 Lucide Icons and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/app/src/assets/icon/task-in-progress.svg b/app/src/assets/icon/task-in-progress.svg
new file mode 100644
index 0000000000..26f35dc894
--- /dev/null
+++ b/app/src/assets/icon/task-in-progress.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect width="18" height="18" x="3" y="3" rx="2" />
+ <line x1="9" x2="15" y1="15" y2="9" />
+</svg>
diff --git a/app/src/assets/icon/task-unchecked.svg b/app/src/assets/icon/task-unchecked.svg
new file mode 100644
index 0000000000..4b057f70c3
--- /dev/null
+++ b/app/src/assets/icon/task-unchecked.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect width="18" height="18" x="3" y="3" rx="2"/>
+</svg>
diff --git a/app/src/assets/scss/protyle/_task.scss b/app/src/assets/scss/protyle/_task.scss
index 98c909bc47..c30a8a0a17 100644
--- a/app/src/assets/scss/protyle/_task.scss
+++ b/app/src/assets/scss/protyle/_task.scss
@@ -4,6 +4,22 @@
.protyle-action--task[data-task] {
--task-marker: attr(data-task);
}
+
+ // 单字符图标按字形视觉中心对齐,高笔画字符向下补偿,短小写字符保持原位。
+ @each $marker in "b", "d", "f", "h", "k", "l", "t",
+ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
+ "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "Y", "Z",
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" {
+ .li[data-task="#{$marker}"] > .protyle-action--task,
+ .protyle-action--task[data-task="#{$marker}"],
+ .tabs-task[data-task="#{$marker}"] {
+ --task-character-offset: .1em;
+ }
+ }
+
+ .tabs-task--custom > span {
+ transform: translateY(var(--task-character-offset, 0em));
+ }
// 将可打印的单字节标记传给图标,直接响应块属性变化,无需修改渲染结果或任务数据。
@each $code in string.split("21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 59 5a 5c 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 79 7a 7b 7c 7d 7e", " ") {
.li[data-subtype="t"][data-task="#{'\\'}#{$code}"] > .protyle-action--task {
@@ -14,29 +30,47 @@
.li[data-subtype="t"][data-task]:not([data-task=" "]):not([data-task="x"]):not([data-task="X"]) > .protyle-action--task,
.protyle-action--task[data-task]:not([data-task=" "]):not([data-task="x"]):not([data-task="X"]) {
> svg {
- visibility: hidden;
+ background-color: currentColor;
+ -webkit-mask: var(--task-icon, url("../icon/task-unchecked.svg")) center / auto 100% no-repeat;
+ mask: var(--task-icon, url("../icon/task-unchecked.svg")) center / auto 100% no-repeat;
+
+ > use {
+ visibility: hidden;
+ }
}
&::before {
- content: var(--task-marker, attr(data-task));
+ content: var(--task-character, var(--task-marker, attr(data-task)));
position: absolute;
top: 50%;
left: 50%;
- transform: translate(-50%, -50%);
- box-sizing: border-box;
- width: max(14px, 1em - 4px);
- height: max(14px, 1em - 4px);
- border: 1.5px solid currentColor;
- border-radius: 2px;
+ transform: translate(-50%, calc(-50% + var(--task-character-offset, 0em)));
font-family: var(--b3-font-family-code);
- font-size: 12px;
- line-height: 11px;
+ font-size: max(10px, (1em - 4px) / 1.4);
+ line-height: 1;
+ display: flex;
+ align-items: center;
+ justify-content: center;
text-align: center;
pointer-events: none;
z-index: 1;
}
}
+ .li[data-task="/"] > .protyle-action--task,
+ .protyle-action--task[data-task="/"] {
+ --task-icon: url("../icon/task-in-progress.svg");
+
+ --task-character: none;
+ }
+
+ .li[data-task="-"] > .protyle-action--task,
+ .protyle-action--task[data-task="-"] {
+ --task-icon: url("../icon/task-canceled.svg");
+
+ --task-character: none;
+ }
+
.li[data-task="/"] > div.p,
.li > .protyle-action--task[data-task="/"] ~ div.p {
color: inherit;
diff --git a/app/src/protyle/render/tabsRender.ts b/app/src/protyle/render/tabsRender.ts
index ba7f383653..d5bb5c2b27 100644
--- a/app/src/protyle/render/tabsRender.ts
+++ b/app/src/protyle/render/tabsRender.ts
@@ -294,6 +294,8 @@ export const tabsRender = (element: Element, options: ITabsRenderOptions = {}) =
});
if (marker === " " || marker.toLowerCase() === "x") {
task.innerHTML = `<svg><use xlink:href="#${marker === " " ? "iconUncheck" : "iconCheck"}"></use></svg>`;
+ } else if (marker === "/" || marker === "-") {
+ task.innerHTML = `<svg><use xlink:href="#${marker === "/" ? "iconTaskInProgress" : "iconIndeterminateCheck"}"></use></svg>`;
} else {
task.innerHTML = '<svg><use xlink:href="#iconUncheck"></use></svg>';
const character = document.createElement("span");
diff --git a/app/src/protyle/wysiwyg/taskStatusDialog.ts b/app/src/protyle/wysiwyg/taskStatusDialog.ts
index acb8f0c13d..99ac9a0482 100644
--- a/app/src/protyle/wysiwyg/taskStatusDialog.ts
+++ b/app/src/protyle/wysiwyg/taskStatusDialog.ts
@@ -6,19 +6,21 @@ import {Menu} from "../../plugin/Menu";
export const getTaskStatusItems = (marker: string, setMarker: (marker: string) => void): IMenu[] => {
const lang = window.siyuan.languages;
return [
- {id: "taskStatusTodo", marker: " ", label: lang.taskStatusTodo},
- {id: "taskStatusInProgress", marker: "/", label: lang.taskStatusInProgress},
- {id: "taskStatusDone", marker: "X", label: lang.taskStatusDone},
- {id: "taskStatusCanceled", marker: "-", label: lang.taskStatusCanceled},
+ {id: "taskStatusTodo", marker: " ", label: lang.taskStatusTodo, icon: "iconUncheck"},
+ {id: "taskStatusInProgress", marker: "/", label: lang.taskStatusInProgress, icon: "iconTaskInProgress"},
+ {id: "taskStatusDone", marker: "X", label: lang.taskStatusDone, icon: "iconCheck"},
+ {id: "taskStatusCanceled", marker: "-", label: lang.taskStatusCanceled, icon: "iconIndeterminateCheck"},
].map(item => ({
id: item.id,
label: item.label,
- icon: marker?.toUpperCase() === item.marker ? "iconCheck" : "iconUncheck",
+ icon: item.icon,
+ checked: marker?.toUpperCase() === item.marker,
click: () => setMarker(item.marker),
})).concat([{
id: "customTaskStatus",
label: lang.customTaskStatus,
icon: "iconEdit",
+ checked: ![" ", "/", "X", "-"].includes(marker?.toUpperCase()),
click: () => openTaskStatusDialog(marker, setMarker),
}]);
};
diff --git a/app/tests/taskIconAssets.test.js b/app/tests/taskIconAssets.test.js
new file mode 100644
index 0000000000..f0cf6f538d
--- /dev/null
+++ b/app/tests/taskIconAssets.test.js
@@ -0,0 +1,19 @@
+const assert = require("node:assert/strict");
+const {existsSync} = require("node:fs");
+const path = require("node:path");
+const test = require("node:test");
+const sass = require("sass");
+
+test("task icon URLs resolve from every stylesheet entry", () => {
+ for (const name of ["base", "mobile", "export"]) {
+ const entry = path.join(__dirname, `../src/assets/scss/${name}.scss`);
+ const css = sass.compile(entry, {logger: sass.Logger.silent}).css;
+ const icons = new Set();
+ for (const match of css.matchAll(/url\(["']?([^\s"')]*task-(?:unchecked|in-progress|canceled)\.svg)["']?\)/g)) {
+ const asset = path.resolve(path.dirname(entry), match[1]);
+ assert.ok(existsSync(asset), `${name}: ${asset}`);
+ icons.add(path.basename(asset));
+ }
+ assert.deepEqual([...icons].sort(), ["task-canceled.svg", "task-in-progress.svg", "task-unchecked.svg"]);
+ }
+});
diff --git a/app/tests/taskStatus.test.js b/app/tests/taskStatus.test.js
index b33cdd6c73..0a347b33f9 100644
--- a/app/tests/taskStatus.test.js
+++ b/app/tests/taskStatus.test.js
@@ -18,6 +18,8 @@ const sources = () => {
};
const renderSource = readFileSync(path.join(__dirname, "../src/protyle/render/tabsRender.ts"), "utf8");
return {
+ icons: ["unchecked", "in-progress", "canceled"].map(name =>
+ readFileSync(path.join(__dirname, `../src/assets/icon/task-${name}.svg`), "utf8")),
actions: extract("protyle/render/tabsRender.ts", ["getTabTask", "getTabItems", "hasTabsTasks"]) +
extract("protyle/util/tabsCopy.ts", ["preserveTabTask", "preserveCopiedTabTask", "remapTabsDOMIDs", "wrapPastedTabItems"]) +
extract("protyle/wysiwyg/tabsRemoval.ts", ["repairActiveTab"]) +
@@ -35,6 +37,19 @@ const sources = () => {
const cases = async source => {
const check = require("node:assert/strict");
+ // 列表遮罩与页签引用的图标保持同一外框和图形,防止两处资源发生偏差。
+ const symbols = ["iconUncheck", "iconTaskInProgress", "iconIndeterminateCheck"];
+ source.icons.forEach((svg, index) => {
+ const icon = new DOMParser().parseFromString(svg, "image/svg+xml").documentElement;
+ const symbol = document.getElementById(symbols[index]);
+ for (const attribute of ["viewBox", "stroke-width", "stroke-linecap", "stroke-linejoin"]) {
+ check.equal(icon.getAttribute(attribute), symbol.getAttribute(attribute));
+ }
+ const shape = element => Array.from(element.children).map(child => [child.localName,
+ Array.from(child.attributes).map(attribute => [attribute.name, attribute.value])]);
+ check.deepEqual(shape(icon), shape(symbol));
+ check.equal(icon.querySelector("rect").getAttribute("width"), "18");
+ });
const lute = window.Lute.New();
lute.SetTabs(true);
lute.SetKramdownIAL(true);
@@ -185,9 +200,14 @@ const cases = async source => {
imported.innerHTML = lute.SpinBlockDOM(root.innerHTML);
check.equal(imported.querySelector(".li").getAttribute("data-task"), marker === "x" ? "X" : marker);
const action = taskItem.querySelector(".protyle-action--task");
- if (![" ", "X", "x"].includes(marker)) {
+ if (![" ", "X", "x", "/", "-"].includes(marker)) {
check.equal(JSON.parse(getComputedStyle(action, "::before").content), marker);
- check.equal(getComputedStyle(action.querySelector("svg")).visibility, "hidden");
+ check.equal(getComputedStyle(action.querySelector("use")).visibility, "hidden");
+ }
+ if (marker === "/" || marker === "-") {
+ check.equal(getComputedStyle(action, "::before").content, "none");
+ check.ok(getComputedStyle(action.querySelector("svg")).maskImage.includes(
+ marker === "/" ? "task-in-progress.svg" : "task-canceled.svg"));
}
if (marker === "/" || marker === "-") {
check.equal(getComputedStyle(taskItem.querySelector(".p")).textDecorationLine,
@@ -210,6 +230,19 @@ const cases = async source => {
check.equal(taskItem.outerHTML, before);
protyle.options.action = [];
+ // 各状态复用同一 SVG 画布尺寸,预设状态不再绘制字符或 CSS 边框。
+ for (const fontSize of [16, 20, 28]) {
+ root.style.fontSize = `${fontSize}px`;
+ api.setTaskListItemMarker(protyle, taskItem, "/");
+ const action = taskItem.querySelector(".protyle-action--task");
+ const iconSize = action.querySelector("svg").getBoundingClientRect().height;
+ for (const marker of [" ", "-", "X", "?"]) {
+ api.setTaskListItemMarker(protyle, taskItem, marker);
+ check.equal(action.querySelector("svg").getBoundingClientRect().height, iconSize);
+ }
+ }
+ root.style.fontSize = "";
+
// 重载、嵌套列表和导出结构使用各自标记,不能继承外层任务字符。
for (const exportDOM of [false, true]) {
root.innerHTML = lute.Md2BlockDOM("* [-] Canceled\n * [/] Working\n * [?] Custom\n");
@@ -222,7 +255,7 @@ const cases = async source => {
const entries = root.querySelectorAll(".li");
["-", "/", "?"].forEach((marker, index) => {
const action = entries[index].querySelector(":scope > .protyle-action--task");
- check.equal(JSON.parse(getComputedStyle(action, "::before").content), marker);
+ check.equal(getComputedStyle(action, "::before").content, marker === "?" ? '"?"' : "none");
});
check.equal(getComputedStyle(entries[1].querySelector(".p")).textDecorationLine, "none");
}
@@ -235,7 +268,7 @@ const cases = async source => {
document.head.append(style);
({from} = reset());
const items = from.querySelectorAll(":scope > .tab-item");
- items[1].setAttribute("tabs-task", "/");
+ items[1].setAttribute("tabs-task", "?");
const completed = items[0].cloneNode(true);
completed.dataset.nodeId = window.Lute.NewNodeID();
completed.setAttribute("tabs-task", "X");
@@ -246,12 +279,19 @@ const cases = async source => {
const custom = from.querySelector(".tabs-task--custom");
const incomplete = from.querySelector(".tabs-task:not(.tabs-task--custom)");
check.equal(custom.querySelector("use").getAttribute("xlink:href"), incomplete.querySelector("use").getAttribute("xlink:href"));
- check.equal(custom.querySelector("span").textContent, "/");
+ check.equal(custom.querySelector("span").textContent, "?");
check.equal(custom.getBoundingClientRect().width, incomplete.getBoundingClientRect().width);
check.equal(custom.getBoundingClientRect().height, incomplete.getBoundingClientRect().height);
const checked = from.querySelector('.tabs-task[data-task="X"]');
check.equal(checked.querySelector("use").getAttribute("xlink:href"), "#iconCheck");
check.equal(custom.getBoundingClientRect().width, checked.getBoundingClientRect().width);
+ for (const [marker, icon] of [["/", "iconTaskInProgress"], ["-", "iconIndeterminateCheck"]]) {
+ items[0].setAttribute("tabs-task", marker);
+ renderer.tabsRender(root, {readonly: () => false, taskMenu: entry => { edited = entry; }, task: entry => { toggled = entry; }});
+ const preset = from.querySelector(`.tabs-task[data-task="${marker}"]`);
+ check.equal(preset.querySelector("use").getAttribute("xlink:href"), `#${icon}`);
+ check.equal(preset.querySelector("span"), null);
+ }
const active = from.getAttribute("tabs-active-id");
custom.dispatchEvent(new MouseEvent("contextmenu", {bubbles: true, cancelable: true}));
check.equal(edited, items[1]);
@@ -279,6 +319,8 @@ const run = async () => {
await win.loadURL("data:text/html,<html><body></body></html>");
await win.webContents.executeJavaScript(readFileSync(path.join(__dirname,
"../stage/protyle/js/lute/lute.min.js"), "utf8"));
+ await win.webContents.executeJavaScript(readFileSync(path.join(__dirname,
+ "../appearance/icons/litheness/icon.js"), "utf8"));
const result = await win.webContents.executeJavaScript(`(${cases.toString()})(${JSON.stringify(sources())})`);
assert.equal(result, "Task status cases passed");
console.log(result);
diff --git a/app/webpack.config.js b/app/webpack.config.js
index 935104a7dc..d65f483279 100644
--- a/app/webpack.config.js
+++ b/app/webpack.config.js
@@ -118,8 +118,13 @@ module.exports = (env, argv) => {
},
],
},
+ {
+ test: /task-(canceled|in-progress|unchecked)\.svg$/,
+ type: "asset/inline",
+ },
{
test: /\.(png|svg)$/,
+ exclude: /task-(canceled|in-progress|unchecked)\.svg$/,
use: [
{
loader: "file-loader",
diff --git a/app/webpack.desktop.js b/app/webpack.desktop.js
index dcb5ff98d3..e04190f7fb 100644
--- a/app/webpack.desktop.js
+++ b/app/webpack.desktop.js
@@ -91,8 +91,13 @@ module.exports = (env, argv) => {
},
],
},
+ {
+ test: /task-(canceled|in-progress|unchecked)\.svg$/,
+ type: "asset/inline",
+ },
{
test: /\.(png|svg)$/,
+ exclude: /task-(canceled|in-progress|unchecked)\.svg$/,
use: [
{
loader: "file-loader",
diff --git a/app/webpack.export.js b/app/webpack.export.js
index d705287683..4bf0e8352e 100644
--- a/app/webpack.export.js
+++ b/app/webpack.export.js
@@ -39,6 +39,10 @@ module.exports = (env, argv) => {
},
module: {
rules: [
+ {
+ test: /task-(canceled|in-progress|unchecked)\.svg$/,
+ type: "asset/inline",
+ },
{
test: /\.ts(x?)$/,
include: [path.resolve(__dirname, "src")],
diff --git a/app/webpack.mobile.js b/app/webpack.mobile.js
index 1f4bffc07a..2986968d2f 100644
--- a/app/webpack.mobile.js
+++ b/app/webpack.mobile.js
@@ -92,8 +92,13 @@ module.exports = (env, argv) => {
},
],
},
+ {
+ test: /task-(canceled|in-progress|unchecked)\.svg$/,
+ type: "asset/inline",
+ },
{
test: /\.(png|svg)$/,
+ exclude: /task-(canceled|in-progress|unchecked)\.svg$/,
use: [
{
loader: "file-loader",