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

Vanessa5c90a6ffbee8
diff --git a/app/src/assets/scss/business/_layout.scss b/app/src/assets/scss/business/_layout.scss
index 9c43e21e7c..8a84369974 100644
--- a/app/src/assets/scss/business/_layout.scss
+++ b/app/src/assets/scss/business/_layout.scss
@@ -343,6 +343,7 @@
user-select: none;
background-color: var(--b3-theme-surface);
box-sizing: border-box;
+ -webkit-user-select: none;
&:hover .dock__item--pin {
opacity: 1;
diff --git a/app/src/boot/globalEvent/event.ts b/app/src/boot/globalEvent/event.ts
index e49ee4a31a..cec97c111b 100644
--- a/app/src/boot/globalEvent/event.ts
+++ b/app/src/boot/globalEvent/event.ts
@@ -6,6 +6,14 @@ import {windowKeyDown} from "./keydown";
import {globalClick} from "./click";
import {goBack, goForward} from "../../util/backForward";
import {Constants} from "../../constants";
+import {isIPad} from "../../protyle/util/compatibility";
+import {globalTouchEnd} from "./touch";
+import {initDockMenu} from "../../menus/dock";
+import {hasClosestByAttribute, hasClosestByClassName} from "../../protyle/util/hasClosest";
+import {initTabMenu} from "../../menus/tab";
+import {getInstanceById} from "../../layout/util";
+import {Tab} from "../../layout/Tab";
+import {hideTooltip} from "../../dialog/tooltip";
export const initWindowEvent = (app: App) => {
document.body.addEventListener("mouseleave", () => {
@@ -58,4 +66,44 @@ export const initWindowEvent = (app: App) => {
window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
globalClick(event);
});
+
+ if (isIPad()) {
+ let time = 0;
+ document.addEventListener("touchstart", () => {
+ time = new Date().getTime();
+ }, false);
+ document.addEventListener("touchend", (event) => {
+ if (globalTouchEnd(event, undefined, time, app)) {
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ return;
+ }
+ if (new Date().getTime() - time <= 900) {
+ return;
+ }
+ const target = event.target as HTMLElement;
+ // dock right menu
+ const dockElement = hasClosestByClassName(target, "dock__item");
+ if (dockElement && dockElement.getAttribute("data-type")) {
+ const dockRect = dockElement.getBoundingClientRect()
+ initDockMenu(dockElement).popup({x: dockRect.right, y: dockRect.bottom});
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ return;
+ }
+
+ // tab right menu
+ const tabElement = hasClosestByAttribute(target, "data-type", "tab-header");
+ if (tabElement) {
+ const tabRect = tabElement.getBoundingClientRect()
+ initTabMenu(app, (getInstanceById(tabElement.getAttribute("data-id")) as Tab)).popup({
+ x: tabRect.left, y: tabRect.bottom
+ });
+ hideTooltip()
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ return;
+ }
+ }, false);
+ }
};
diff --git a/app/src/boot/globalEvent/touch.ts b/app/src/boot/globalEvent/touch.ts
index 936d9de3a0..9681cafad3 100644
--- a/app/src/boot/globalEvent/touch.ts
+++ b/app/src/boot/globalEvent/touch.ts
@@ -12,6 +12,7 @@ import {hideTooltip} from "../../dialog/tooltip";
export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, app: App) => {
const target = event.target as HTMLElement;
+ const isIPadBoolean = isIPad();
if (typeof yDiff === "undefined" && new Date().getTime() - time > 900) {
// ios 长按
// 文档树
@@ -19,7 +20,7 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, a
if (fileItemElement) {
if (!window.siyuan.config.readonly && fileItemElement.dataset.type === "navigation-root") {
const menu = initNavigationMenu(app, fileItemElement);
- if (isIPad()) {
+ if (isIPadBoolean) {
const rect = fileItemElement.getBoundingClientRect()
menu.popup({x: rect.right, y: rect.bottom, h: rect.height})
hideTooltip()
@@ -30,7 +31,7 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, a
const rootElement = hasTopClosestByTag(fileItemElement, "UL");
if (rootElement) {
const menu = initFileMenu(app, rootElement.dataset.url, fileItemElement.dataset.path, fileItemElement);
- if (isIPad()) {
+ if (isIPadBoolean) {
const rect = fileItemElement.getBoundingClientRect()
menu.popup({x: rect.right, y: rect.bottom, h: rect.height})
hideTooltip()
@@ -44,11 +45,7 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, a
// 内元素弹出菜单
if (target.tagName === "SPAN" && !hasClosestByAttribute(target, "data-type", "NodeBlockQueryEmbed")) {
let editor: Protyle
- if (isIPhone()) {
- if (hasClosestByClassName(target, "protyle-wysiwyg", true)) {
- editor = getCurrentEditor();
- }
- } else {
+ if (isIPadBoolean) {
const tabContainerElement = hasClosestByClassName(target, "protyle", true)
if (tabContainerElement) {
const tab = getInstanceById(tabContainerElement.dataset.id);
@@ -56,6 +53,10 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, a
editor = tab.model.editor
}
}
+ } else {
+ if (hasClosestByClassName(target, "protyle-wysiwyg", true)) {
+ editor = getCurrentEditor();
+ }
}
if (!editor) {
return false;