Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17628

Vanessae8fe1df87861
diff --git a/app/src/dialog/index.ts b/app/src/dialog/index.ts
index c8c9c6aa7b..f2aab05ceb 100644
--- a/app/src/dialog/index.ts
+++ b/app/src/dialog/index.ts
@@ -1,7 +1,5 @@
import {genUUID} from "../util/genID";
-/// #if !MOBILE
import {moveResize} from "./moveResize";
-/// #endif
import {isMobile} from "../util/functions";
import {isNotCtrl} from "../protyle/util/compatibility";
import {Protyle} from "../protyle";
@@ -82,9 +80,7 @@ left:${left || "auto"};top:${top || "auto"}">
this.element.classList.add("b3-dialog--open");
}, Constants.TIMEOUT_OPENDIALOG);
}
- /// #if !MOBILE
moveResize(this.element.querySelector(".b3-dialog__container"), options.resizeCallback);
- /// #endif
}
public resize() {
diff --git a/app/src/layout/dock/util.ts b/app/src/layout/dock/util.ts
index 2a09df4cc7..88c6f31ed9 100644
--- a/app/src/layout/dock/util.ts
+++ b/app/src/layout/dock/util.ts
@@ -2,7 +2,7 @@ import {getAllModels} from "../getAll";
import {Tab} from "../Tab";
import {Graph} from "./Graph";
import {Outline} from "./Outline";
-import {fixWndFlex1, getInstanceById, getWndByLayout, saveLayout} from "../util";
+import {fixWndFlex1, getInstanceById, getWndByLayout} from "../util";
import {getDockByType, resizeTabs} from "../tabUtil";
import {Backlink} from "./Backlink";
import {App} from "../../index";
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index fa7cd891a7..f715b74c7a 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -38,6 +38,7 @@ import {processIOSPurchaseResponse} from "../util/iOSPurchase";
import {nbsp2space} from "../protyle/util/normalizeText";
import {callMobileAppShowKeyboard, canInput, setWebViewFocusable} from "./util/mobileAppUtil";
import {hideAllElements} from "../protyle/ui/hideElements";
+import {initTouchDragBridge} from "../util/touchDragBridge";
class App {
public plugins: import("../plugin").Plugin[] = [];
@@ -203,6 +204,7 @@ class App {
}
}
});
+ initTouchDragBridge();
});
}
}
diff --git a/app/src/mobile/menu/search.ts b/app/src/mobile/menu/search.ts
index ab9d0aec93..7ad76d0928 100644
--- a/app/src/mobile/menu/search.ts
+++ b/app/src/mobile/menu/search.ts
@@ -8,7 +8,7 @@ import {openModel} from "./model";
import {getDisplayName, getNotebookIcon, getNotebookName, movePathTo, pathPosix} from "../../util/pathName";
import {getKeyByLiElement, initCriteriaMenu, moreMenu} from "../../search/menu";
import {setStorageVal} from "../../protyle/util/compatibility";
-import {escapeLessThans, escapeHtml, escapeAttr} from "../../util/escape";
+import {escapeHtml} from "../../util/escape";
import {unicode2Emoji} from "../../emoji";
import {newFileByName} from "../../util/newFile";
import {showMessage} from "../../dialog/message";
diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts
index b0148fcbd4..d7f9e76b36 100644
--- a/app/src/mobile/util/touch.ts
+++ b/app/src/mobile/util/touch.ts
@@ -163,12 +163,17 @@ export const handleTouchEnd = (event: TouchEvent) => {
};
export const handleTouchStart = (event: TouchEvent) => {
- if (0 < event.touches.length && ((event.touches[0].target as HTMLElement).tagName === "VIDEO" || (event.touches[0].target as HTMLElement).tagName === "AUDIO")) {
+ if (0 < event.touches.length && ((event.touches[0].target as HTMLElement).tagName === "VIDEO" ||
+ (event.touches[0].target as HTMLElement).tagName === "AUDIO")) {
// https://github.com/siyuan-note/siyuan/issues/14569
activeBlur();
return;
}
-
+ // 存在其他拖拽元素时
+ const otherTouchElement = hasClosestByClassName(event.touches[0].target as Element, "b3-chip");
+ if (otherTouchElement && otherTouchElement.parentElement.classList.contains("b3-chips__doctag")) {
+ return;
+ }
if (getSelection().rangeCount > 0 && hasClosestBlock(event.target as Element)) {
const editor = getCurrentEditor();
if (editor && !editor.protyle.disabled && event.touches[0].clientY > window.innerHeight / 2 &&
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index 5113635f7e..96e8bb8395 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -540,7 +540,7 @@ export class Background {
}
} else if (isCloseBtn) {
// 如果没拖拽且点在关闭按钮上
- target.closest(".b3-chip__close").dispatchEvent(new MouseEvent('click', {bubbles: true}));
+ target.closest(".b3-chip__close").dispatchEvent(new MouseEvent("click", {bubbles: true}));
}
};
diff --git a/app/src/util/touchDragBridge.ts b/app/src/util/touchDragBridge.ts
index 8405412543..5e6eb07261 100644
--- a/app/src/util/touchDragBridge.ts
+++ b/app/src/util/touchDragBridge.ts
@@ -18,46 +18,8 @@ interface TouchDragState {
let dragState: TouchDragState | null = null;
let lastDragOverElement: Element | null = null;
-// ── Manual mousedown bridge ──────────────────────────────────────────
-
let manualTouchActive = false;
-const dispatchSyntheticMouse = (type: string, clientX: number, clientY: number, target: Element) => {
- const mouseEvent = new MouseEvent(type, {
- bubbles: true,
- cancelable: true,
- clientX,
- clientY,
- button: 0,
- view: window,
- });
- target.dispatchEvent(mouseEvent);
-};
-
-const callDocumentMouseMove = (clientX: number, clientY: number) => {
- if (typeof document.onmousemove !== "function") return;
- const target = document.elementFromPoint(clientX, clientY);
- if (!target) return;
- const fakeEvent = new MouseEvent("mousemove", {
- clientX,
- clientY,
- cancelable: true,
- bubbles: true,
- });
- target.dispatchEvent(fakeEvent);
-};
-
-const callDocumentMouseUp = (clientX: number, clientY: number) => {
- if (typeof document.onmouseup !== "function") return;
- const target = document.elementFromPoint(clientX, clientY) || document.body;
- const fakeEvent = new MouseEvent("mouseup", {
- clientX,
- clientY,
- bubbles: true,
- });
- target.dispatchEvent(fakeEvent);
-};
-
const handleManualTouchStart = (e: TouchEvent) => {
if (dragState) return;
if (e.touches.length !== 1) return;
@@ -81,7 +43,15 @@ const handleManualTouchStart = (e: TouchEvent) => {
!target.closest(".b3-chip")) return;
const touch = e.touches[0];
- dispatchSyntheticMouse("mousedown", touch.clientX, touch.clientY, target);
+ const mouseEvent = new MouseEvent("mousedown", {
+ bubbles: true,
+ cancelable: true,
+ clientX:touch.clientX,
+ clientY:touch.clientY,
+ button: 0,
+ view: window,
+ });
+ target.dispatchEvent(mouseEvent);
manualTouchActive = true;
};
@@ -90,9 +60,14 @@ const handleManualTouchMove = (e: TouchEvent) => {
if (!manualTouchActive) return;
const touch = e.touches[0];
- if (document.onmousemove) {
+ if (document.onmousemove && typeof document.onmousemove === "function" && (touch.target as Element)?.nodeType === 1) {
e.preventDefault();
- callDocumentMouseMove(touch.clientX, touch.clientY);
+ touch.target.dispatchEvent( new MouseEvent("mousemove", {
+ clientX: touch.clientX,
+ clientY: touch.clientY,
+ cancelable: true,
+ bubbles: true,
+ }));
}
};
@@ -101,13 +76,17 @@ const handleManualTouchEnd = (e: TouchEvent) => {
if (!manualTouchActive) return;
if (document.onmouseup) {
- callDocumentMouseUp(e.changedTouches[0].clientX, e.changedTouches[0].clientY);
+ if (typeof document.onmouseup !== "function") return;
+ const target = e.changedTouches[0].target || document.body;
+ target.dispatchEvent(new MouseEvent("mouseup", {
+ clientX:e.changedTouches[0].clientX,
+ clientY:e.changedTouches[0].clientY,
+ bubbles: true,
+ }));
}
manualTouchActive = false;
};
-// ── Native Drag API bridge ───────────────────────────────────────────
-
const getDraggableAncestor = (el: HTMLElement): HTMLElement | null => {
let current: HTMLElement | null = el;
while (current) {
@@ -283,7 +262,7 @@ const cleanupDrag = () => {
lastDragOverElement = null;
};
-const handleTouchStart = (e: TouchEvent) => {
+const handleDragStart = (e: TouchEvent) => {
if (e.touches.length !== 1) return;
const target = e.target as HTMLElement;
@@ -306,7 +285,7 @@ const handleTouchStart = (e: TouchEvent) => {
};
};
-const handleTouchMove = (e: TouchEvent) => {
+const handleDragMove = (e: TouchEvent) => {
if (!dragState) return;
const touch = e.touches[0];
@@ -340,7 +319,7 @@ const handleTouchMove = (e: TouchEvent) => {
continueTouchDrag(touch);
};
-const handleTouchEnd = (e: TouchEvent) => {
+const handleDragEnd = (e: TouchEvent) => {
if (!dragState) return;
if (dragState.isDragging) {
@@ -351,7 +330,7 @@ const handleTouchEnd = (e: TouchEvent) => {
cleanupDrag();
};
-const handleTouchCancel = () => {
+const handleCancel = () => {
if (dragState?.isDragging) {
cleanupDrag();
}
@@ -362,13 +341,13 @@ const handleTouchCancel = () => {
export const initTouchDragBridge = () => {
// Native Drag API bridge (for [draggable="true"] elements)
- document.addEventListener("touchstart", handleTouchStart, {passive: false});
- document.addEventListener("touchmove", handleTouchMove, {passive: false});
- document.addEventListener("touchend", handleTouchEnd);
- document.addEventListener("touchcancel", handleTouchCancel);
-
+ document.addEventListener("touchstart", handleDragStart, {passive: false});
+ document.addEventListener("touchmove", handleDragMove, {passive: false});
+ document.addEventListener("touchend", handleDragEnd);
// Manual mousedown bridge (for dock / dialog / outline)
document.addEventListener("touchstart", handleManualTouchStart, {passive: false});
document.addEventListener("touchmove", handleManualTouchMove, {passive: false});
document.addEventListener("touchend", handleManualTouchEnd);
+
+ document.addEventListener("touchcancel", handleCancel);
};