Skip to content

Commit

Permalink
Revert "enhance(ux): incorrect break line for the property key editor"
Browse files Browse the repository at this point in the history
This reverts commit ad52c68.
  • Loading branch information
tiensonqin committed Nov 25, 2024
1 parent a5c708a commit 3c3dea5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
18 changes: 1 addition & 17 deletions src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
29 changes: 3 additions & 26 deletions src/main/frontend/components/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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))]))

0 comments on commit 3c3dea5

Please sign in to comment.