From ecb12cf4b07c6269c38fa969aadac4a39fa6fa56 Mon Sep 17 00:00:00 2001 From: rcmerci Date: Wed, 28 Jun 2023 17:48:14 +0800 Subject: [PATCH] property uuid key --- src/main/frontend/components/property.cljs | 7 +++---- src/main/frontend/db/model.cljs | 4 ++-- src/main/frontend/handler/property.cljs | 6 +++--- src/main/frontend/util.cljc | 6 ++++++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index d2171ca25d..28ec3ff947 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -82,12 +82,11 @@ (when (seq properties) [:div (for [[prop-uuid-or-built-in-prop v] properties] - (if (and (string? prop-uuid-or-built-in-prop) - (util/uuid-string? prop-uuid-or-built-in-prop)) - (when-let [property-class (db/pull [:block/uuid (uuid prop-uuid-or-built-in-prop)])] + (if (uuid? prop-uuid-or-built-in-prop) + (when-let [property-class (db/pull [:block/uuid prop-uuid-or-built-in-prop])] [:div [:a.mr-2 - {:on-click (fn [] (state/set-modal! #(property-class-config repo (uuid prop-uuid-or-built-in-prop))))} + {:on-click (fn [] (state/set-modal! #(property-class-config repo prop-uuid-or-built-in-prop)))} (:block/name property-class)] [:span (or (get properties-text-values prop-uuid-or-built-in-prop) (str v))] [:a.ml-8 {:on-click diff --git a/src/main/frontend/db/model.cljs b/src/main/frontend/db/model.cljs index 06e0ecc52f..b441d1cfa1 100644 --- a/src/main/frontend/db/model.cljs +++ b/src/main/frontend/db/model.cljs @@ -1170,8 +1170,8 @@ independent of format as format specific heading characters are stripped" (apply concat) distinct (map (fn [k] - (if (and (string? k) (util/uuid-string? k)) - (keyword (:block/name (d/entity db [:block/uuid (uuid k)]))) + (if (uuid? k) + (keyword (:block/name (d/entity db [:block/uuid k]))) k))) sort))) diff --git a/src/main/frontend/handler/property.cljs b/src/main/frontend/handler/property.cljs index 6a422e1c0e..34ece48a32 100644 --- a/src/main/frontend/handler/property.cljs +++ b/src/main/frontend/handler/property.cljs @@ -90,14 +90,14 @@ :block/uuid property-class-uuid :block/type "property"}])) (let [block-properties (assoc (:block/properties block) - (str property-class-uuid) + property-class-uuid (if (= property-schema :string-contains-refs) (set (extract-page-refs-from-prop-str-value v*)) v*)) block-properties-text-values (if (= property-schema :string-contains-refs) - (assoc (:block/properties-text-values block) (str property-class-uuid) v*) - (dissoc (:block/properties-text-values block) (str property-class-uuid)))] + (assoc (:block/properties-text-values block) property-class-uuid v*) + (dissoc (:block/properties-text-values block) property-class-uuid))] (outliner-tx/transact! {:outliner-op :save-block} (outliner-core/save-block! diff --git a/src/main/frontend/util.cljc b/src/main/frontend/util.cljc index 4d9954ca1a..e99bd53133 100644 --- a/src/main/frontend/util.cljc +++ b/src/main/frontend/util.cljc @@ -45,6 +45,12 @@ js/Symbol (-pr-writer [sym writer _] (-write writer (str "\"" (.toString sym) "\""))))) +#?(:cljs + (extend-protocol INamed + UUID + (-name [this] (str this)) + (-namespace [_] nil))) + #?(:cljs (defonce ^js node-path utils/nodePath)) #?(:cljs (defonce ^js full-path-extname pathCompleteExtname))