Pārlūkot izejas kodu

perf: disable lazy load for short pages

Also, fixed slow blocks selection
Tienson Qin 2 gadi atpakaļ
vecāks
revīzija
481481fc47

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

@@ -3434,7 +3434,7 @@
                      (:blocks-container-id config)
                      "-"
                      (:block/uuid item))}
-     (if hidden?
+     (if (and hidden? (not (:disable-lazy-load? config)))
        [:div {:style {:height 24}}]
        (block-item-inner config item opts))]))
 

+ 4 - 1
src/main/frontend/components/page.cljs

@@ -154,12 +154,15 @@
 
         :else
         (let [document-mode? (state/sub :document/mode?)
+              short-page? (when-not block?
+                            (<= (count (:block/_page block)) 200))
               hiccup-config (merge
                              {:id (if block? (str block-id) page-name)
                               :db/id (:db/id block)
                               :block? block?
                               :editor-box editor/box
-                              :document/mode? document-mode?}
+                              :document/mode? document-mode?
+                              :disable-lazy-load? short-page?}
                              config)
               config (common-handler/config-with-document-mode hiccup-config)
               blocks (if block? [block] (db/sort-by-left (:block/_parent block) block))]

+ 3 - 1
src/main/frontend/handler/editor.cljs

@@ -1150,7 +1150,9 @@
           blocks (if (= :up direction)
                    (reverse blocks)
                    blocks)]
-      (state/exit-editing-and-set-selected-blocks! blocks direction))))
+      (if (state/get-edit-input-id)
+        (state/exit-editing-and-set-selected-blocks! blocks direction)
+        (state/set-selection-blocks! blocks direction)))))
 
 (defn- select-block-up-down
   [direction]