fix(api): insert_batch_block target doesn't support page uuid

This commit is contained in:
Tienson Qin
2025-10-06 15:45:40 +08:00
parent d2acb49b56
commit e001e12c1f
3 changed files with 11 additions and 7 deletions

View File

@@ -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})))))

View File

@@ -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)))))))))))

View File

@@ -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)