mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
This commit is contained in:
parent
99e4614dc2
commit
5c90a6ffbe
3 changed files with 57 additions and 7 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue