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: Restore cross-window block dragging https://github.com/siyuan-note/siyuan/issues/10096
Daniele96a887d3aa1
diff --git a/app/electron/main.js b/app/electron/main.jsindex 6b9b3dcf6f..dbe8b81e36 100644--- a/app/electron/main.js+++ b/app/electron/main.js@@ -141,6 +141,19 @@ const normalizeBlockDragPoint = (point) => {};};+const updateBlockDragCursorPoint = (dragSession, point) => {+ if (!point) {+ return;+ }+ // 跨 BrowserWindow 拖拽时以主进程获取的全局指针位置为准,避免渲染进程失焦后上报的 screen 坐标被窗口边界截断。+ const cursorPoint = screen.getCursorScreenPoint();+ dragSession.point = {+ ...point,+ screenX: cursorPoint.x,+ screenY: cursorPoint.y,+ };+};+const normalizeBlockDragPayload = (payload) => {if (!payload || typeof payload !== "object" || !Array.isArray(payload.items) ||!payload.items.every((item) => item && typeof item.type === "string" && typeof item.data === "string")) {@@ -3662,7 +3675,7 @@ app.whenReady().then(() => {}const point = normalizeBlockDragPoint(data.point);if (point) {- dragSession.point = point;+ updateBlockDragCursorPoint(dragSession, point);}if (data.payload !== undefined) {const payload = normalizeBlockDragPayload(data.payload);diff --git a/app/src/util/touchDragBridge.ts b/app/src/util/touchDragBridge.tsindex 31d48f4a55..e92caf68bf 100644--- a/app/src/util/touchDragBridge.ts+++ b/app/src/util/touchDragBridge.ts@@ -13,6 +13,7 @@ import {hasActiveTouchGesture,isDragRelaySource,restoreNativeDrag,+ shouldCancelPointerDragOnBlur,shouldRequireLongPress,shouldSuppressNativeContextMenu,suspendNativeDrag,@@ -1063,16 +1064,10 @@ export const initTouchDragBridge = () => {document.addEventListener("lostpointercapture", handleLostPointerCapture, {capture: true, passive: true});document.addEventListener("click", handleMouseClick, {capture: true, passive: false});window.addEventListener("blur", () => {- if (isInAndroid() && dragState?.inputType === "pointer") {+ if (dragState?.inputType === "pointer" &&+ shouldCancelPointerDragOnBlur(!!isInAndroid(), dragState.isDragging, !!dragState.relayId)) {completeBridgeDrag(undefined, true);- return;}- window.setTimeout(() => {- if (dragState?.inputType === "pointer" && !dragState.relayRemote &&- !dragState.pendingDropPoint) {- completeBridgeDrag(undefined, true);- }- }, Constants.TIMEOUT_MOUSE_DRAG_DELAY);});}diff --git a/app/src/util/touchDragBridgeCore.test.ts b/app/src/util/touchDragBridgeCore.test.tsindex 057d1710bc..a0a52b8124 100644--- a/app/src/util/touchDragBridgeCore.test.ts+++ b/app/src/util/touchDragBridgeCore.test.ts@@ -9,6 +9,7 @@ import {hasActiveTouchGesture,isDragRelaySource,restoreNativeDrag,+ shouldCancelPointerDragOnBlur,shouldRequireLongPress,shouldSuppressNativeContextMenu,suspendNativeDrag,@@ -137,6 +138,13 @@ describe("desktop mouse drag candidates", () => {assert.equal(shouldRequireLongPress(true, true, true), true);assert.equal(shouldRequireLongPress(true, false, false), true);});++ it("keeps an active desktop relay alive when its source window loses focus", () => {+ assert.equal(shouldCancelPointerDragOnBlur(false, true, true), false);+ assert.equal(shouldCancelPointerDragOnBlur(false, false, true), true);+ assert.equal(shouldCancelPointerDragOnBlur(false, true, false), true);+ assert.equal(shouldCancelPointerDragOnBlur(true, true, true), true);+ });});describe("synthetic drag wheel scrolling", () => {diff --git a/app/src/util/touchDragBridgeCore.ts b/app/src/util/touchDragBridgeCore.tsindex 2b83e9eb8a..cbb8bfa643 100644--- a/app/src/util/touchDragBridgeCore.ts+++ b/app/src/util/touchDragBridgeCore.ts@@ -34,6 +34,10 @@ export const shouldRequireLongPress = (isLongPressTarget: boolean, isMouse: boolreturn isLongPressTarget && (!isMouse || isAndroid);};+export const shouldCancelPointerDragOnBlur = (isAndroid: boolean, isDragging: boolean, hasRelay: boolean) => {+ return isAndroid || !isDragging || !hasRelay;+};+export const getWheelScrollDelta = (delta: number, deltaMode: number, lineSize: number, pageSize: number) => {if (deltaMode === 1) {return delta * lineSize;