fix: allow moving non page blocks to library on UI

This commit is contained in:
Tienson Qin
2025-11-04 14:54:29 +08:00
parent 97e8140d7f
commit 46c4f66aec
2 changed files with 4 additions and 13 deletions

View File

@@ -240,7 +240,7 @@
(defn- remove-inline-page-classes
[db {:block/keys [tags] :as block}]
;; Notice: should check `page?` for block from the current db
(if (ldb/page? (d/entity db (:db/id block)))
(if (or (ldb/page? (d/entity db (:db/id block))) (:block/name block))
block
(let [tags' (cond
(or (integer? tags)
@@ -922,10 +922,8 @@
(let [target-block (d/entity db (:db/id target-block))
block (d/entity db (:db/id block))]
(if (or
;; target-block doesn't have parent or moving non-page block to library
(and sibling? (or (nil? (:block/parent target-block))
(and (not (ldb/page? block))
(ldb/library? (:block/parent target-block)))))
;; target-block doesn't have parent
(and sibling? (nil? (:block/parent target-block)))
;; move page to be a child of block
(and (not sibling?)
(not (ldb/page? target-block))

View File

@@ -183,14 +183,7 @@
page-tag-update? (and (= :block/tags (:a datom))
(= (:db/id page-tag) (:v datom)))
move-to-library? (and (= :block/parent (:a datom))
(or (= (:db/id library-page) (:v datom))
(and
(ldb/page? (d/entity db (:v datom)))
(let [parents (->> (ldb/get-block-parents db (:block/uuid (d/entity db (:v datom))))
(map :db/id)
(set))]
(contains? parents (:db/id library-page)))))
(= (:db/id library-page) (:v datom))
(:added datom))]
(when (or page-tag-update? move-to-library?)
(let [block-before (d/entity db-before id)