diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts index e42499e5f..d45e1588d 100644 --- a/app/src/mobile/util/touch.ts +++ b/app/src/mobile/util/touch.ts @@ -1,4 +1,9 @@ -import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByClassName,} from "../../protyle/util/hasClosest"; +import { + hasClosestBlock, + hasClosestByAttribute, + hasClosestByClassName, + hasTopClosestByClassName, isInEmbedBlock, +} from "../../protyle/util/hasClosest"; import {closeModel, closePanel} from "./closePanel"; import {popMenu} from "../menu"; import {activeBlur} from "./keyboardToolbar"; @@ -33,6 +38,21 @@ export const handleTouchEnd = (event: TouchEvent, app: App) => { event.preventDefault(); return; } + if (typeof yDiff === "undefined" && window.siyuan.mobile.editor.protyle.options.render.gutter) { + const nodeElement = hasClosestBlock(target); + if (nodeElement) { + if (nodeElement && (nodeElement.classList.contains("list") || nodeElement.classList.contains("li"))) { + // 光标在列表下部应显示右侧的元素,而不是列表本身。放在 windowEvent 中的 mousemove 下处理 + return; + } + const embedElement = isInEmbedBlock(nodeElement); + if (embedElement) { + window.siyuan.mobile.editor.protyle.gutter.render(window.siyuan.mobile.editor.protyle, embedElement); + return; + } + window.siyuan.mobile.editor.protyle.gutter.render(window.siyuan.mobile.editor.protyle, nodeElement, target); + } + } isFirstMove = true; if (!clientY || typeof yDiff === "undefined" || target.tagName === "AUDIO" || diff --git a/app/src/protyle/ui/hideElements.ts b/app/src/protyle/ui/hideElements.ts index 69514edec..e22c0476d 100644 --- a/app/src/protyle/ui/hideElements.ts +++ b/app/src/protyle/ui/hideElements.ts @@ -1,4 +1,5 @@ import {getAllEditor} from "../../layout/getAll"; +import {isIPhone} from "../util/compatibility"; // "gutter", "toolbar", "select", "hint", "util", "dialog", "gutterOnly" export const hideElements = (panels: string[], protyle?: IProtyle, focusHide = false) => { @@ -25,7 +26,9 @@ export const hideElements = (panels: string[], protyle?: IProtyle, focusHide = f } // 不能 remove("protyle-wysiwyg--hl") 否则打开页签的时候 "cb-get-hl" 高亮会被移除 if (protyle.gutter && panels.includes("gutterOnly")) { - protyle.gutter.element.classList.add("fn__none"); + if (!isIPhone()) { + protyle.gutter.element.classList.add("fn__none"); + } protyle.gutter.element.innerHTML = ""; } if (protyle.toolbar && panels.includes("toolbar")) { diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts index 1ab9fbe9e..6cbe24116 100644 --- a/app/src/protyle/ui/initUI.ts +++ b/app/src/protyle/ui/initUI.ts @@ -182,8 +182,8 @@ export const initUI = (protyle: IProtyle) => { } }); let overAttr = false; - const isTouch = isTouchDevice(); - protyle.element.addEventListener(isTouch ? "touchend" : "mouseover", (event: KeyboardEvent & { + /// #if !MOBILE + protyle.element.addEventListener("mouseover", (event: KeyboardEvent & { target: HTMLElement }) => { // attr @@ -221,7 +221,7 @@ export const initUI = (protyle: IProtyle) => { // gutter const buttonElement = hasClosestByTag(event.target, "BUTTON"); - if (!isTouch && buttonElement && buttonElement.parentElement.classList.contains("protyle-gutters")) { + if (buttonElement && buttonElement.parentElement.classList.contains("protyle-gutters")) { const type = buttonElement.getAttribute("data-type"); if (type === "fold" || type === "NodeAttributeViewRow") { Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl, .av__row--hl")).forEach(item => { @@ -254,7 +254,6 @@ export const initUI = (protyle: IProtyle) => { } // 面包屑 - /// #if !MOBILE if (protyle.selectElement.classList.contains("fn__none")) { const svgElement = hasClosestByAttribute(event.target, "data-node-id", null); if (svgElement && svgElement.parentElement.classList.contains("protyle-breadcrumb__bar")) { @@ -267,8 +266,8 @@ export const initUI = (protyle: IProtyle) => { } } } - /// #endif }); + /// #endif }; export const addLoading = (protyle: IProtyle, msg?: string) => {