From 3c3dea5d38208c2aec10b31a189a588af02e1d9b Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 25 Nov 2024 16:50:32 +0800 Subject: [PATCH] Revert "enhance(ux): incorrect break line for the property key editor" This reverts commit ad52c68793e48af90b6c7b348e2fb84953191bfb. --- src/main/frontend/components/block.cljs | 18 +-------------- src/main/frontend/components/editor.cljs | 29 +++--------------------- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 83291b1ffb1..8c458a5af4b 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -2819,19 +2819,6 @@ (when-not edit? [:div.more (ui/icon "dots-circle-horizontal" {:size 18})])]]) -(rum/defc block-content-size-observer - [*wrap-ref config] - (rum/use-effect! - (fn [] - (when-let [^js el (and (:property? config) (rum/deref *wrap-ref))] - (util/schedule - (fn [] - (let [w (.-clientWidth el)] - (dom/set-attr! el :data-width w) - (dom/set-style! el :width (str w ".5px")))))) - [])) - [:<>]) - (rum/defcs ^:large-vars/cleanup-todo block-content-or-editor < rum/reactive (rum/local false ::hover?) {:init (fn [state] @@ -2870,15 +2857,12 @@ raw-mode-block (state/sub :editor/raw-mode-block) type-block-editor? (and (contains? #{:code} (:logseq.property.node/display-type block)) (not= (:db/id block) (:db/id raw-mode-block))) - config (assoc config :block-parent-id block-id) - *inner-el (rum/create-ref)] + config (assoc config :block-parent-id block-id)] [:div.block-content-or-editor-wrap {:class (when (:page-title? config) "ls-page-title-container") :data-node-type (some-> (:logseq.property.node/display-type block) name)} (when (and db-based? (not table?)) (block-positioned-properties config block :block-left)) - (block-content-size-observer *inner-el config) [:div.block-content-or-editor-inner - {:ref *inner-el} [:div.flex.flex-1.flex-row.gap-1.items-center (if (and editor-box edit? (not type-block-editor?)) [:div.editor-wrapper.flex.flex-1 diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 271455a1733..7292c7f1c87 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -738,23 +738,6 @@ (some-> config :on-escape-editing (apply [(str uuid) (= type :esc)]))))))) -(rum/defc editor-box-size-observer - [*wrap-ref _config] - (rum/use-effect! - (fn [] - (let [^js wrap (rum/deref *wrap-ref) - ^js content-wrap (some-> wrap (.closest ".block-content-or-editor-inner"))] - (when-let [content-width (some-> content-wrap (.-dataset) (.-width))] - (dom/set-style! wrap :width (str (inc (js/parseInt content-width)) "px")) - ;; clear content wrap width - (fn [] - (util/schedule - (fn [] - (dom/set-attr! content-wrap :data-width (.-clientWidth content-wrap)) - (dom/set-style! content-wrap :width "auto"))))))) - []) - [:<>]) - (rum/defcs box < rum/reactive {:init (fn [state] (assoc state @@ -778,9 +761,7 @@ lifecycle/lifecycle [state {:keys [format block parent-block]} id config] (let [*ref (::ref state) - *wrap-ref (rum/create-ref) content (state/sub-edit-content (:block/uuid block)) - property? (:property? config) heading-class (get-editor-style-class block content format) opts (cond-> {:id id @@ -803,15 +784,11 @@ true (merge (:editor-opts config)))] - [:div.editor-inner.flex.flex-1 - {:class (str (if block "block-editor" "non-block-editor") - (when property? " as-property")) - :ref *wrap-ref} + [:div.editor-inner.flex.flex-1 {:class (if block "block-editor" "non-block-editor")} + (ui/ls-textarea opts) (mock-textarea content) (command-popups id format) (when format - (image-uploader id format)) - (when property? - (editor-box-size-observer *wrap-ref config))])) + (image-uploader id format))]))