Skip to content

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

:iphone: fix https://github.com/siyuan-note/siyuan/issues/6405

Vanessa5b669b609105
diff --git a/app/src/layout/Tab.ts b/app/src/layout/Tab.ts
index 00e9403ba1..ef44fc4aec 100644
--- a/app/src/layout/Tab.ts
+++ b/app/src/layout/Tab.ts
@@ -8,6 +8,7 @@ import {escapeHtml} from "../util/escape";
import {unicode2Emoji} from "../emoji";
import {fetchPost} from "../util/fetch";
import {showTooltip} from "../dialog/tooltip";
+import {isTouchDevice} from "../util/functions";
export class Tab {
public parent: Wnd;
@@ -47,8 +48,8 @@ export class Tab {
let id = "";
if (this.model instanceof Editor && this.model.editor?.protyle?.block?.rootID) {
id = (this.model as Editor).editor.protyle.block.rootID;
- } else if (!this.model){
- const initData = JSON.parse(this.headElement.getAttribute("data-initdata")||"{}");
+ } else if (!this.model) {
+ const initData = JSON.parse(this.headElement.getAttribute("data-initdata") || "{}");
if (initData) {
id = initData.blockId;
}
@@ -65,6 +66,11 @@ export class Tab {
}
});
this.headElement.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
+ if (isTouchDevice()) {
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
window.getSelection().removeAllRanges();
const tabElement = hasClosestByTag(event.target, "LI");
if (tabElement) {
diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts
index 7e978ee493..b17861df7f 100644
--- a/app/src/layout/dock/Files.ts
+++ b/app/src/layout/dock/Files.ts
@@ -16,6 +16,7 @@ import {confirmDialog} from "../../dialog/confirmDialog";
import {updateHotkeyTip} from "../../protyle/util/compatibility";
import {openFileById} from "../../editor/util";
import {hasClosestByTag, hasTopClosestByTag} from "../../protyle/util/hasClosest";
+import {isTouchDevice} from "../../util/functions";
export class Files extends Model {
public element: HTMLElement;
@@ -268,6 +269,11 @@ export class Files extends Model {
// b3-list-item--focus 样式会遮挡拖拽排序的上下线条
let focusElement: HTMLElement;
this.element.addEventListener("dragstart", (event: DragEvent & { target: HTMLElement }) => {
+ if (isTouchDevice()) {
+ event.stopPropagation();
+ event.preventDefault();
+ return;
+ }
window.getSelection().removeAllRanges();
focusElement = this.element.querySelector(".b3-list-item--focus");
if (focusElement) {
diff --git a/app/src/util/functions.ts b/app/src/util/functions.ts
index 6f3f7da91e..6d036e183a 100644
--- a/app/src/util/functions.ts
+++ b/app/src/util/functions.ts
@@ -2,6 +2,10 @@ export const isMobile = () => {
return !document.getElementById("dockBottom");
};
+export const isTouchDevice = () => {
+ return ("ontouchstart" in window) || navigator.maxTouchPoints > 0;
+};
+
export const isArrayEqual = (arr1: string[], arr2: string[]) => {
return arr1.length === arr2.length && arr1.every((item) => arr2.includes(item));
};