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/13436

Vanessa76e7ecb19c09
diff --git a/app/src/boot/globalEvent/touch.ts b/app/src/boot/globalEvent/touch.ts
index b00b96bd12..a6ddf60885 100644
--- a/app/src/boot/globalEvent/touch.ts
+++ b/app/src/boot/globalEvent/touch.ts
@@ -18,37 +18,8 @@ import {Editor} from "../../editor";
import {hideTooltip} from "../../dialog/tooltip";
export const globalTouchStart = (event: TouchEvent) => {
- // 文档背景位置调整
const target = event.target as HTMLElement;
const backgroundElement = hasClosestByClassName(target, "protyle-background");
- if (backgroundElement && target.tagName === "IMG" && backgroundElement.firstElementChild.querySelector(".protyle-icons").classList.contains("fn__none")) {
- const contentElement = hasClosestByClassName(target, "protyle-content", true);
- if (!contentElement) {
- return false;
- }
- contentElement.style.overflow = "hidden";
- const y = event.touches[0].clientY;
- const height = (target as HTMLImageElement).naturalHeight * target.clientWidth / (target as HTMLImageElement).naturalWidth - target.clientHeight;
- let originalPositionY = parseFloat(target.style.objectPosition.substring(7)) || 50;
- if (target.style.objectPosition.endsWith("px")) {
- originalPositionY = -parseInt(target.style.objectPosition.substring(7)) / height * 100;
- }
-
- const documentSelf = document;
- documentSelf.ontouchmove = (moveEvent) => {
- target.style.objectPosition = `center ${((y - moveEvent.touches[0].clientY) / height * 100 + originalPositionY).toFixed(2)}%`;
- };
- documentSelf.ontouchend = () => {
- contentElement.style.overflow = "";
- documentSelf.ontouchmove = null;
- documentSelf.ontouchstart = null;
- documentSelf.ondragstart = null;
- documentSelf.onselectstart = null;
- documentSelf.onselect = null;
- };
- event.stopImmediatePropagation();
- return true;
- }
if (backgroundElement) {
if (backgroundElement.classList.contains("protyle-background--enable")) {
backgroundElement.classList.add("protyle-background--mobileshow");
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index cbff2bef43..2b2b54c19d 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -512,8 +512,8 @@ export class Background {
};
const onMouseUp = (upEvent: MouseEvent) => {
- window.removeEventListener("mousemove", onMouseMove);
- window.removeEventListener("mouseup", onMouseUp, true);
+ document.onmousemove = null;
+ document.onmouseup = null;
document.body.style.cursor = "";
if (isDragging) {
@@ -544,9 +544,8 @@ export class Background {
}
};
- // 使用捕获阶段监听 mouseup,确保能第一时间拦截拖拽后的 click
- window.addEventListener("mousemove", onMouseMove);
- window.addEventListener("mouseup", onMouseUp, true);
+ document.onmousemove = (e) => onMouseMove(e as MouseEvent);
+ document.onmouseup = (e) => onMouseUp(e as MouseEvent);
});
}
diff --git a/app/src/util/touchDragBridge.ts b/app/src/util/touchDragBridge.ts
index 657778c613..8405412543 100644
--- a/app/src/util/touchDragBridge.ts
+++ b/app/src/util/touchDragBridge.ts
@@ -76,7 +76,9 @@ const handleManualTouchStart = (e: TouchEvent) => {
!target.closest(".av__widthdrag") &&
!target.closest(".av__drag-fill") &&
!target.closest(".protyle-action__drag") &&
- !target.closest(".table__resize")) return;
+ !target.closest(".table__resize") &&
+ !target.closest(".protyle-background__img") &&
+ !target.closest(".b3-chip")) return;
const touch = e.touches[0];
dispatchSyntheticMouse("mousedown", touch.clientX, touch.clientY, target);