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: Prevent list range selection from expanding across super block columns https://github.com/siyuan-note/siyuan/issues/19086
Daniel7a85f9890b75
diff --git a/app/src/protyle/util/blockRangeSelect.test.ts b/app/src/protyle/util/blockRangeSelect.test.tsindex 3ac51ac9be..e85fbf4dae 100644--- a/app/src/protyle/util/blockRangeSelect.test.ts+++ b/app/src/protyle/util/blockRangeSelect.test.ts@@ -54,6 +54,10 @@ class TestElement {return attribute === "data-node-id" && !!this.type;}+ contains(element: TestElement): boolean {+ return this === element || this.children.some(child => child.contains(element));+ }+getBoundingClientRect() {return {bottom: this.top + 10,@@ -135,4 +139,33 @@ describe("getBlockRangeSelectElements", () => {assert.deepEqual(upwardSelection.selectElements, expected);assert.equal(upwardSelection.toDown, false);});++ it("stops at a list containing the range end in the left vertical super block", () => {+ const editor = new TestElement("editor", 0, ["protyle-wysiwyg"]);+ const outer = block("outer", 0, "NodeSuperBlock", ["sb"]);+ const left = block("left", 0, "NodeSuperBlock", ["sb"]);+ const first = block("first", 10);+ const list = block("list", 20, "NodeList", ["list"]);+ const listItem = block("list-item", 20, "NodeListItem", ["li"]);+ const listParagraph = block("list-paragraph", 20);+ const listItemAttr = new TestElement("list-item-attr", 20, ["protyle-attr"]);+ const listAttr = new TestElement("list-attr", 20, ["protyle-attr"]);+ const leftAttr = new TestElement("left-attr", 20, ["protyle-attr"]);+ const resize = new TestElement("resize", 0, ["sb__resize"]);+ const right = block("right", 0, "NodeSuperBlock", ["sb"]);+ const third = block("third", 10);+ const fourth = block("fourth", 20);+ const rightAttr = new TestElement("right-attr", 20, ["protyle-attr"]);+ const outerAttr = new TestElement("outer-attr", 20, ["protyle-attr"]);+ list.append(listItem.append(listParagraph, listItemAttr), listAttr);+ editor.append(outer.append(left.append(first, list, leftAttr), resize,+ right.append(third, fourth, rightAttr), outerAttr));++ const expected = [asElement(first), asElement(list)];+ assert.deepEqual(getBlockRangeSelectElements(asElement(first), asElement(listParagraph), getBlock)+ .selectElements, expected);+ const upwardSelection = getBlockRangeSelectElements(asElement(listParagraph), asElement(first), getBlock);+ assert.deepEqual(upwardSelection.selectElements, expected);+ assert.equal(upwardSelection.toDown, false);+ });});diff --git a/app/src/protyle/util/blockRangeSelect.ts b/app/src/protyle/util/blockRangeSelect.tsindex da9f1e82d2..f973dd7e5e 100644--- a/app/src/protyle/util/blockRangeSelect.ts+++ b/app/src/protyle/util/blockRangeSelect.ts@@ -58,8 +58,8 @@ export const getBlockRangeSelectElements = (rangeStartElement: HTMLElement, rangif (!currentElement.classList.contains("sb__resize")) {selectElements.push(currentElement);}- // 到达实际选区终点后停止,避免经过属性节点继续提升到父容器。- if (currentElement === endElement) {+ // 当前选择单元包含选区终点时停止,避免经过属性节点继续提升到父容器。+ if (currentElement === endElement || currentElement.contains(endElement)) {break;}const parentElement = currentElement.parentElement;