浏览代码

fix(editor): exit editing mode and clear highlights when blocks are selected

Tienson Qin 5 年之前
父节点
当前提交
41c9bf0fd0
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      src/main/frontend/handler/editor.cljs

+ 9 - 2
src/main/frontend/handler/editor.cljs

@@ -1138,6 +1138,12 @@
       (dom/remove-class! block "noselect"))
     (state/clear-selection-blocks!)))
 
+(defn exit-editing-and-set-selected-blocks!
+  [blocks]
+  (util/clear-selection!)
+  (state/clear-edit!)
+  (state/set-selection-blocks! blocks))
+
 (defn select-all-blocks!
   []
   (when-let [current-input-id (state/get-edit-input-id)]
@@ -1146,7 +1152,7 @@
           blocks (dom/by-class blocks-container "ls-block")]
       (doseq [block blocks]
         (dom/add-class! block "selected noselect"))
-      (state/set-selection-blocks! blocks))))
+      (exit-editing-and-set-selected-blocks! blocks))))
 
 (defn- get-selected-blocks-with-children
   []
@@ -1295,7 +1301,7 @@
     (let [blocks (util/get-nodes-between-two-nodes start-block end-block "ls-block")]
       (doseq [block blocks]
         (dom/add-class! block "selected noselect"))
-      (state/set-selection-blocks! blocks))))
+      (exit-editing-and-set-selected-blocks! blocks))))
 
 (defn on-select-block
   [state e up?]
@@ -1330,6 +1336,7 @@
               nil)
             (do
               (util/clear-selection!)
+              (state/clear-edit!)
               (state/conj-selection-block! element up?))))))))
 
 (defn save-block-aux!