Pārlūkot izejas kodu

:lipstick: fix https://github.com/siyuan-note/siyuan/issues/5799

Vanessa 2 gadi atpakaļ
vecāks
revīzija
e02c071caa

+ 8 - 1
app/src/protyle/gutter/index.ts

@@ -26,8 +26,11 @@ import {isMobile} from "../../util/functions";
 import {confirmDialog} from "../../dialog/confirmDialog";
 import {enableProtyle} from "../util/onGet";
 import {countBlockWord} from "../../layout/status";
-import {Constants} from "../../constants";
+/// #if !MOBILE
 import {openFileById} from "../../editor/util";
+/// #endif
+import {Constants} from "../../constants";
+import {openMobileFileById} from "../../mobile/editor";
 
 export class Gutter {
     public element: HTMLElement;
@@ -1184,10 +1187,14 @@ export class Gutter {
                 if (!protyle.block.showAll) {
                     const ids = protyle.path.split("/");
                     if (ids.length > 2) {
+                        /// #if MOBILE
+                        openMobileFileById(ids[ids.length - 2],[Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
+                        /// #else
                         openFileById({
                             id: ids[ids.length - 2],
                             action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
                         });
+                        /// #endif
                     }
                 } else {
                     zoomOut(protyle, protyle.block.parent2ID, id);

+ 5 - 1
app/src/protyle/toolbar/index.ts

@@ -661,7 +661,7 @@ export class Toolbar {
             pinData.styleH = textElement.style.height;
             pinData.styleW = textElement.style.width;
         } else {
-            this.subElement.style.width = "";
+            this.subElement.style.width = isMobile() ? "100vw" : "";
             this.subElement.style.padding = "0";
         }
         this.subElement.innerHTML = `<div ${(isPin && this.subElement.firstElementChild.getAttribute("data-drag") === "true") ? 'data-drag="true"' : ""} class="block__popover--move"><div class="block__icons block__icons--border fn__flex">
@@ -686,6 +686,10 @@ export class Toolbar {
 <textarea spellcheck="false" class="b3-text-field b3-text-field--text fn__block" placeholder="${placeholder}" style="width:${isMobile() ? "80vw" : Math.max(480, renderElement.clientWidth * 0.7) + "px"};max-height:50vh"></textarea></div>`;
         const autoHeight = () => {
             textElement.style.height = textElement.scrollHeight + "px";
+            if (isMobile()) {
+                setPosition(this.subElement, 0, 0);
+                return;
+            }
             if (this.subElement.firstElementChild.getAttribute("data-drag") === "true") {
                 if (textElement.getBoundingClientRect().bottom > window.innerHeight) {
                     this.subElement.style.top = window.innerHeight - this.subElement.clientHeight + "px";

+ 5 - 0
app/src/protyle/wysiwyg/keydown.ts

@@ -64,6 +64,7 @@ import * as dayjs from "dayjs";
 import {highlightRender} from "../markdown/highlightRender";
 import {countBlockWord} from "../../layout/status";
 import {insertHTML} from "../util/insertHTML";
+import {openMobileFileById} from "../../mobile/editor";
 
 export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
     editorElement.addEventListener("keydown", async (event: KeyboardEvent & { target: HTMLElement }) => {
@@ -411,10 +412,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
             if (!protyle.block.showAll) {
                 const ids = protyle.path.split("/");
                 if (ids.length > 2) {
+                    /// #if MOBILE
+                    openMobileFileById(ids[ids.length - 2],[Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]);
+                    /// #else
                     openFileById({
                         id: ids[ids.length - 2],
                         action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
                     });
+                    /// #endif
                 }
             } else {
                 zoomOut(protyle, protyle.block.parent2ID, nodeElement.getAttribute("data-node-id"));