From 1bea86974c0f1f05488f5dfdc8e1160cf578992e Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 27 Sep 2023 00:11:52 +0800 Subject: [PATCH] fix: can't use template for blocks --- .../frontend/components/property/value.cljs | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/frontend/components/property/value.cljs b/src/main/frontend/components/property/value.cljs index f0b565995..2dede4195 100644 --- a/src/main/frontend/components/property/value.cljs +++ b/src/main/frontend/components/property/value.cljs @@ -417,23 +417,30 @@ (if editing? (let [dropdown? (if-some [x dropdown?] x true)] [:div.flex.flex-1 - (case type - (list :number :url) - (select block property (assoc select-opts - :multiple-choices? multiple-values? - :dropdown? dropdown?)) + (case type + (list :number :url) + (select block property (assoc select-opts + :multiple-choices? multiple-values? + :dropdown? dropdown?)) - :page - (select-page block property (assoc select-opts - :classes (:classes schema) - :multiple-choices? multiple-values? - :dropdown? dropdown?)) + :page + (select-page block property (assoc select-opts + :classes (:classes schema) + :multiple-choices? multiple-values? + :dropdown? dropdown?)) - (let [config {:editor-opts (new-text-editor-opts repo block property value editor-id)}] - [:div - (editor-box editor-args editor-id (cond-> config - multiple-values? - (assoc :property-value value)))]))]) + :template + (let [id (first (:classes schema)) + template (when id (db/entity [:block/uuid id]))] + (when template + (create-new-block-from-template! block property template) + (exit-edit-property))) + + (let [config {:editor-opts (new-text-editor-opts repo block property value editor-id)}] + [:div + (editor-box editor-args editor-id (cond-> config + multiple-values? + (assoc :property-value value)))]))]) (let [class (str (when-not row? "flex flex-1 ") (when multiple-values? "property-value-content"))] [:div {:id (or dom-id (random-uuid))