Skip to content

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

:bug: Correct list mind map gutter visibility and view icons https://github.com/siyuan-note/siyuan/issues/18831

Vanessa746e1a794fab
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 967f5e318f..c4f9aa7109 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -28,6 +28,12 @@
<body>
<h2>SiYuan</h2>
<div class="fn__clear">
+ <div>
+ <svg>
+ <use xlink:href="#iconMindmap"></use>
+ </svg>
+ iconMindmap
+ </div>
<div>
<svg>
<use xlink:href="#iconRoute"></use>
diff --git a/app/appearance/icons/litheness/icon.js b/app/appearance/icons/litheness/icon.js
index 1d5fb4fd16..70d520ef87 100644
--- a/app/appearance/icons/litheness/icon.js
+++ b/app/appearance/icons/litheness/icon.js
@@ -1,5 +1,14 @@
document.body.insertAdjacentHTML('afterbegin', `<svg id="iconsLitheness" style="position: absolute; width: 0; height: 0; overflow: hidden;">
<defs>
+ <symbol id="iconMindmap" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <g transform="rotate(-90 12 12)">
+ <rect x="16" y="16" width="6" height="6" rx="1" />
+ <rect x="2" y="16" width="6" height="6" rx="1" />
+ <rect x="9" y="2" width="6" height="6" rx="1" />
+ <path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3" />
+ <path d="M12 12V8" />
+ </g>
+ </symbol>
<symbol id="iconRoute" viewBox="0 0 24 24" fill="currentColor">
<path d="M6 15C7.65685 15 9 16.3431 9 18C9 19.6569 7.65685 21 6 21C4.34315 21 3 19.6569 3 18C3 16.3431 4.34315 15 6 15ZM6 16.5C5.17157 16.5 4.5 17.1716 4.5 18C4.5 18.8284 5.17157 19.5 6 19.5C6.82843 19.5 7.5 18.8284 7.5 18C7.5 17.1716 6.82843 16.5 6 16.5Z" />
<path d="M18.501 6.39551C18.501 6.18457 18.4277 6.00586 18.2812 5.85938C18.1289 5.71289 17.9531 5.63965 17.7539 5.63965L8.63086 5.64844C7.79297 5.64844 7.06641 5.80664 6.45117 6.12305C5.83008 6.44531 5.34961 6.88477 5.00977 7.44141C4.66992 8.00391 4.5 8.64844 4.5 9.375C4.5 10.1016 4.66992 10.7461 5.00977 11.3086C5.34375 11.877 5.82129 12.3223 6.44238 12.6445C7.05762 12.9668 7.78711 13.1279 8.63086 13.1279H16.1807C16.9541 13.1279 17.5664 13.3418 18.0176 13.7695C18.4629 14.2031 18.6855 14.7422 18.6855 15.3867C18.6855 16.0313 18.46 16.5615 18.0088 16.9775C17.5518 17.3994 16.9424 17.6104 16.1807 17.6104L8.38184 17.6104C8.17676 17.6104 8.00098 17.6836 7.85449 17.8301C7.70801 17.9766 7.63477 18.1523 7.63477 18.3574C7.63477 18.5625 7.70801 18.7383 7.85449 18.8848C8.00098 19.0371 8.17676 19.1133 8.38184 19.1133L16.0488 19.1133C16.8926 19.1133 17.625 18.9521 18.2461 18.6299C18.8672 18.3135 19.3447 17.874 19.6787 17.3115C20.0186 16.7549 20.1885 16.1133 20.1885 15.3867C20.1885 14.6602 20.0186 14.0127 19.6787 13.4443C19.3447 12.8818 18.8672 12.4395 18.2461 12.1172C17.625 11.7949 16.8926 11.6338 16.0488 11.6338H8.50781C7.73437 11.6338 7.125 11.417 6.67969 10.9834C6.22852 10.5557 6.00293 10.0195 6.00293 9.375C6.00293 8.73047 6.23145 8.19727 6.68848 7.77539C7.13965 7.35938 7.74609 7.15137 8.50781 7.15137L17.7539 7.14258C17.9531 7.14258 18.1289 7.06934 18.2812 6.92285C18.4277 6.77637 18.501 6.60059 18.501 6.39551ZM16.9277 4.37402V8.4082C16.9277 8.71875 17.0215 8.91211 17.209 8.98828C17.3906 9.07031 17.6016 9.02637 17.8418 8.85645L20.6455 6.8877C20.8447 6.74707 20.9443 6.58301 20.9443 6.39551C20.9502 6.20801 20.8506 6.04102 20.6455 5.89453L17.8506 3.92578C17.6045 3.75586 17.3906 3.70898 17.209 3.78516C17.0215 3.86133 16.9277 4.05762 16.9277 4.37402Z" />
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 4a9066ab05..1a715ccd95 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -2193,7 +2193,7 @@ export class Gutter {
if (type === "NodeList") {
submenu.push({
id: "listMindmap",
- icon: "iconGraph",
+ icon: nodeElement.getAttribute("custom-list-mindmap") === "1" ? "iconList" : "iconMindmap",
label: nodeElement.getAttribute("custom-list-mindmap") === "1" ?
window.siyuan.languages.listMindmapToList : window.siyuan.languages.listMindmapToMindmap,
click() {
@@ -3744,6 +3744,9 @@ export class Gutter {
}
let html = "";
let nodeElement = selectedElement || element;
+ const mindmapElement = nodeElement.getAttribute("data-type") === "NodeList" &&
+ nodeElement.getAttribute("custom-list-mindmap") === "1" ?
+ nodeElement.querySelector(":scope > .list-mindmap") : null;
const tabsHeader = !isMultiSelect && nodeElement.getAttribute("data-type") === "NodeTabs" ?
nodeElement.querySelector(":scope > .tabs-header") : null;
if (tabsHeader) {
@@ -3789,7 +3792,8 @@ export class Gutter {
}
if (index === 0) {
// 不单独显示,要不然在块的间隔中,gutter 会跳来跳去的
- if (!isMultiSelect && ["NodeBlockquote", "NodeList", "NodeCallout", "NodeSuperBlock"].includes(type)) {
+ if (!isMultiSelect && !mindmapElement &&
+ ["NodeBlockquote", "NodeList", "NodeCallout", "NodeSuperBlock"].includes(type)) {
if (target && type === "NodeCallout") {
// Callout 标题需显示
const calloutInfoElement = hasTopClosestByClassName(target, "callout-info");
@@ -3803,7 +3807,7 @@ export class Gutter {
}
}
- let topElement = selectedElement || (tabsHeader ? nodeElement : getTopAloneElement(nodeElement));
+ let topElement = selectedElement || (tabsHeader || mindmapElement ? nodeElement : getTopAloneElement(nodeElement));
if (embedContext && !embedContext.boundaryElement.contains(topElement)) {
// 单独查询列表项时,渲染器生成的无 ID 列表包装节点不属于可操作边界。
topElement = embedContext.targetElement || nodeElement;
@@ -3978,10 +3982,13 @@ data-type="fold"${viewOccurrenceID ? ` data-view-occurrence-id="${encodeURICompo
titleElement?.getBoundingClientRect().bottom,
);
}
- let rect = element.getBoundingClientRect();
+ // 脑图中的原始列表项已隐藏,使用可见面板定位列表块标。
+ let rect = (mindmapElement || element).getBoundingClientRect();
let marginHeight = 0;
const isRTL = window.siyuan.config.editor.rtl || getComputedStyle(element).direction === "rtl";
- if (listItem && !isRTL) {
+ if (mindmapElement) {
+ space = 0;
+ } else if (listItem && !isRTL) {
rect = listItem.firstElementChild.getBoundingClientRect();
space = 0;
} else if (nodeElement.getAttribute("data-type") === "NodeBlockQueryEmbed") {
diff --git a/app/src/protyle/render/listMindmap/index.ts b/app/src/protyle/render/listMindmap/index.ts
index f670dbaeb6..b44212d799 100644
--- a/app/src/protyle/render/listMindmap/index.ts
+++ b/app/src/protyle/render/listMindmap/index.ts
@@ -75,6 +75,15 @@ class ListMindmapController {
this.host = document.createElement("div");
this.host.className = "list-mindmap";
this.host.contentEditable = "false";
+ this.host.addEventListener("pointermove", event => {
+ if (event.pointerType !== "mouse" || event.buttons || !owner.options.render.gutter ||
+ !owner.gutter || this.host.classList.contains("fullscreen") ||
+ (event.target as Element).closest(".list-mindmap__editor, .protyle-toolbar, .protyle-util")) {
+ return;
+ }
+ // 脑图内部的鼠标事件不冒泡到编辑器,块标仍定位到原列表块。
+ owner.gutter.render(owner, list, this.host);
+ });
this.host.addEventListener("pointerdown", event => {
const target = event.target as HTMLElement;
// 脑图阻止事件冒泡,主动复用公共收起逻辑,并保留内嵌编辑器浮层的交互。