From 583a3d5dc8ad7dc4ff5bb14348016fa6b1e901ba Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 22 Aug 2023 21:36:38 +0800 Subject: [PATCH] Enhance/plugin APIs x (#10022) * fix(apis): validate non-empty uuid input for query block * fix(plugin): missing block data for the nested renderer macro hook * fix(plugin): incorrect block config for the query table block items --- src/main/frontend/components/block.cljs | 2 +- src/main/frontend/components/query_table.cljs | 9 +++++---- src/main/logseq/api/block.cljs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 5ab55fdd9..d7d2eaec2 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -952,7 +952,7 @@ (if (and (not paragraph?) (mldoc/block-with-title? (ffirst ast))) (markup-elements-cp (assoc config :block/format format) ast) - (inline-text format macro-content))) + (inline-text config format macro-content))) [:span.warning {:title (str "Unsupported macro name: " name)} (macro->text name arguments)])]) diff --git a/src/main/frontend/components/query_table.cljs b/src/main/frontend/components/query_table.cljs index 9283803fd..26b961296 100644 --- a/src/main/frontend/components/query_table.cljs +++ b/src/main/frontend/components/query_table.cljs @@ -118,7 +118,7 @@ (defn- build-column-value "Builds a column's tuple value for a query table given a row, column and options" - [row column {:keys [page? ->elem map-inline config comma-separated-property?]}] + [row column {:keys [page? ->elem map-inline comma-separated-property?]}] (case column :page [:string (if page? @@ -129,13 +129,14 @@ :block ; block title (let [content (:block/content row) + uuid (:block/uuid row) {:block/keys [title]} (block/parse-title-and-body (:block/uuid row) (:block/format row) (:block/pre-block? row) content)] (if (seq title) - [:element (->elem :div (map-inline config title))] + [:element (->elem :div (map-inline {:block/uuid uuid} title))] [:string content])) :created-at @@ -189,7 +190,7 @@ render-column-value (fn [row-format cell-format value] (cond ;; elements should be rendered as they are provided - (= :element cell-format) value + (= :element cell-format) value ;; collections are treated as a comma separated list of page-cps (coll? value) (->> (map #(page-cp {} {:block/name %}) value) (interpose [:span ", "])) @@ -198,7 +199,7 @@ ;; string values will attempt to be rendered as pages, falling back to ;; inline-text when no page entity is found (string? value) (if-let [page (db/entity [:block/name (util/page-name-sanity-lc value)])] - (page-cp {} page) + (page-cp {} page) (inline-text row-format value)) ;; anything else should just be rendered as provided :else value))] diff --git a/src/main/logseq/api/block.cljs b/src/main/logseq/api/block.cljs index d2eeed688..87b33ef23 100644 --- a/src/main/logseq/api/block.cljs +++ b/src/main/logseq/api/block.cljs @@ -12,7 +12,7 @@ [id-or-uuid ^js opts] (when-let [block (if (number? id-or-uuid) (db-utils/pull id-or-uuid) - (db-model/query-block-by-uuid (sdk-utils/uuid-or-throw-error id-or-uuid)))] + (and id-or-uuid (db-model/query-block-by-uuid (sdk-utils/uuid-or-throw-error id-or-uuid))))] (when-not (contains? block :block/name) (when-let [uuid (:block/uuid block)] (let [{:keys [includeChildren]} (bean/->clj opts)