An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Improve mind map color selection and snapping https://github.com/siyuan-note/siyuan/issues/20856
Danielafdfc6f612bd
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.syindex cb4b6d84e9..d1da41f471 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20200924093441-ft2rhps.sy@@ -8,7 +8,7 @@"title": "Formatting elements","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20261027172226"+ "updated": "20261027231810"},"Children": [{@@ -2052,7 +2052,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091509-v1x69oc",- "updated": "20261025114801"+ "updated": "20261027231810"},"Children": [{@@ -3003,7 +3003,7 @@"Type": "NodeHeading","Properties": {"id": "20261024161816-xo714c2",- "updated": "20261024161816"+ "updated": "20261027231810"},"Children": [{@@ -3078,12 +3078,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-2f033n1",- "updated": "20261012014859"+ "updated": "20261027231810"},"Children": [{"Type": "NodeText",- "Data": "Double-click the summary text, or select the summary and use the edit button at the bottom, to edit it. Enter saves and Esc cancels. You can change its color or delete it using the bottom toolbar; Delete also removes the selected summary. These changes support undo and redo."+ "Data": "Double-click the summary text to edit it. Enter saves and Esc cancels. You can change its color or delete it using the bottom toolbar; Delete also removes the selected summary. These changes support undo and redo."}]},diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.syindex dbdc3309a2..978def95d1 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20200825162036-4dx365o.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20261027172226"+ "updated": "20261027231810"},"Children": [{@@ -2055,7 +2055,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091228-wdpx6ev",- "updated": "20261025114801"+ "updated": "20261027231810"},"Children": [{@@ -2819,7 +2819,7 @@"Type": "NodeHeading","Properties": {"id": "20261024161816-qjux5s9",- "updated": "20261024161816"+ "updated": "20261027231810"},"Children": [{@@ -2880,12 +2880,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-csjz6es",- "updated": "20261012014859"+ "updated": "20261027231810"},"Children": [{"Type": "NodeText",- "Data": "双击概要文字,或选中概要后点击底部的编辑按钮,即可修改文字;Enter 保存,Esc 取消。可以通过底部工具栏修改颜色或删除概要,也可以按 Delete 删除选中的概要。这些操作均支持撤销和重做。"+ "Data": "双击概要文字即可修改文字;Enter 保存,Esc 取消。可以通过底部工具栏修改颜色或删除概要,也可以按 Delete 删除选中的概要。这些操作均支持撤销和重做。"}]},diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.syindex 144184d1e4..f0193d8517 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20211226121319-emrk2yy.sy@@ -8,7 +8,7 @@"title": "排版元素","title-img": "background-color: hsl(2, 57%, 40%);background-image: repeating-linear-gradient(transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(270deg, transparent, transparent 50px, rgba(0,0,0,.4) 50px, rgba(0,0,0,.4) 53px, transparent 53px, transparent 63px, rgba(0,0,0,.4) 63px, rgba(0,0,0,.4) 66px, transparent 66px, transparent 116px, rgba(0,0,0,.5) 116px, rgba(0,0,0,.5) 166px, rgba(255,255,255,.2) 166px, rgba(255,255,255,.2) 169px, rgba(0,0,0,.5) 169px, rgba(0,0,0,.5) 179px, rgba(255,255,255,.2) 179px, rgba(255,255,255,.2) 182px, rgba(0,0,0,.5) 182px, rgba(0,0,0,.5) 232px, transparent 232px),repeating-linear-gradient(125deg, transparent, transparent 2px, rgba(0,0,0,.2) 2px, rgba(0,0,0,.2) 3px, transparent 3px, transparent 5px, rgba(0,0,0,.2) 5px);","type": "doc",- "updated": "20261027172226"+ "updated": "20261027231810"},"Children": [{@@ -2053,7 +2053,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226122008-731sqd6",- "updated": "20261025114801"+ "updated": "20261027231810"},"Children": [{@@ -2817,7 +2817,7 @@"Type": "NodeHeading","Properties": {"id": "20261024161816-6yvoml8",- "updated": "20261024161816"+ "updated": "20261027231810"},"Children": [{@@ -2878,12 +2878,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-nenflr8",- "updated": "20261012014859"+ "updated": "20261027231810"},"Children": [{"Type": "NodeText",- "Data": "按兩下概要文字,或選取概要後點選底部的編輯按鈕,即可修改文字;Enter 儲存,Esc 取消。可以透過底部工具列修改顏色或刪除概要,也可以按 Delete 刪除選取的概要。這些操作皆支援復原與重做。"+ "Data": "按兩下概要文字即可修改文字;Enter 儲存,Esc 取消。可以透過底部工具列修改顏色或刪除概要,也可以按 Delete 刪除選取的概要。這些操作皆支援復原與重做。"}]},diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.syindex ab28467877..25cf262660 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20240530101000-3qhz7br.sy@@ -9,7 +9,7 @@"title": "書式要素","title-img": "background-color:#269;background-image: linear-gradient(white 2px, transparent 2px),linear-gradient(90deg, white 2px, transparent 2px),linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px);background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px;","type": "doc",- "updated": "20261027172226"+ "updated": "20261027231810"},"Children": [{@@ -2177,7 +2177,7 @@"Properties": {"ID": "20240530101000-ch5e4vh","id": "20240530101000-1ev7xub",- "updated": "20261025114801"+ "updated": "20261027231810"},"Children": [{@@ -3064,7 +3064,7 @@"Type": "NodeHeading","Properties": {"id": "20261024161816-ymjcdgg",- "updated": "20261024164212"+ "updated": "20261027231810"},"Children": [{@@ -3139,12 +3139,12 @@"Type": "NodeParagraph","Properties": {"id": "20260926151827-l7l2w92",- "updated": "20261012014859"+ "updated": "20261027231810"},"Children": [{"Type": "NodeText",- "Data": "要約テキストをダブルクリックするか、要約を選択して下部の編集ボタンを押すと、テキストを編集できます。Enter で保存し、Esc でキャンセルします。下部のツールバーで色の変更や削除ができ、Delete でも選択中の要約を削除できます。これらの操作は元に戻す・やり直しに対応しています。"+ "Data": "要約テキストをダブルクリックすると、テキストを編集できます。Enter で保存し、Esc でキャンセルします。下部のツールバーで色の変更や削除ができ、Delete でも選択中の要約を削除できます。これらの操作は元に戻す・やり直しに対応しています。"}]},diff --git a/app/src/assets/scss/business/_color.scss b/app/src/assets/scss/business/_color.scssindex 37f432a79e..ea4b346f74 100644--- a/app/src/assets/scss/business/_color.scss+++ b/app/src/assets/scss/business/_color.scss@@ -32,14 +32,29 @@&--compact {margin: 0;+ position: relative;- // 紧凑排列时将反馈限制在按钮内部,避免被滚动边界或相邻色卡遮挡。+ // 细边框和角标保留色块大小,并避免反馈被滚动边界或相邻色卡遮挡。&:hover:not(.color__square--list):not(.color__square--current) {- box-shadow: 0 0 0 1px var(--b3-border-color) inset, 0 0 0 3px var(--b3-list-hover) inset;+ box-shadow: 0 0 0 1px var(--b3-theme-primary) inset;}&.color__square--current {- box-shadow: 0 0 0 1px var(--b3-menu-background) inset, 0 0 0 3px var(--b3-list-hover) inset;+ box-shadow: 0 0 0 1px var(--b3-list-hover) inset;+ }++ > .color__square-mark {+ position: absolute;+ right: 0;+ bottom: 0;+ width: 12px;+ height: 12px;+ padding: 1px;+ box-sizing: border-box;+ border-radius: var(--b3-border-radius) 0;+ background-color: var(--b3-theme-primary);+ color: var(--b3-theme-on-primary);+ pointer-events: none;}}}diff --git a/app/src/assets/scss/protyle/_mindmap-view.scss b/app/src/assets/scss/protyle/_mindmap-view.scssindex 71882304ee..c1268bf98f 100644--- a/app/src/assets/scss/protyle/_mindmap-view.scss+++ b/app/src/assets/scss/protyle/_mindmap-view.scss@@ -1029,6 +1029,16 @@width: 100%;order: 0;scrollbar-width: none;+ scroll-snap-type: x mandatory;+ scroll-padding-left: max(0px, calc((100% / var(--mindmap-palette-columns) - 26px) / 2));++ &[data-scrolling] {+ scroll-snap-type: none;+ }++ > .color__square {+ scroll-snap-align: start;+ }}}diff --git a/app/src/protyle/render/listMindmap/inspector.test.ts b/app/src/protyle/render/listMindmap/inspector.test.tsindex 319cbc2c50..12beb4625d 100644--- a/app/src/protyle/render/listMindmap/inspector.test.ts+++ b/app/src/protyle/render/listMindmap/inspector.test.ts@@ -37,6 +37,8 @@ const browserCases = async (source: string, css: string) => {const model = api.readListMindmap(holder.firstElementChild);const original = holder.innerHTML;const view = new api.ListMindmapView({host, model, onExit: () => {},+ colors: () => Array.from({length: 13}, (_, i) => ({label: `Color ${i}`, value: `rgb(${i}, 0, 0)`})),+ onManageLineColors: () => {},onNodeWidths: async () => true});const inspector = host.querySelector<HTMLElement>(".mindmap-view__inspector");const panel = host.querySelector<HTMLElement>(".mindmap-view__inspector-popover");@@ -54,6 +56,22 @@ const browserCases = async (source: string, css: string) => {`vertical bounds ${rect.top}..${rect.bottom} within ${clip.top}..${clip.bottom}`);check.ok(rect.left >= clip.left - 1 && rect.right <= clip.right + 1);};+ const checkPalette = async (columns: number) => {+ const palette = inspector.querySelector<HTMLElement>(".mindmap-view__palette");+ const row = palette.parentElement;+ check.equal(row.style.getPropertyValue("--mindmap-palette-columns"), String(columns));+ check.ok(palette.querySelector('[aria-pressed="true"] .color__square-mark'));+ const controls = Array.from(row.children).slice(1);+ const positions = controls.map(control => control.getBoundingClientRect().left);+ palette.scrollLeft = 73;+ await settle();+ const step = parseFloat(getComputedStyle(palette).gridTemplateColumns);+ check.ok(palette.scrollLeft > 0);+ check.ok(Math.abs(palette.scrollLeft - Math.round(palette.scrollLeft / step) * step) < 1,+ `${stage}: ${columns} color columns snap into alignment at scale ${scale}`);+ check.deepEqual(controls.map(control => control.getBoundingClientRect().left), positions,+ "scroll snapping keeps action and settings controls fixed");+ };await settle();select();await settle();@@ -134,13 +152,26 @@ const browserCases = async (source: string, css: string) => {view.renderInspector();await settle();visible(inspector);+ await checkPalette(7);view.selectedEdge = undefined;+ view.model.metadata.relations.push({id: "relation", from: model.root.children[0].id,+ to: model.root.children[1].id, label: "Relation"});+ view.selectedRelation = "relation";+ view.renderInspector();+ stage = "relation";+ await settle();+ visible(inspector);+ await checkPalette(5);+ view.selectedRelation = undefined;+ view.model.metadata.relations = [];view.model.metadata.summaries = [{id: "summary", label: "Summary", parentId: model.root.id,nodeIds: model.root.children.map((node: {id: string}) => node.id)}];view.selectSummary("summary");stage = "summary";await settle();visible(inspector);+ check.equal(inspector.querySelector('[aria-label="edit"]'), null);+ await checkPalette(6);delete view.model.metadata.summaries;select();diff --git a/app/src/protyle/render/listMindmap/model.test.ts b/app/src/protyle/render/listMindmap/model.test.tsindex f479cab8c3..fdacc3a199 100644--- a/app/src/protyle/render/listMindmap/model.test.ts+++ b/app/src/protyle/render/listMindmap/model.test.ts@@ -2311,6 +2311,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,host.style.setProperty("--b3-list-hover", "rgba(100, 100, 100, .4)");host.style.setProperty("--b3-menu-background", "#fff");host.style.setProperty("--b3-border-color", "#888");+ host.style.setProperty("--b3-theme-primary", "#3583ff");view.selectNode(alpha, true);for (const width of [240, 320, 760]) {host.style.width = `${width}px`;@@ -2348,14 +2349,21 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,"the next color stays outside the first page");}const selectedColor = palettes[0].querySelector<HTMLElement>(".color__square--current");- check.equal(getComputedStyle(selectedColor).boxShadow.match(/inset/g)?.length, 2,- "selected colors keep both feedback rings inside the clipped palette");+ check.equal(getComputedStyle(selectedColor).boxShadow.match(/inset/g)?.length, 1,+ "selection preserves the thin original border instead of shrinking the color fill");+ check.equal(selectedColor.querySelector(".color__square-mark use")?.getAttribute("xlink:href"), "#iconSelect",+ "selected node colors display a check mark");+ check.equal(selectedColor.offsetWidth, 26);+ check.equal(selectedColor.offsetHeight, 26);+ const selectedLine = palettes[1].querySelector<HTMLElement>('[aria-pressed="true"]');+ check.equal(selectedLine.getAttribute("aria-label"), "default");+ check.ok(selectedLine.querySelector(".color__square-mark"), "multi-node line colors mark their common value");await moveMouse();- await moveMouse(palettes[0].children[6]);- check.equal(getComputedStyle(palettes[0].children[6]).boxShadow.match(/inset/g)?.length, 2,- "hover feedback also stays inside the last visible color: " + JSON.stringify({width,- hover: palettes[0].children[6].matches(":hover"), bounds: palettes[0].children[6].getBoundingClientRect().toJSON(),- shadow: getComputedStyle(palettes[0].children[6]).boxShadow}));+ for (const palette of palettes) {+ await moveMouse(palette.children[6]);+ check.equal(getComputedStyle(palette.children[6]).boxShadow, "rgb(53, 131, 255) 0px 0px 0px 1px inset",+ "node and line hover use a uniform thin border inside the last visible color");+ }const beforeSettings = nodeStyles.length;managers[0].focus();check.equal(host.querySelector('[role="tooltip"]').textContent, "listMindmapManageNodeColors");@@ -2369,6 +2377,31 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,palettes[1].querySelector<HTMLButtonElement>('[aria-label="Line 14"]').click();check.deepEqual(nodeStyles.at(-1), [view.getSelectedIds(), {lineColor: "rgb(14, 0, 0)"}]);}+ const originalAlphaStyle = model.metadata.nodes[alpha];+ const originalBetaStyle = model.metadata.nodes[beta];+ for (const [alphaColor, betaColor] of [["rgb(2, 0, 0)", "rgb(2, 0, 0)"], ["rgb(2, 0, 0)", "rgb(3, 0, 0)"]]) {+ model.metadata.nodes[alpha] = {...originalAlphaStyle, lineColor: alphaColor};+ model.metadata.nodes[beta] = {...originalBetaStyle, lineColor: betaColor};+ view.renderInspector();+ inspector.querySelector<HTMLButtonElement>('[aria-label="color"]').click();+ const lines = host.querySelectorAll<HTMLElement>(".mindmap-view__inspector-popover .mindmap-view__palette")[1];+ const selected = lines.querySelectorAll('[aria-pressed="true"]');+ check.equal(selected.length, alphaColor === betaColor ? 1 : 0, "mixed line colors never indicate a false common selection");+ if (selected.length) {+ check.equal(selected[0].getAttribute("aria-label"), "Line 2");+ check.ok(selected[0].querySelector(".color__square-mark"));+ }+ }+ if (originalAlphaStyle) {+ model.metadata.nodes[alpha] = originalAlphaStyle;+ } else {+ delete model.metadata.nodes[alpha];+ }+ if (originalBetaStyle) {+ model.metadata.nodes[beta] = originalBetaStyle;+ } else {+ delete model.metadata.nodes[beta];+ }options.nodeColors = () => Array.from({length: 13}, (_, i) => ({label: `Color ${i}`, color: `rgb(${i}, 0, 0)`, backgroundColor: "",preview: {color: `rgb(${i}, 0, 0)`, backgroundColor: ""}}));options.colors = () => Array.from({length: 13}, (_, i) => ({label: `Line ${i}`, value: `rgb(${i}, 0, 0)`}));@@ -2401,6 +2434,21 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,const touchManager = touchPalette.nextElementSibling;const managerPosition = touchManager.getBoundingClientRect().left;const beforeColorSwipe = nodeStyles.length;+ const settlePalette = async () => {+ const deadline = performance.now() + 2000;+ let stable = 0;+ let last = -1;+ while (performance.now() < deadline && stable < 12) {+ await frame();+ stable = !touchPalette.hasAttribute("data-scrolling") && Math.abs(touchPalette.scrollLeft - last) < .1 ? stable + 1 : 0;+ last = touchPalette.scrollLeft;+ }+ const step = parseFloat(getComputedStyle(touchPalette).gridTemplateColumns);+ check.ok(Math.abs(touchPalette.scrollLeft - Math.round(touchPalette.scrollLeft / step) * step) < 1 ||+ Math.abs(touchPalette.scrollLeft - (touchPalette.scrollWidth - touchPalette.clientWidth)) < 1,+ "scrolling settles on a complete color column: " + JSON.stringify({left: touchPalette.scrollLeft, step}));+ check.ok(stable >= 12, "palette scrolling settles within the deadline");+ };const swipeStart = {x: Math.round(touchBounds.right - 12), y: Math.round(touchBounds.top + touchBounds.height / 2)};await require("electron").ipcRenderer.invoke("mindmap-view-native-touch", [{type: "touchStart", touchPoints: [{id: 1, ...swipeStart}]},@@ -2408,7 +2456,7 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,touchPoints: [{id: 1, x: swipeStart.x - delta, y: swipeStart.y}]})),{type: "touchEnd", touchPoints: []},]);- await settle();+ await settlePalette();check.ok(touchPalette.scrollLeft > 0, "a native horizontal swipe reaches colors beyond the first six groups");check.equal(touchManager.getBoundingClientRect().left, managerPosition, "swiping the palette keeps color settings fixed");check.equal(nodeStyles.length, beforeColorSwipe, "swiping colors does not apply a color or alter document styles");@@ -2427,15 +2475,18 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,]);await settle();check.ok(touchPalette.scrollLeft > 0, "a native vertical mouse wheel browses the horizontal palette");+ await settlePalette();touchPalette.scrollLeft = 0;await nativeInput([{type: "mouseMove", ...start},{type: "mouseDown", ...start, button: "left", clickCount: 1},...[20, 40, 60, 80].map(delta => ({type: "mouseMove", x: start.x - delta, y: start.y, button: "left"})),- {type: "mouseUp", x: start.x - 80, y: start.y, button: "left", clickCount: 1},]);await settle();- check.ok(Math.abs(touchPalette.scrollLeft - 80 / scale) < 2, "mouse dragging accounts for an outer editor scale");+ check.ok(Math.abs(touchPalette.scrollLeft - 80 / scale) < 2,+ "mouse dragging stays continuous and accounts for an outer editor scale before release");+ await nativeInput([{type: "mouseUp", x: start.x - 80, y: start.y, button: "left", clickCount: 1}]);+ await settlePalette();check.equal(nodeStyles.length, beforeColorSwipe, "drag release never applies the color underneath the pointer");check.deepEqual(view.getSelectedIds(), paletteSelection);check.deepEqual({x: view.offsetX, y: view.offsetY, scale: view.scale}, canvasPosition);@@ -5239,32 +5290,29 @@ const browserCases = async (sourceCode: string, css: string, taskSource: string,summaryLabel.click();check.equal(summaryView.selectedSummary, "summary", "touching the summary selects it");const summaryInspector = summaryHost.querySelector<HTMLElement>(".mindmap-view__inspector");- let summaryEdit = summaryInspector.querySelector<HTMLButtonElement>('[aria-label="edit"]');- check.ok(summaryEdit, "summary editing retains its explicit toolbar entry");+ check.equal(summaryInspector.querySelector('[aria-label="edit"]'), null, "summary editing uses the same double-click gesture as nodes");for (const width of [240, 320, 700]) {summaryHost.style.width = `${width}px`;summaryView.renderInspector();await settle();const summaryPalette = summaryInspector.querySelector<HTMLElement>(".mindmap-view__palette");- const fixed = ["edit", "delete", "listMindmapManageLineColors"]+ const fixed = ["delete", "listMindmapManageLineColors"].map(key => summaryInspector.querySelector<HTMLElement>(`[aria-label="${key}"]`));+ check.ok(summaryPalette.children[5].getBoundingClientRect().right <= summaryPalette.getBoundingClientRect().right + 1,+ "removing the edit control leaves room for default and five summary colors");+ check.ok(summaryPalette.children[6].getBoundingClientRect().left >= summaryPalette.getBoundingClientRect().right - 1);const positions = fixed.map(control => control.getBoundingClientRect().left);summaryPalette.scrollLeft = summaryPalette.scrollWidth;check.deepEqual(fixed.map(control => control.getBoundingClientRect().left), positions,- "summary edit, delete and color settings stay fixed while colors scroll");+ "summary delete and color settings stay fixed while colors scroll");const bounds = summaryInspector.getBoundingClientRect();fixed.forEach(control => check.ok(control.getBoundingClientRect().right <= bounds.right));check.equal(summaryPalette.children.length, 14, "all existing summary colors remain accessible");}summaryHost.style.width = "700px";- summaryEdit = summaryInspector.querySelector<HTMLButtonElement>('[aria-label="edit"]');- summaryEdit.click();- check.ok(summaryHost.querySelector(".mindmap-view__summary-editor"), "the retained edit button opens summary text editing");- summaryHost.querySelector<HTMLInputElement>(".mindmap-view__summary-editor")- .dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));summaryLabel.dispatchEvent(new MouseEvent("dblclick", {bubbles: true}));const reopenedSummary = summaryHost.querySelector<HTMLInputElement>(".mindmap-view__summary-editor");- check.ok(reopenedSummary);+ check.ok(reopenedSummary, "double-clicking still opens summary text editing without the toolbar edit button");reopenedSummary.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));const savedSummary = api.readListMindmap(summaryList).metadata.summaries[0];const summaryContext = summaryHost.querySelector("canvas").getContext("2d");diff --git a/app/src/protyle/render/listMindmap/view.ts b/app/src/protyle/render/listMindmap/view.tsindex a63d92f315..eb7ea924d9 100644--- a/app/src/protyle/render/listMindmap/view.ts+++ b/app/src/protyle/render/listMindmap/view.ts@@ -3880,9 +3880,19 @@ export class ListMindmapView {}private makePaletteRow(palette: HTMLElement, controls: HTMLElement[], columns = 8) {+ palette.querySelectorAll(".color__square--current").forEach(control => {+ control.insertAdjacentHTML("beforeend",+ '<svg class="color__square-mark" aria-hidden="true"><use xlink:href="#iconSelect"></use></svg>');+ });// 触屏沿用原生横向滚动,鼠标支持拖动和滚轮浏览;拖动完成后不触发色卡点击。let drag: {id: number, x: number, scroll: number, scale: number};let moved = false;+ let wheelTimer: number;+ const snap = () => {+ if (!drag) {+ palette.removeAttribute("data-scrolling");+ }+ };palette.addEventListener("pointerdown", (event: PointerEvent) => {moved = false;if (event.pointerType !== "mouse" || event.button !== 0 ||@@ -3902,6 +3912,7 @@ export class ListMindmapView {}if (!moved) {moved = true;+ palette.setAttribute("data-scrolling", "");palette.setPointerCapture(event.pointerId);this.tooltip.hidden = true;}@@ -3911,6 +3922,7 @@ export class ListMindmapView {const end = (event: PointerEvent) => {if (drag?.id === event.pointerId) {drag = undefined;+ snap();}};palette.addEventListener("pointerup", end);@@ -3919,6 +3931,7 @@ export class ListMindmapView {palette.addEventListener("pointerleave", () => {if (!moved) {drag = undefined;+ snap();}});palette.addEventListener("click", event => {@@ -3934,9 +3947,12 @@ export class ListMindmapView {}const delta = Math.abs(event.deltaX) > Math.abs(event.deltaY) ? event.deltaX : event.deltaY;if (delta) {+ palette.setAttribute("data-scrolling", "");+ window.clearTimeout(wheelTimer);const unit = event.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 :event.deltaMode === WheelEvent.DOM_DELTA_PAGE ? palette.clientWidth : 1;palette.scrollLeft += delta * unit;+ wheelTimer = window.setTimeout(snap, 160);event.preventDefault();}}, {passive: false});@@ -4006,7 +4022,10 @@ export class ListMindmapView {lines.setAttribute("aria-label", this.label("listMindmapLineColor"));[{label: this.label("default"), value: ""}, ...(this.options.colors?.() || [])].forEach(item => {const control = button("color", "", () => change({lineColor: item.value}));+ const selected = panel.ids.every(id => (this.model.metadata.nodes[id]?.lineColor || "") === item.value);control.setAttribute("aria-label", item.label);+ control.setAttribute("aria-pressed", String(selected));+ control.classList.toggle("color__square--current", selected);control.style.backgroundColor = item.value || "var(--b3-theme-background)";lines.append(control);});@@ -4121,8 +4140,7 @@ export class ListMindmapView {const summary = this.model.metadata.summaries?.find(item => item.id === this.selectedSummary);if (summary) {color(summary.color, value => this.options.onSummaryChange?.(summary.id, {color: value}),- [squareButton("edit", "iconEdit", () => this.editSummaryLabel(summary.id)),- squareButton("delete", "iconTrashcan", () => this.options.onSummaryDelete?.(summary.id))]);+ [squareButton("delete", "iconTrashcan", () => this.options.onSummaryDelete?.(summary.id))]);}return;}