mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 23:19:38 +00:00
fix: avoid re-rendering text property block
This commit is contained in:
@@ -2443,7 +2443,7 @@
|
||||
:else
|
||||
nil)))
|
||||
|
||||
(rum/defcs db-properties-cp <
|
||||
(rum/defcs db-properties-cp < rum/static
|
||||
{:init (fn [state]
|
||||
(let [container-id (or (:container-id (first (:rum/args state)))
|
||||
(state/get-next-container-id))]
|
||||
@@ -3612,9 +3612,22 @@
|
||||
[old-block new-block]
|
||||
(not= (:block/tx-id old-block) (:block/tx-id new-block)))
|
||||
|
||||
(defn- config-block-should-update?
|
||||
[old-state new-state]
|
||||
(let [config-compare-keys [:show-cloze? :hide-children? :own-order-list-type :own-order-list-index :original-block :edit? :hide-bullet?]
|
||||
b1 (second (:rum/args old-state))
|
||||
b2 (second (:rum/args new-state))
|
||||
result (or
|
||||
(block-changed? b1 b2)
|
||||
;; config changed
|
||||
(not= (select-keys (first (:rum/args old-state)) config-compare-keys)
|
||||
(select-keys (first (:rum/args new-state)) config-compare-keys)))]
|
||||
(boolean result)))
|
||||
|
||||
(rum/defcs block-container < rum/reactive db-mixins/query
|
||||
(rum/local false ::show-block-left-menu?)
|
||||
(rum/local false ::show-block-right-menu?)
|
||||
{:should-update config-block-should-update?}
|
||||
{:init (fn [state]
|
||||
(let [[config block] (:rum/args state)
|
||||
block-id (:block/uuid block)
|
||||
@@ -4106,16 +4119,7 @@
|
||||
(map #(markup-element-cp config %) col))
|
||||
|
||||
(rum/defc block-item <
|
||||
{:should-update (fn [old-state new-state]
|
||||
(let [config-compare-keys [:show-cloze? :hide-children? :own-order-list-type :own-order-list-index :original-block :edit? :hide-bullet?]
|
||||
b1 (second (:rum/args old-state))
|
||||
b2 (second (:rum/args new-state))
|
||||
result (or
|
||||
(block-changed? b1 b2)
|
||||
;; config changed
|
||||
(not= (select-keys (first (:rum/args old-state)) config-compare-keys)
|
||||
(select-keys (first (:rum/args new-state)) config-compare-keys)))]
|
||||
(boolean result)))}
|
||||
{:should-update config-block-should-update?}
|
||||
[config item {:keys [top? bottom?]}]
|
||||
(let [original-block item
|
||||
linked-block (:block/link item)
|
||||
|
||||
@@ -252,39 +252,36 @@
|
||||
(reset! *show-new-property-config? false)))))))
|
||||
|
||||
(rum/defc property-key-title
|
||||
[block property class-schema? property-position]
|
||||
(let [block-container (state/get-component :block/container)]
|
||||
(shui/trigger-as
|
||||
:a
|
||||
{:tabIndex 0
|
||||
:title (:block/title property)
|
||||
:class "property-k flex select-none jtrigger w-full"
|
||||
:on-pointer-down (fn [^js e]
|
||||
(when (util/meta-key? e)
|
||||
(route-handler/redirect-to-page! (:block/uuid property))
|
||||
(.preventDefault e)))
|
||||
:on-click (fn [^js/MouseEvent e]
|
||||
(if (state/editing?)
|
||||
(editor-handler/escape-editing {:select? true})
|
||||
(shui/popup-show! (.-target e)
|
||||
(fn []
|
||||
(property-config/dropdown-editor property block {:debug? (.-altKey e)
|
||||
:class-schema? class-schema?}))
|
||||
{:content-props
|
||||
{:class "ls-property-dropdown-editor as-root"
|
||||
:onEscapeKeyDown (fn [e]
|
||||
(util/stop e)
|
||||
(shui/popup-hide!)
|
||||
(when-let [input (state/get-input)]
|
||||
(.focus input)))}
|
||||
:align "start"
|
||||
:as-dropdown? true})))}
|
||||
(if (= :block-below property-position)
|
||||
(:block/title property)
|
||||
(block-container {:property? true} property)))))
|
||||
[block property class-schema?]
|
||||
(shui/trigger-as
|
||||
:a
|
||||
{:tabIndex 0
|
||||
:title (:block/title property)
|
||||
:class "property-k flex select-none jtrigger w-full"
|
||||
:on-pointer-down (fn [^js e]
|
||||
(when (util/meta-key? e)
|
||||
(route-handler/redirect-to-page! (:block/uuid property))
|
||||
(.preventDefault e)))
|
||||
:on-click (fn [^js/MouseEvent e]
|
||||
(if (state/editing?)
|
||||
(editor-handler/escape-editing {:select? true})
|
||||
(shui/popup-show! (.-target e)
|
||||
(fn []
|
||||
(property-config/dropdown-editor property block {:debug? (.-altKey e)
|
||||
:class-schema? class-schema?}))
|
||||
{:content-props
|
||||
{:class "ls-property-dropdown-editor as-root"
|
||||
:onEscapeKeyDown (fn [e]
|
||||
(util/stop e)
|
||||
(shui/popup-hide!)
|
||||
(when-let [input (state/get-input)]
|
||||
(.focus input)))}
|
||||
:align "start"
|
||||
:as-dropdown? true})))}
|
||||
(:block/title property)))
|
||||
|
||||
(rum/defc property-key-cp < rum/static
|
||||
[block property {:keys [other-position? class-schema? property-position]}]
|
||||
[block property {:keys [other-position? class-schema?]}]
|
||||
(let [icon (:logseq.property/icon property)]
|
||||
[:div.property-key-inner.jtrigger-view
|
||||
;; icon picker
|
||||
@@ -319,7 +316,7 @@
|
||||
[:a.property-k.flex.select-none.jtrigger
|
||||
{:on-click #(route-handler/redirect-to-page! (:block/uuid property))}
|
||||
(:block/title property)]
|
||||
(property-key-title block property class-schema? property-position))]))
|
||||
(property-key-title block property class-schema?))]))
|
||||
|
||||
(rum/defcs property-input < rum/reactive
|
||||
(rum/local nil ::ref)
|
||||
@@ -548,7 +545,7 @@
|
||||
{:db/id (:db/id block)})]
|
||||
{:outliner-op :save-block})))})))
|
||||
|
||||
(rum/defc properties-section < rum/reactive db-mixins/query
|
||||
(rum/defc properties-section < rum/static
|
||||
[block properties opts]
|
||||
(when (seq properties)
|
||||
;; Sort properties by :block/order
|
||||
|
||||
Reference in New Issue
Block a user