mirror of https://github.com/logseq/logseq
Add option to handle default block refs expanding behaviour (#8839)
* Add option to handle default block refs expanding behaviour * provide default value * polish config desc for dicts * polish config desc in template config * specify option on settings page * fix: typo on fn name * chore: remove the tail period --------- Co-authored-by: situ2001 <yongcong2001@outlook.com>pull/8857/head
parent
54bd86aca7
commit
0eb25b3934
|
@ -2383,7 +2383,7 @@
|
|||
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)]
|
||||
default-hide? (if (and current-block-page? (not embed-self?) (state/auto-expand-block-refs?)) 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?)
|
||||
|
|
|
@ -133,6 +133,17 @@
|
|||
:width 500
|
||||
:height 500}]]])
|
||||
|
||||
(rum/defc auto-expand-hint
|
||||
[]
|
||||
[:div.ui__modal-panel
|
||||
{:style {:box-shadow "0 4px 20px 4px rgba(0, 20, 60, .1), 0 4px 80px -8px rgba(0, 20, 60, .2)"}}
|
||||
[:div {:style {:margin "12px" :max-width "500px"}}
|
||||
[:p.text-sm
|
||||
"This option controls whether to expand the block references automatically when zoom-in."]
|
||||
[:img {:src "https://user-images.githubusercontent.com/28241963/225818326-118deda9-9d1e-477d-b0ce-771ca0bcd976.gif"
|
||||
:width 500
|
||||
:height 500}]]])
|
||||
|
||||
(defn row-with-button-action
|
||||
[{:keys [left-label action button-label href on-click desc -for]}]
|
||||
[:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-start
|
||||
|
@ -378,6 +389,17 @@
|
|||
preferred-pasting-file?
|
||||
config-handler/toggle-preferred-pasting-file!))
|
||||
|
||||
(defn auto-expand-row [t auto-expand-block-refs?]
|
||||
(toggle "auto_expand_block_refs"
|
||||
[(t :settings-page/auto-expand-block-refs)
|
||||
(ui/tippy {:html (auto-expand-hint)
|
||||
:class "tippy-hover ml-2"
|
||||
:interactive true
|
||||
:disabled false}
|
||||
(svg/info))]
|
||||
auto-expand-block-refs?
|
||||
config-handler/toggle-auto-expand-block-refs!))
|
||||
|
||||
(defn tooltip-row [t enable-tooltip?]
|
||||
(toggle "enable_tooltip"
|
||||
(t :settings-page/enable-tooltip)
|
||||
|
@ -615,6 +637,7 @@
|
|||
logical-outdenting? (state/logical-outdenting?)
|
||||
show-full-blocks? (state/show-full-blocks?)
|
||||
preferred-pasting-file? (state/preferred-pasting-file?)
|
||||
auto-expand-block-refs? (state/auto-expand-block-refs?)
|
||||
enable-tooltip? (state/enable-tooltip?)
|
||||
enable-shortcut-tooltip? (state/sub :ui/shortcut-tooltip?)
|
||||
show-brackets? (state/show-brackets?)
|
||||
|
@ -631,6 +654,7 @@
|
|||
(outdenting-row t logical-outdenting?)
|
||||
(showing-full-blocks t show-full-blocks?)
|
||||
(preferred-pasting-file t preferred-pasting-file?)
|
||||
(auto-expand-row t auto-expand-block-refs?)
|
||||
(when-not (or (util/mobile?) (mobile-util/native-platform?))
|
||||
(shortcut-tooltip-row t enable-shortcut-tooltip?))
|
||||
(when-not (or (util/mobile?) (mobile-util/native-platform?))
|
||||
|
|
|
@ -175,6 +175,7 @@
|
|||
:settings-page/disable-sentry-desc "Logseq will never collect your local graph database or sell your data."
|
||||
:settings-page/preferred-outdenting "Logical outdenting"
|
||||
:settings-page/show-full-blocks "Show all lines of a block reference"
|
||||
:settings-page/auto-expand-block-refs "Expand block references automatically when zoom-in"
|
||||
:settings-page/custom-date-format "Preferred date format"
|
||||
:settings-page/custom-date-format-warning "Re-index required! Existing journal references would be broken!"
|
||||
:settings-page/preferred-file-format "Preferred file format"
|
||||
|
@ -1458,6 +1459,7 @@
|
|||
:settings-page/preferred-file-format "首选文件格式"
|
||||
:settings-page/preferred-workflow "首选工作流"
|
||||
:settings-page/preferred-pasting-file "保存链接为文件"
|
||||
:settings-page/auto-expand-block-refs "自动展开聚焦 block 的引用"
|
||||
:settings-page/enable-timetracking "开启 timetracking"
|
||||
:settings-page/enable-tooltip "开启提示框"
|
||||
:settings-page/enable-journals "开启日记"
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
(let [show-full-blocks? (state/show-full-blocks?)]
|
||||
(set-config! :ui/show-full-blocks? (not show-full-blocks?))))
|
||||
|
||||
(defn toggle-auto-expand-block-refs! []
|
||||
(let [auto-expand-block-refs? (state/auto-expand-block-refs?)]
|
||||
(set-config! :ui/auto-expand-block-refs? (not auto-expand-block-refs?))))
|
||||
|
||||
(defn toggle-ui-enable-tooltip! []
|
||||
(let [enable-tooltip? (state/enable-tooltip?)]
|
||||
(set-config! :ui/enable-tooltip? (not enable-tooltip?))))
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
[:ui/show-command-doc? :boolean]
|
||||
[:ui/show-empty-bullets? :boolean]
|
||||
[:ui/show-full-blocks? :boolean]
|
||||
[:ui/auto-expand-block-refs? :boolean]
|
||||
[:query/views [:map-of
|
||||
:keyword
|
||||
[:sequential any?]]]
|
||||
|
|
|
@ -313,6 +313,7 @@
|
|||
"Default config for a repo-specific, user config"
|
||||
{:feature/enable-search-remove-accents? true
|
||||
:default-arweave-gateway "https://arweave.net"
|
||||
:ui/auto-expand-block-refs? true
|
||||
|
||||
;; For flushing the settings of old versions. Don't bump this value.
|
||||
;; There are only two kinds of graph, one is not upgraded (:legacy) and one is upgraded (:triple-lowbar)
|
||||
|
@ -674,6 +675,10 @@ Similar to re-frame subscriptions"
|
|||
[]
|
||||
(:editor/preferred-pasting-file? (sub-config)))
|
||||
|
||||
(defn auto-expand-block-refs?
|
||||
[]
|
||||
(:ui/auto-expand-block-refs? (sub-config)))
|
||||
|
||||
(defn doc-mode-enter-for-new-line?
|
||||
[]
|
||||
(and (document-mode?)
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
;; Enable showing the body of blocks when referencing them.
|
||||
:ui/show-full-blocks? false
|
||||
|
||||
;; Expand block references automatically when zoom-in
|
||||
:ui/auto-expand-block-refs? true
|
||||
|
||||
;; Enable Block timestamp
|
||||
:feature/enable-block-timestamps? false
|
||||
|
||||
|
|
Loading…
Reference in New Issue