Browse Source

:iphone: 键盘收起

Vanessa 2 years ago
parent
commit
2c0d2ed934
2 changed files with 8 additions and 2 deletions
  1. 1 0
      app/src/assets/scss/mobile.scss
  2. 7 2
      app/src/mobile/util/showKeyboardToolbar.ts

+ 1 - 0
app/src/assets/scss/mobile.scss

@@ -257,6 +257,7 @@
   background: var(--b3-theme-background);
   z-index: 221;
   display: flex;
+  border-top: 1px solid var(--b3-border-color);
 
   button {
     background: transparent;

+ 7 - 2
app/src/mobile/util/showKeyboardToolbar.ts

@@ -19,12 +19,17 @@ export const hideKeyboardToolbar = () => {
 
 export const initKeyboardToolbar = () => {
     const toolbarElement = document.getElementById("keyboardToolbar");
-    toolbarElement.addEventListener(getEventName(), (event) => {
+    toolbarElement.addEventListener("click", (event) => {
         const target = event.target as HTMLElement;
         const buttonElement = hasClosestByMatchTag(target, "BUTTON");
         if (!buttonElement || !window.siyuan.mobileEditor) {
             return;
         }
+        if (window.siyuan.mobileEditor.protyle.disabled) {
+            return;
+        }
+        event.preventDefault();
+        event.stopPropagation();
         const type = buttonElement.getAttribute("data-type");
         const protyle = window.siyuan.mobileEditor.protyle;
         if (type === "undo") {
@@ -75,8 +80,8 @@ export const initKeyboardToolbar = () => {
                 range.collapse(false);
                 range.insertNode(document.createTextNode(Constants.ZWSP));
                 range.collapse(false);
-                focusByRange(range);
             }
+            focusByRange(range);
             return;
         }