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: Retain single list item indicators in compact mode https://github.com/siyuan-note/siyuan/issues/20647
Daniel4e1212e460f8
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy b/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.syindex 59a1f4d71f..6686f3e665 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234731-h3zkwm2.sy@@ -7,7 +7,7 @@"id": "20200923234731-h3zkwm2","title": "FAQ","type": "doc",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{@@ -1068,7 +1068,7 @@"HeadingLevel": 2,"Properties": {"id": "20220501231348-sx3l5qp",- "updated": "20260809232000"+ "updated": "20261017234852"},"Children": [{@@ -1082,12 +1082,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017212429-ykfqzzo",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{"Type": "NodeText",- "Data": "Compact indicators are used by default. To show indicators for the current block and all its containers, open "+ "Data": "Compact indicators are used by default. Lists with only one item retain both the list and list item indicators. To show indicators for the current block and all its containers, open "},{"Type": "NodeTextMark",diff --git a/app/guide/20210808180117-czj9bvb/20200813093015-u6bopdt.sy b/app/guide/20210808180117-czj9bvb/20200813093015-u6bopdt.syindex 4601cf9f6c..d737e3e0c7 100644--- a/app/guide/20210808180117-czj9bvb/20200813093015-u6bopdt.sy+++ b/app/guide/20210808180117-czj9bvb/20200813093015-u6bopdt.sy@@ -7,7 +7,7 @@"id": "20200813093015-u6bopdt","title": "常见问题","type": "doc",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{@@ -1060,7 +1060,7 @@"HeadingLevel": 2,"Properties": {"id": "20220501230739-whydmx1",- "updated": "20260809232000"+ "updated": "20261017234852"},"Children": [{@@ -1074,12 +1074,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017212429-ssbwd82",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{"Type": "NodeText",- "Data": "默认使用精简块标。若要显示当前块及其所属容器的全部块标,可在 "+ "Data": "默认使用精简块标。只有一个列表项时,也会保留列表块和列表项块标。若要显示当前块及其所属容器的全部块标,可在 "},{"Type": "NodeTextMark",diff --git a/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy b/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.syindex 7b5aee48cd..c8a243d0c3 100644--- a/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115227-r1rty9v.sy@@ -7,7 +7,7 @@"id": "20211226115227-r1rty9v","title": "常見問題","type": "doc",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{@@ -1064,7 +1064,7 @@"HeadingLevel": 2,"Properties": {"id": "20220501231338-vlg2lgm",- "updated": "20260809232000"+ "updated": "20261017234852"},"Children": [{@@ -1078,12 +1078,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017212429-ke3nbw0",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{"Type": "NodeText",- "Data": "預設使用精簡區塊標。若要顯示目前區塊及其所屬容器的所有區塊標,可在 "+ "Data": "預設使用精簡區塊標。只有一個列表項時,也會保留列表區塊和列表項區塊標。若要顯示目前區塊及其所屬容器的所有區塊標,可在 "},{"Type": "NodeTextMark",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-jp793ic.sy b/app/guide/20240530133126-axarxgx/20240530101000-jp793ic.syindex b90101502a..1431277bf6 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-jp793ic.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-jp793ic.sy@@ -8,7 +8,7 @@"id": "20240530101000-jp793ic","title": "よくある質問","type": "doc",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{@@ -1110,7 +1110,7 @@"Properties": {"ID": "20240530101000-owjuw7q","id": "20240530101000-1u51q5t",- "updated": "20260809232000"+ "updated": "20261017234852"},"Children": [{@@ -1134,12 +1134,12 @@"Type": "NodeParagraph","Properties": {"id": "20261017212429-yem61n3",- "updated": "20261017212429"+ "updated": "20261017234852"},"Children": [{"Type": "NodeText",- "Data": "既定では簡略表示です。現在のブロックと、それを含むすべてのコンテナのアイコンを表示するには "+ "Data": "既定では簡略表示です。項目が1つだけのリストでも、リストとリスト項目のアイコンは表示されます。現在のブロックと、それを含むすべてのコンテナのアイコンを表示するには "},{"Type": "NodeTextMark",diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex d5a99cd406..01faf28191 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -1610,7 +1610,7 @@ export class Gutter {label: window.siyuan.languages.multiSelect,click: () => {const blockElement = getMobileBlockSelectionElement(nodeElement as HTMLElement,- window.siyuan.config.editor.blockGutterMode === 1);+ window.siyuan.config.editor.blockGutterMode === 1 || type === "NodeListItem");hideElements(["select"], protyle);window.getSelection()?.removeAllRanges();protyle.toolbar.showMultiSelectMode(protyle, blockElement);@@ -3783,6 +3783,11 @@ export class Gutter {}let topElement = selectedElement || (fullGutter || tabsHeader || mindmapElement ? nodeElement : getTopAloneElement(nodeElement));+ const listItemElement = nodeElement.closest('[data-type="NodeListItem"]');+ if (!fullGutter && !isMultiSelect && listItemElement && topElement.contains(listItemElement)) {+ // 精简模式保留列表项入口,其内部段落仍合并到列表项块标。+ topElement = listItemElement;+ }if (!fullGutter && listItemContainer && topElement.contains(listItemContainer)) {topElement = nodeElement === listItemContainer.parentElement ? nodeElement : listItemContainer;}diff --git a/app/tests/listContainerGutter.test.js b/app/tests/listContainerGutter.test.jsindex 406d87fd27..495ebe7499 100644--- a/app/tests/listContainerGutter.test.js+++ b/app/tests/listContainerGutter.test.js@@ -10,6 +10,19 @@ const sources = (full = false) => {const gutter = source.statements.find(node => ts.isClassDeclaration(node) && node.name.text === "Gutter");const render = gutter.members.find(node => node.name?.getText(source) === "render");const getNodeElement = gutter.members.find(node => node.name?.getText(source) === "getNodeElement");+ const renderMenu = gutter.members.find(node => node.name?.getText(source) === "renderMenu");+ let multiSelectAction;+ const collectMultiSelect = node => {+ if (ts.isObjectLiteralExpression(node) && node.properties.some(property =>+ property.name?.getText(source) === "id" && property.initializer?.getText(source) === '"multiSelect"')) {+ multiSelectAction = node.properties.find(property => property.name?.getText(source) === "click").initializer;+ }+ ts.forEachChild(node, collectMultiSelect);+ };+ collectMultiSelect(renderMenu);+ assert.ok(multiSelectAction);+ const menuType = renderMenu.body.statements.find(node => ts.isVariableStatement(node) &&+ node.declarationList.declarations.some(declaration => declaration.name.getText(source) === "type"));const interactions = [];const collectInteractions = node => {if (ts.isCallExpression(node) && node.expression.getText(source) === "this.element.addEventListener" &&@@ -22,7 +35,7 @@ const sources = (full = false) => {const body = full ? render.body.getText(source) :render.body.getText(source).split("const shouldRenderInsert")[0] + "return html; }";const helpers = ["protyle/gutter/container.ts", "protyle/wysiwyg/getBlock.ts", "protyle/gutter/layout.ts",- "protyle/util/hasClosest.ts", "protyle/render/autoDirection.ts"].map(file => {+ "protyle/util/hasClosest.ts", "protyle/render/autoDirection.ts", "mobile/util/blockSelection.ts"].map(file => {const source = ts.createSourceFile(file, readFileSync(path.join(__dirname, "../src", file), "utf8"),ts.ScriptTarget.Latest, true);return source.statements.filter(node => ts.isVariableStatement(node) &&@@ -30,7 +43,8 @@ const sources = (full = false) => {"getSbChildBlockCount", "getParentBlock", "getGutterMarginHeight", "getFixedGutterPosition","getBacklinkGutterContentTop", "getListGutterAnchorLeft", "getContainerGutterSpace", "isContainerGutterBridge","hasClosestBlock", "isBlockElement", "hasClosestByClassName", "hasTopClosestByClassName", "hasClosestByTag",- "hasClosestByAttribute", "getAutoListDirection", "listSelector", "directionAttribute"].includes(declaration.name.getText(source))))+ "hasClosestByAttribute", "getAutoListDirection", "listSelector", "directionAttribute",+ "getMobileBlockSelectionElement"].includes(declaration.name.getText(source)))).map(node => node.getText(source)).join("\n");}).join("\n").replace(/export const /g, "const ");const hoverSource = ts.createSourceFile("initUI.ts", readFileSync(path.join(__dirname,@@ -49,6 +63,10 @@ const sources = (full = false) => {.replace(/^import .*;\r?\n/gm, "").replace(/^export /gm, "") +`\nfunction bindHover(protyle) { let overAttr = false; ${hoverBinding}; }`;const interactionSource = `function getNodeElement(protyle, element) ${getNodeElement.body.getText(source)}+function mobileMultiSelect(protyle, nodeElement) {+ ${menuType.getText(source)}+ return (${multiSelectAction.getText(source)})();+}function bindInteractions(protyle) {let isGutterDragging = false;let dragCleanupController;@@ -89,8 +107,8 @@ const cases = (source, fullSource, css) => {toggleMenu: options => options.build(null, {show: callback => callback()}),};const render = new Function(...Object.keys(dependencies), source + "\nreturn render;")(...Object.values(dependencies));- const {render: renderFull, windowMouseMove, bindHover, getNodeElement, bindInteractions} = new Function(...Object.keys(dependencies),- fullSource + "\nreturn {render, windowMouseMove, bindHover, getNodeElement, bindInteractions};")(...Object.values(dependencies));+ const {render: renderFull, windowMouseMove, bindHover, getNodeElement, bindInteractions, mobileMultiSelect} = new Function(...Object.keys(dependencies),+ fullSource + "\nreturn {render, windowMouseMove, bindHover, getNodeElement, bindInteractions, mobileMultiSelect};")(...Object.values(dependencies));let mobile = false;window.siyuan = {languages: {fold: "Fold", rowTip: "Row", addBelowAbove: "Add"}, layout: {}, blockPanels: [],config: {editor: {fontSize: 16, rtl: false}, system: {workspaceDir: "test"}}};@@ -265,7 +283,7 @@ ${legacyMindmap ? 'custom-sy-list-mindmap="1"' : ""}>${content}${attr}</div>${p(}check.deepEqual(movements, [], "moving to the marker must preserve gutters");- window.siyuan.config.editor.blockGutterMode = 1;+ window.siyuan.config.editor.blockGutterMode = 0;window.siyuan.menus = {menu: {element: document.createElement("div"), remove() {}, fullscreen() {}, popup() {}}};Object.assign(protyle, {toolbar: {range: {}}, block: {rootID: "document"}, notebookId: "notebook"});gutter.getNodeElement = (...args) => getNodeElement.apply(gutter, args);@@ -292,6 +310,52 @@ ${legacyMindmap ? 'custom-sy-list-mindmap="1"' : ""}>${content}${attr}</div>${p(check.equal(folded.at(-1), id);});};+ for (const platform of [false, true]) {+ mobile = platform;+ for (const subtype of ["u", "o", "t"]) {+ root.innerHTML = `<div data-node-id="list" data-type="NodeList" data-subtype="${subtype}" class="list"><div data-node-id="item" data-type="NodeListItem" data-subtype="${subtype}" class="li"><div class="protyle-action">-</div>${p("paragraph")}${attr}</div>${attr}</div>`;+ const paragraph = root.querySelector('[data-node-id="paragraph"]');+ gutter.render(protyle, paragraph);+ assertTargets(["list", "item"]);+ check.equal(gutter.element.classList.contains("protyle-gutters--full"), false);+ const before = state();+ check.deepEqual(hover(root.querySelector(".protyle-action")), before,+ "compact single-item indicators stay stable when moving to the list marker");+ if (mobile) {+ let selected;+ protyle.toolbar.showMultiSelectMode = (_owner, element) => { selected = element; };+ const item = root.querySelector('[data-node-id="item"]');+ mobileMultiSelect(protyle, item);+ check.equal(selected, item, "the compact list item menu selects the item instead of the whole list");+ }+ const list = root.querySelector('[data-node-id="list"]');+ list.lastElementChild.insertAdjacentHTML("beforebegin", `<div data-node-id="second-item" data-type="NodeListItem" data-subtype="${subtype}" class="li"><div class="protyle-action">-</div>${p("second-paragraph")}${attr}</div>`);+ gutter.render(protyle, paragraph);+ assertTargets(["list", "item"]);+ gutter.render(protyle, root.querySelector('[data-node-id="second-paragraph"]'));+ assertTargets(["second-item"]);+ root.querySelector('[data-node-id="second-item"]').remove();+ gutter.render(protyle, paragraph);+ assertTargets(["list", "item"]);+ paragraph.insertAdjacentHTML("afterend", p("extra-paragraph"));+ gutter.render(protyle, paragraph);+ assertTargets(["list", "item"]);+ check.equal(gutter.element.querySelector('[data-type="fold"]').previousElementSibling.dataset.nodeId, "item");+ }+ const list = `<div data-node-id="list" data-type="NodeList" class="list"><div data-node-id="item" data-type="NodeListItem" class="li"><div class="protyle-action">-</div>${p("paragraph")}${attr}</div>${attr}</div>`;+ for (const [html, ids] of [+ [`<div data-node-id="quote" data-type="NodeBlockquote" class="bq">${list}${attr}</div>`, ["quote", "list", "item"]],+ [`<div data-node-id="callout" data-type="NodeCallout" class="callout"><div class="callout-info">Title</div><div class="callout-content">${list}</div>${attr}</div>`, ["list", "item"]],+ [`<div data-node-id="super" data-type="NodeSuperBlock" class="sb" data-sb-layout="row">${list}${attr}</div>`, ["super", "list", "item"]],+ [`<div data-node-id="tabs" data-type="NodeTabs" class="tabs"><div class="tabs-header">Tab</div><div data-node-id="tab" data-type="NodeTabItem" class="tab-item"><div class="tab-item-content">${list}</div>${attr}</div>${attr}</div>`, ["tab", "list", "item"]],+ ]) {+ root.innerHTML = html;+ gutter.render(protyle, root.querySelector('[data-node-id="paragraph"]'));+ assertTargets(ids);+ }+ }++ window.siyuan.config.editor.blockGutterMode = 1;for (const platform of [false, true]) {mobile = platform;for (const [type, cls, content, layout = "row"] of fixtures) {@@ -363,7 +427,7 @@ ${legacyMindmap ? 'custom-sy-list-mindmap="1"' : ""}>${content}${attr}</div>${p(window.siyuan.config.editor.blockGutterMode = 0;root.innerHTML = `<div data-node-id="list" data-type="NodeList" class="list"><div data-node-id="item" data-type="NodeListItem" class="li"><div class="protyle-action"></div>${p("paragraph")}${attr}</div>${attr}</div>`;gutter.render(protyle, root.querySelector('[data-node-id="paragraph"]'));- check.deepEqual(state().ids, ["list"], "switching back restores compact mode");+ check.deepEqual(state().ids.sort(), ["item", "list"], "narrow compact mode retains both list and item indicators");check.equal(gutter.element.style.maxHeight, "");check.equal(gutter.element.style.overflowY, "");check.equal(gutter.element.dataset.scrollable, undefined);