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 horizontal jitter after moving documents https://github.com/siyuan-note/siyuan/issues/19577
Daniel4c76e3941b70
diff --git a/app/src/assets/scss/component/_list.scss b/app/src/assets/scss/component/_list.scssindex 04bedad9c2..1c445ce2d2 100644--- a/app/src/assets/scss/component/_list.scss+++ b/app/src/assets/scss/component/_list.scss@@ -257,7 +257,7 @@height: 22px;padding: 0 2px;color: var(--b3-theme-on-surface-light);- transition: var(--b3-transition);+ transition: color .2s cubic-bezier(0, 0, .2, 1), background-color .2s cubic-bezier(0, 0, .2, 1);border-radius: var(--b3-border-radius);&--hl {diff --git a/app/src/mobile/dock/MobileFiles.ts b/app/src/mobile/dock/MobileFiles.tsindex 031723017d..c4605bd1ec 100644--- a/app/src/mobile/dock/MobileFiles.ts+++ b/app/src/mobile/dock/MobileFiles.ts@@ -570,7 +570,7 @@ export class MobileFiles extends Model {selectFileElements.forEach(item => {const fromPath = item.getAttribute("data-path");const newPath = pathPosix().join(toDir, item.getAttribute("data-node-id") + ".sy");- updateMovedSubtree(item, getFileTreeChildList(item), fromPath, newPath);+ updateMovedSubtree(item, getFileTreeChildList(item), fromPath, newPath, 20);});hasMove = true;}@@ -1051,7 +1051,7 @@ export class MobileFiles extends Model {if (sourceElement) {childListElement = getFileTreeChildList(sourceElement);collectExpandedDocIDs(sourceElement, childListElement, expandedDocIDs);- updateMovedSubtree(sourceElement, childListElement, move.fromPath, move.newPath);+ updateMovedSubtree(sourceElement, childListElement, move.fromPath, move.newPath, 20);}if (sourceElement && !sourceAtTarget) {const sourceListElement = sourceElement.parentElement;diff --git a/app/src/util/fileTreeMove.test.ts b/app/src/util/fileTreeMove.test.tsindex f8372466f2..ece6ba3f5b 100644--- a/app/src/util/fileTreeMove.test.ts+++ b/app/src/util/fileTreeMove.test.ts@@ -256,12 +256,15 @@ describe("updateMovedSubtree", () => {assert.equal(root.element.dataset.path, move.newPath);assert.equal(child.element.dataset.path, "/target/current/child.sy");assert.equal(grandchild.element.dataset.path, "/target/current/child/grandchild.sy");- assert.equal(root.properties.get("--file-toggle-width"), "60px");- assert.equal(child.properties.get("--file-toggle-width"), "80px");- assert.equal(grandchild.properties.get("--file-toggle-width"), "100px");- assert.equal(root.toggleElement.style.paddingLeft, "40px");- assert.equal(child.toggleElement.style.paddingLeft, "60px");- assert.equal(grandchild.toggleElement.style.paddingLeft, "80px");+ assert.equal(root.properties.get("--file-toggle-width"), "54px");+ assert.equal(child.properties.get("--file-toggle-width"), "72px");+ assert.equal(grandchild.properties.get("--file-toggle-width"), "90px");+ assert.equal(root.properties.get("--file-action-offset"), "56px");+ assert.equal(child.properties.get("--file-action-offset"), "74px");+ assert.equal(grandchild.properties.get("--file-action-offset"), "92px");+ assert.equal(root.toggleElement.style.paddingLeft, "36px");+ assert.equal(child.toggleElement.style.paddingLeft, "54px");+ assert.equal(grandchild.toggleElement.style.paddingLeft, "72px");});it("is idempotent when the local move and WebSocket event both update the subtree", () => {@@ -278,8 +281,19 @@ describe("updateMovedSubtree", () => {assert.equal(root.element.dataset.path, move.newPath);assert.equal(child.element.dataset.path, "/target/current/child.sy");- assert.equal(root.properties.get("--file-toggle-width"), "60px");- assert.equal(child.properties.get("--file-toggle-width"), "80px");+ assert.equal(root.properties.get("--file-toggle-width"), "54px");+ assert.equal(child.properties.get("--file-toggle-width"), "72px");+ });++ it("preserves mobile indentation when moving a subtree to the notebook root", () => {+ const root = createFileTreeItem(move.fromPath);+ const child = createFileTreeItem("/parent/current/child.sy");+ updateMovedSubtree(root.element, createFileTreeList([child.element]), move.fromPath, "/current.sy", 20);+ assert.equal(root.toggleElement.style.paddingLeft, "20px");+ assert.equal(child.toggleElement.style.paddingLeft, "40px");+ assert.equal(root.properties.get("--file-toggle-width"), "40px");+ assert.equal(child.properties.get("--file-toggle-width"), "60px");+ assert.equal(child.element.dataset.path, "/current/child.sy");});});diff --git a/app/src/util/fileTreeMove.ts b/app/src/util/fileTreeMove.tsindex 1d94a354b7..f585669fe7 100644--- a/app/src/util/fileTreeMove.ts+++ b/app/src/util/fileTreeMove.ts@@ -171,10 +171,11 @@ export const remapMovedPath = (currentPath: string, fromPath: string, newPath: sreturn newPrefix + currentPath.slice(fromPrefix.length);};-const updateMovedItemPath = (item: HTMLElement, newPath: string) => {+const updateMovedItemPath = (item: HTMLElement, newPath: string, indent: number) => {item.dataset.path = newPath;- const paddingLeft = (newPath.split("/").length - 1) * 20;- item.style.setProperty("--file-toggle-width", `${paddingLeft + 20}px`);+ const paddingLeft = (newPath.split("/").length - 1) * indent;+ item.style.setProperty("--file-toggle-width", `${paddingLeft + indent}px`);+ item.style.setProperty("--file-action-offset", `${paddingLeft + 20}px`);const toggleElement = item.querySelector<HTMLElement>(":scope > .b3-list-item__toggle");if (toggleElement) {toggleElement.style.paddingLeft = `${paddingLeft}px`;@@ -185,10 +186,11 @@ export const updateMovedSubtree = (liElement: HTMLElement,childListElement: HTMLElement | undefined,fromPath: string,- newPath: string+ newPath: string,+ indent = 18) => {- updateMovedItemPath(liElement, newPath);+ updateMovedItemPath(liElement, newPath, indent);childListElement?.querySelectorAll<HTMLElement>("li[data-path]").forEach((item) => {- updateMovedItemPath(item, remapMovedPath(item.dataset.path, fromPath, newPath));+ updateMovedItemPath(item, remapMovedPath(item.dataset.path, fromPath, newPath), indent);});};