enhance(ux): able to create pages directly on Library

This commit is contained in:
Tienson Qin
2025-06-16 11:05:22 +08:00
parent edfd020276
commit f442ae82a0
3 changed files with 32 additions and 12 deletions

View File

@@ -334,7 +334,7 @@
txs (map (fn [id] [:db.fn/retractEntity [:block/uuid id]]) ids)
page-tx (let [block (d/entity db [:block/uuid block-id])]
(when (:block/pre-block? block)
(let [id (:db/id (:block/page block))]
(when-let [id (:db/id (:block/page block))]
[[:db/retract id :block/properties]
[:db/retract id :block/properties-order]
[:db/retract id :block/properties-text-values]
@@ -531,11 +531,13 @@
(let [ref-ids (set (map :block/uuid (:block/refs block)))]
(->> (set/intersection block-ids ref-ids)
(remove #{(:block/uuid block)})))))
m {:db/id (:db/id block)
:block/uuid uuid'
:block/page target-page
:block/parent parent
:block/order order}
m (cond->
{:db/id (:db/id block)
:block/uuid uuid'
:block/parent parent
:block/order order}
(not (ldb/page? block))
(assoc :block/page target-page))
result (->
(if (de/entity? block)
(assoc m :block/level (:block/level block))

View File

@@ -88,10 +88,21 @@
[?b :block/title ?title]
[?b :block/tags ?tag-id]
[(not= ?b ?eid)]
;; same parent
;; same extends
[?b :logseq.property.class/extends ?bp]
[?eid :logseq.property.class/extends ?ep]
[(= ?bp ?ep)]]
(:block/parent entity)
'[:find [?b ...]
:in $ ?eid ?title [?tag-id ...]
:where
[?b :block/title ?title]
[?b :block/tags ?tag-id]
[(not= ?b ?eid)]
;; same parent
[?b :block/parent ?bp]
[?eid :block/parent ?ep]
[(= ?bp ?ep)]]
:else
'[:find [?b ...]
:in $ ?eid ?title [?tag-id ...]

View File

@@ -336,14 +336,21 @@
true
:else
(not has-children?))]
(not has-children?))
library? (:library? config)
new-block' (if library?
(-> new-block
(-> (assoc :block/tags #{:logseq.class/Page}
:block/name (util/page-name-sanity-lc (:block/title new-block)))
(dissoc :block/page)))
new-block)]
(ui-outliner-tx/transact!
{:outliner-op :insert-blocks}
(save-current-block! {:current-block current-block})
(outliner-op/insert-blocks! [new-block] current-block {:sibling? sibling?
:keep-uuid? keep-uuid?
:ordered-list? ordered-list?
:replace-empty-target? replace-empty-target?}))))
(outliner-op/insert-blocks! [new-block'] current-block {:sibling? sibling?
:keep-uuid? keep-uuid?
:ordered-list? ordered-list?
:replace-empty-target? replace-empty-target?}))))
(defn- block-self-alone-when-insert?
[config uuid]