Просмотр исходного кода

fix: cursor blinks when editing a new block

Tienson Qin 2 лет назад
Родитель
Сommit
2212016a3b
2 измененных файлов с 10 добавлено и 11 удалено
  1. 8 8
      src/main/frontend/components/block.cljs
  2. 2 3
      src/main/frontend/handler/block.cljs

+ 8 - 8
src/main/frontend/components/block.cljs

@@ -1808,15 +1808,15 @@
               (not doc-mode?))
          bullet
 
-         (or
+         (and
+          (not (util/react *control-show?))
+          (or
            (and empty-content?
                 (not edit?)
                 (not (:block.temp/top? block))
-                (not (:block.temp/bottom? block))
-                (not (util/react *control-show?)))
+                (not (:block.temp/bottom? block)))
            (and doc-mode?
-                (not collapsed?)
-                (not (util/react *control-show?))))
+                (not collapsed?))))
          ;; hidden
          [:span.bullet-container]
 
@@ -2986,7 +2986,7 @@
 
      ;; only render this for the first block in each container
      (when top?
-       (dnd-separator-wrapper block block-id slide? true false))
+       (dnd-separator-wrapper block children block-id slide? true false))
 
      [:div.block-main-container.flex.flex-row.pr-2
       {:class (if (and heading? (seq (:block/title block))) "items-baseline" "")
@@ -3002,8 +3002,8 @@
        :on-mouse-leave (fn [e]
                          (block-mouse-leave e *control-show? block-id doc-mode?))}
       (when (and (not slide?) (not in-whiteboard?) (not hidden?))
-        (block-control config block uuid block-id collapsed? *control-show? edit?))
-
+        (block-control config block uuid block-id collapsed? *control-show?
+                       (or edit? (= uuid (:block/uuid (state/get-edit-block))))))
       (when (and @*show-left-menu? (not in-whiteboard?) (not hidden?))
         (block-left-menu config block))
 

+ 2 - 3
src/main/frontend/handler/block.cljs

@@ -369,10 +369,9 @@
                            :else
                            ;; take the first dom node
                            (gdom/getElement (str "ls-block-" (:block/uuid block))))]
+      (state/set-editing! "" content block text-range {:ref next-edit-node})
       (if next-edit-node
-        (do
-          (state/set-editing! "" content block text-range {:ref next-edit-node})
-          (mark-last-input-time! repo))
+        (mark-last-input-time! repo)
         (util/schedule (fn [] (edit-block-aux repo block content block-node text-range (update opts :retry-times inc))))))))
 
 (defn edit-block!