An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:zap: Preserve large table virtualization during pane resizing https://github.com/siyuan-note/siyuan/issues/19964
Danielcd1741bbd0a1
diff --git a/app/src/protyle/wysiwyg/tableVirtualization.test.ts b/app/src/protyle/wysiwyg/tableVirtualization.test.tsindex bc722dbaf6..45a65e97e7 100644--- a/app/src/protyle/wysiwyg/tableVirtualization.test.ts+++ b/app/src/protyle/wysiwyg/tableVirtualization.test.ts@@ -100,13 +100,19 @@ body {margin:0; --b3-theme-surface-lighter:#ddd; --b3-font-size-editor:16px; --bfor (const type of ["pointerdown", "keydown", "beforeinput", "copy", "cut", "paste", "contextmenu"]) {outside.dispatchEvent(new Event(type, {bubbles: true}));}+ outside.dispatchEvent(new PointerEvent("pointerdown", {bubbles: true, buttons: 1, pointerType: "mouse"}));for (const width of [600, 540, 460, 380, 640]) {+ f.editor.dispatchEvent(new PointerEvent("pointermove", {+ bubbles: true, buttons: 1, pointerType: "mouse", movementX: 10,+ }));+ tables.forEach(table => reduced(table, "external divider drag crosses the editor"));f.viewport.style.width = `${width}px`;f.editor.style.paddingLeft = `${(640 - width) / 10}px`;f.root.dispatchEvent(new Event("touchmove", {bubbles: true}));await tick();tables.forEach(table => reduced(table, "sidebar animation keeps all table windows"));}+ outside.dispatchEvent(new PointerEvent("pointerup", {bubbles: true, pointerType: "mouse"}));await new Promise(resolve => setTimeout(resolve, 250));await tick();check.equal(restores, 0, "outside interactions and viewport resizing do not materialize intrinsic-width tables");@@ -130,6 +136,26 @@ body {margin:0; --b3-theme-surface-lighter:#ddd; --b3-font-size-editor:16px; --boutside.remove();f.destroy();}+ {+ const f = fixture(600);+ await tick();+ const cell = f.table.querySelector("tbody td");+ cell.dispatchEvent(new PointerEvent("pointerdown", {bubbles: true, buttons: 1, pointerType: "mouse"}));+ reduced(f.table);+ f.editor.dispatchEvent(new PointerEvent("pointermove", {+ bubbles: true, buttons: 1, pointerType: "mouse", movementX: 10,+ }));+ rowsMatch(f.editor.innerHTML, 600);+ f.editor.dispatchEvent(new PointerEvent("pointercancel", {bubbles: true, pointerType: "mouse"}));+ f.root.dispatchEvent(new WheelEvent("wheel", {bubbles: true}));+ await tick();+ reduced(f.table, "cancelled editor drag can virtualize again");+ f.editor.dispatchEvent(new PointerEvent("pointermove", {+ bubbles: true, buttons: 1, pointerType: "mouse", movementX: 10,+ }));+ reduced(f.table, "cancelled editor drag does not affect a subsequent external drag");+ f.destroy();+ }for (const sizing of ["inline", "theme", "fallback"]) {const f = fixture(600, false, table => {if (sizing !== "theme") {diff --git a/app/src/protyle/wysiwyg/tableVirtualization.ts b/app/src/protyle/wysiwyg/tableVirtualization.tsindex 2e2e053e8b..ffe3f61806 100644--- a/app/src/protyle/wysiwyg/tableVirtualization.ts+++ b/app/src/protyle/wysiwyg/tableVirtualization.ts@@ -152,7 +152,8 @@ export class LargeTableVirtualizer {window.addEventListener("pointerup", () => { this.interacting = false; this.dragTable = undefined; }, {capture: true, signal});window.addEventListener("pointercancel", () => { this.interacting = false; this.dragTable = undefined; }, {capture: true, signal});root.addEventListener("pointermove", event => {- if (event.buttons && (event.movementX || event.movementY)) {+ // 仅处理本编辑器内开始的拖选,外部分隔条拖动经过正文时保留屏外行缓存。+ if (this.interacting && event.buttons && (event.movementX || event.movementY)) {if (!getTableCellRichEventTarget(event) && !this.dragTable?.contains(event.target as Node)) {this.dragTable = undefined;this.restore();