Browse Source

fix: page property

Tienson Qin 1 year ago
parent
commit
40a6b18db0

+ 2 - 25
src/main/frontend/components/property.cljs

@@ -140,7 +140,7 @@
                                   :selected (= type (:type property-schema))})))]
     [:div {:class (if in-block-container? "flex flex-1" "flex items-center col-span-2")}
      (shui/select
-      {:default-open in-block-container?
+      {:default-open true
        :on-value-change
        (fn [v]
          (let [type (keyword (string/lower-case v))
@@ -161,8 +161,7 @@
                              (update-schema-fn property-schema))]
               (components-pu/update-property! property property-name schema))
 
-            (when (and in-block-container? *show-new-property-config?)
-              (reset! *show-new-property-config? false)))))}
+            (reset! *show-new-property-config? false))))}
       (shui/select-trigger
        {:class "!px-2 !py-0 !h-8"}
        (shui/select-value
@@ -411,28 +410,6 @@
         (do (notification/show! "This is an invalid property name. A property name cannot start with page reference characters '#' or '[['." :error)
             (pv/exit-edit-property))))))
 
-(rum/defc property-value-new
-  [entity property property-value opts]
-
-  (let [*el-ref (rum/use-ref nil)]
-    (rum/use-effect!
-     (fn []
-       (let [content-fn
-             (fn [{:keys [id]}]
-               (property-config entity property
-                                (merge opts {:toggle-fn         #(shui/popup-hide! id)
-                                             :block             entity
-                                             :add-new-property? true})))]
-         (when-let [^js target (rum/deref *el-ref)]
-           (shui/popup-show! target content-fn
-                             {:content-props {:onOpenAutoFocus #(.preventDefault %) :class "w-auto"}}))))
-     [])
-
-    [:div.is-new-editing-property-input
-     {:ref *el-ref}
-     (pv/property-value entity property property-value
-                        (assoc opts :editing? true))]))
-
 (rum/defc property-select
   [exclude-properties on-chosen input-opts]
   (let [[properties set-properties!] (rum/use-state nil)]

+ 7 - 13
src/main/frontend/components/property/value.cljs

@@ -34,13 +34,10 @@
       (seq (get-in property [:block/schema :values]))))
 
 (defn exit-edit-property
-  ([]
-   (exit-edit-property true))
-  ([property-configure-check?]
-   (when (or (and property-configure-check? (not (:editor/property-configure? @state/state)))
-             (not property-configure-check?))
-     (state/set-state! :editor/new-property-input-id nil)
-     (state/clear-edit!))))
+  []
+  (state/set-state! :editor/new-property-input-id nil)
+  (state/set-state! :editor/properties nil)
+  (state/clear-edit!))
 
 (defn set-editing!
   [property editor-id dom-id v opts]
@@ -309,19 +306,16 @@
 ;;       (.focus editor))))
 
 (defn- save-text!
-  [repo block property value editor-id e]
+  [repo block property value _editor-id e]
   (let [new-value (util/evalue e)]
     (when (not (state/get-editor-action))
       (util/stop e)
       (p/do!
+       (exit-edit-property)
        (when (not= new-value value)
          (property-handler/set-block-property! repo (:block/uuid block)
                                                (:block/original-name property)
-                                               (string/trim new-value)))
-
-       (when (= js/document.activeElement (gdom/getElement editor-id))
-         (exit-edit-property false)
-         (shui/popup-hide!))))))
+                                               (string/trim new-value)))))))
 
 (defn <create-new-block!
   [block property value]