1
0
Эх сурвалжийг харах

fix: editor lost focus on electron

Tienson Qin 2 жил өмнө
parent
commit
848ea4f3f7

+ 13 - 16
src/main/frontend/handler/editor.cljs

@@ -1331,7 +1331,6 @@
                               value (if (= (:block/uuid current-block) (:block/uuid block))
                                       (:block/content current-block)
                                       (and elem (gobj/get elem "value")))]
-                          (prn :debug :value value)
                           (when value
                             (cond
                               force?
@@ -2282,16 +2281,17 @@
         target (or original-block (:data parent-node))
         pos (state/get-edit-pos)
         block (:data node)]
-    (save-current-block!)
-    (when target
-      (ui-outliner-tx/transact!
-       {:outliner-op :move-blocks
-        :real-outliner-op :indent-outdent}
-       (outliner-core/move-blocks! (state/get-current-repo) (db/get-db false)
-                                   (block-handler/get-top-level-blocks [block])
-                                   target true))
-      (when original-block
-        (util/schedule #(edit-block! block pos nil))))))
+    (p/do!
+     (ui-outliner-tx/transact!
+      {:outliner-op :move-blocks
+       :real-outliner-op :indent-outdent}
+      (save-current-block!)
+      (when target
+        (outliner-core/move-blocks! (state/get-current-repo) (db/get-db false)
+                                    (block-handler/get-top-level-blocks [block])
+                                    target true)))
+     (when original-block
+       (util/schedule #(edit-block! block pos nil))))))
 
 (defn- last-top-level-child?
   [{:keys [id]} current-node]
@@ -2875,7 +2875,6 @@
 
 (defn indent-outdent
   [indent?]
-  (save-current-block!)
   (state/set-editor-op! :indent-outdent)
   (let [editor (state/get-input)
         pos (some-> editor cursor/pos)
@@ -2886,6 +2885,7 @@
        (ui-outliner-tx/transact!
         {:outliner-op :move-blocks
          :real-outliner-op :indent-outdent}
+        (save-current-block!)
         (outliner-core/indent-outdent-blocks! (state/get-current-repo)
                                               (db/get-db false)
                                               (block-handler/get-top-level-blocks [block])
@@ -2893,10 +2893,7 @@
                                               {:get-first-block-original block-handler/get-first-block-original
                                                :logical-outdenting? (state/logical-outdenting?)})))
 
-     (state/set-editor-op! :nil)
-
-     (when-let [input (state/get-input)]
-       (.focus input)))))
+     (state/set-editor-op! :nil))))
 
 (defn keydown-tab-handler
   [direction]

+ 0 - 1
src/main/frontend/handler/events.cljs

@@ -362,7 +362,6 @@
     (ui-handler/re-render-root!)))
 
 (defmethod handle :file/not-matched-from-disk [[_ path disk-content db-content]]
-  (state/clear-edit!)
   (when-let [repo (state/get-current-repo)]
     (when (and disk-content db-content
                (not= (util/trim-safe disk-content) (util/trim-safe db-content)))

+ 1 - 0
src/main/frontend/state.cljs

@@ -1267,6 +1267,7 @@ Similar to re-frame subscriptions"
 
 (defn clear-edit!
   []
+  (js/console.trace)
   (when-let [prev-ref @*editor-editing-ref]
     (reset! (get @(:editor/ref->editing? @state) prev-ref) false))
   (reset! *editor-editing-ref nil)