From e001e12c1f00a111f8f65c15e98569d38711a363 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 6 Oct 2025 15:45:40 +0800 Subject: [PATCH] fix(api): insert_batch_block target doesn't support page uuid --- src/main/frontend/handler/editor.cljs | 12 +++++++----- src/main/logseq/api.cljs | 5 +++-- src/main/logseq/api/block.cljs | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 88f27b6de7..9d3b443730 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -2064,12 +2064,11 @@ (when-not keep-uuid? [:id]) [:custom_id :custom-id] exclude-properties)) - :block/format format) - (not db-based?) - (assoc :block/properties-text-values (apply dissoc (:block/properties-text-values block) + :block/properties-text-values (apply dissoc (:block/properties-text-values block) (concat (when-not keep-uuid? [:id]) - exclude-properties))))))) + exclude-properties)) + :block/format format))))) (defn- edit-last-block-after-inserted! [result] @@ -2179,10 +2178,13 @@ A block element: {:content :properties :children [block-1, block-2, ...]}" [tree-vec format {:keys [target-block keep-uuid?] :as opts}] (let [repo (state/get-current-repo) - page-id (:db/id (:block/page target-block)) + page-id (or (:db/id (:block/page target-block)) + (when (ldb/page? target-block) + (:db/id target-block))) page-name (some-> page-id (db/entity) :block/name) blocks (block-tree->blocks repo tree-vec format keep-uuid? page-name) blocks (gp-block/with-parent-and-order page-id blocks)] + (ui-outliner-tx/transact! {:outliner-op :paste-blocks} (paste-blocks blocks (merge opts {:ops-only? true}))))) diff --git a/src/main/logseq/api.cljs b/src/main/logseq/api.cljs index 26844d34e3..e604929eb6 100644 --- a/src/main/logseq/api.cljs +++ b/src/main/logseq/api.cljs @@ -785,9 +785,10 @@ (throw (js/Error. (util/format "Custom block UUID already exists (%s)." uuid))))))) block (if before - (db/pull (:db/id (ldb/get-left-sibling (db/entity (:db/id block))))) block)] + (db/pull (:db/id (ldb/get-left-sibling (db/entity (:db/id block))))) block) + sibling? (if (ldb/page? block) false sibling)] (some-> (editor-handler/insert-block-tree-after-target - (:db/id block) sibling blocks' (get block :block/format :markdown) keep-uuid?) + (:db/id block) sibling? blocks' (get block :block/format :markdown) keep-uuid?) (p/then (fn [results] (some-> results :blocks (sdk-utils/normalize-keyword-for-json) (bean/->js))))))))))) diff --git a/src/main/logseq/api/block.cljs b/src/main/logseq/api/block.cljs index 761b9dd27a..3ea89faabb 100644 --- a/src/main/logseq/api/block.cljs +++ b/src/main/logseq/api/block.cljs @@ -133,6 +133,7 @@ {:outliner-op :set-block-properties} (doseq [[property-id property-ident value schema] properties] (when-not (qualified-keyword? property-ident) + (js/console.error (str "Invalid property id: " property-id)) (throw (ex-info "Invalid property id" {:property-id property-id :property-ident property-ident}))) (let [property (db/entity property-ident)