Răsfoiți Sursa

enhance(ux): add pages to the bottom of Library page

Tienson Qin 8 luni în urmă
părinte
comite
3fc6710f06
1 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 7 2
      src/main/frontend/components/library.cljs

+ 7 - 2
src/main/frontend/components/library.cljs

@@ -7,6 +7,7 @@
             [frontend.search :as search]
             [frontend.state :as state]
             [frontend.ui :as ui]
+            [logseq.db :as ldb]
             [logseq.shui.hooks :as hooks]
             [logseq.shui.ui :as shui]
             [promesa.core :as p]
@@ -38,8 +39,12 @@
       :selected-choices selected-choices
       :on-chosen (fn [chosen selected?]
                    (if selected?
-                     (do
-                       (editor-handler/move-blocks! [{:db/id chosen}] library-page false)
+                     (let [last-child (->> (:block/_parent (db/entity (:db/id library-page)))
+                                           ldb/sort-by-order
+                                           last)
+                           target (or last-child library-page)
+                           sibling? (some? last-child)]
+                       (editor-handler/move-blocks! [{:db/id chosen}] target sibling?)
                        (set-selected-choices! (conj selected-choices chosen)))
                      (do
                        (db/transact! (state/get-current-repo)