fix: open inline block refs by default when zoom in a block

close #7636
This commit is contained in:
Tienson Qin
2022-12-09 14:23:15 +08:00
committed by Gabriel Horner
parent fb8f41077d
commit 5e86745b5e

View File

@@ -2360,10 +2360,17 @@
[:div.more (ui/icon "dots-circle-horizontal" {:size 18})])]])
(rum/defcs block-content-or-editor < rum/reactive
(rum/local true ::hide-block-refs?)
{:init (fn [state]
(let [block (second (:rum/args state))
config (first (:rum/args state))
current-block-page? (= (str (:block/uuid block)) (state/get-current-page))
embed-self? (and (:embed? config)
(= (:block/uuid block) (:block/uuid (:block config))))
default-hide? (if (and current-block-page? (not embed-self?)) false true)]
(assoc state ::hide-block-refs? (atom default-hide?))))}
[state config {:block/keys [uuid format] :as block} edit-input-id block-id edit? hide-block-refs-count?]
(let [*hide-block-refs? (get state ::hide-block-refs?)
hide-block-refs? @*hide-block-refs?
hide-block-refs? (rum/react *hide-block-refs?)
editor-box (get config :editor-box)
editor-id (str "editor-" edit-input-id)
slide? (:slide? config)
@@ -2778,7 +2785,10 @@
(if whiteboard-block?
(block-reference {} (str uuid) nil)
(block-content-or-editor config block edit-input-id block-id edit? false))
;; Not embed self
(let [hide-block-refs-count? (and (:embed? config)
(= (:block/uuid block) (:embed-id config)))]
(block-content-or-editor config block edit-input-id block-id edit? hide-block-refs-count?)))
(when @*show-right-menu?
(block-right-menu config block edit?))]