mirror of https://github.com/logseq/logseq
enhance: persistent "Copy As" options
parent
81e93cbd5e
commit
e2abf01deb
|
@ -76,8 +76,8 @@
|
||||||
[state root-block-ids]
|
[state root-block-ids]
|
||||||
(let [current-repo (state/get-current-repo)
|
(let [current-repo (state/get-current-repo)
|
||||||
type (rum/react *export-block-type)
|
type (rum/react *export-block-type)
|
||||||
text-indent-style (rum/react (state/get-export-block-text-indent-style))
|
text-indent-style (state/sub :copy/export-block-text-indent-style)
|
||||||
text-remove-options (rum/react (state/get-export-block-text-remove-options))
|
text-remove-options (state/sub :copy/export-block-text-remove-options)
|
||||||
copied? (::copied? state)
|
copied? (::copied? state)
|
||||||
content
|
content
|
||||||
(case type
|
(case type
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
:visibility (if (= :text type) "visible" "hidden")}
|
:visibility (if (= :text type) "visible" "hidden")}
|
||||||
:on-change (fn [e]
|
:on-change (fn [e]
|
||||||
(let [value (util/evalue e)]
|
(let [value (util/evalue e)]
|
||||||
(reset! (state/get-export-block-text-indent-style) value)))}
|
(state/set-export-block-text-indent-style! value)))}
|
||||||
(for [{:keys [label value selected]} options]
|
(for [{:keys [label value selected]} options]
|
||||||
[:option (cond->
|
[:option (cond->
|
||||||
{:key label
|
{:key label
|
||||||
|
@ -124,11 +124,8 @@
|
||||||
(ui/checkbox {:style {:margin-right 6
|
(ui/checkbox {:style {:margin-right 6
|
||||||
:visibility (if (= :text type) "visible" "hidden")}
|
:visibility (if (= :text type) "visible" "hidden")}
|
||||||
:checked (contains? text-remove-options :page-ref)
|
:checked (contains? text-remove-options :page-ref)
|
||||||
:on-change (fn [e] (if (util/echecked? e)
|
:on-change (fn [e]
|
||||||
(swap! (state/get-export-block-text-remove-options)
|
(state/update-export-block-text-remove-options! e :page-ref))})
|
||||||
#(conj % :page-ref))
|
|
||||||
(swap! (state/get-export-block-text-remove-options)
|
|
||||||
#(disj % :page-ref))))})
|
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
{:style {:visibility (if (= :text type) "visible" "hidden")}}
|
{:style {:visibility (if (= :text type) "visible" "hidden")}}
|
||||||
|
@ -137,11 +134,8 @@
|
||||||
:margin-left 10
|
:margin-left 10
|
||||||
:visibility (if (= :text type) "visible" "hidden")}
|
:visibility (if (= :text type) "visible" "hidden")}
|
||||||
:checked (contains? text-remove-options :emphasis)
|
:checked (contains? text-remove-options :emphasis)
|
||||||
:on-change (fn [e] (if (util/echecked? e)
|
:on-change (fn [e]
|
||||||
(swap! (state/get-export-block-text-remove-options)
|
(state/update-export-block-text-remove-options! e :emphasis))})
|
||||||
#(conj % :emphasis))
|
|
||||||
(swap! (state/get-export-block-text-remove-options)
|
|
||||||
#(disj % :emphasis))))})
|
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
{:style {:visibility (if (= :text type) "visible" "hidden")}}
|
{:style {:visibility (if (= :text type) "visible" "hidden")}}
|
||||||
|
|
|
@ -1088,8 +1088,8 @@
|
||||||
top-level-block-uuids (mapv :block/uuid (filterv #(not (vector? %)) tree))
|
top-level-block-uuids (mapv :block/uuid (filterv #(not (vector? %)) tree))
|
||||||
exported-md-contents (export/export-blocks-as-markdown
|
exported-md-contents (export/export-blocks-as-markdown
|
||||||
repo top-level-block-uuids
|
repo top-level-block-uuids
|
||||||
@(state/get-export-block-text-indent-style)
|
(state/get-export-block-text-indent-style)
|
||||||
(into [] @(state/get-export-block-text-remove-options)))]
|
(into [] (state/get-export-block-text-remove-options)))]
|
||||||
[exported-md-contents tree]))
|
[exported-md-contents tree]))
|
||||||
|
|
||||||
(defn copy-selection-blocks
|
(defn copy-selection-blocks
|
||||||
|
|
|
@ -150,9 +150,10 @@
|
||||||
;; copied blocks
|
;; copied blocks
|
||||||
:copy/blocks {:copy/content nil :copy/block-tree nil}
|
:copy/blocks {:copy/content nil :copy/block-tree nil}
|
||||||
|
|
||||||
:copy/export-block-text-indent-style (atom "dashes")
|
:copy/export-block-text-indent-style (or (storage/get :copy/export-block-text-indent-style)
|
||||||
:copy/export-block-text-remove-options (atom #{})
|
"dashes")
|
||||||
|
:copy/export-block-text-remove-options (or (storage/get :copy/export-block-text-remove-options)
|
||||||
|
#{})
|
||||||
:date-picker/date nil
|
:date-picker/date nil
|
||||||
|
|
||||||
:view/components {}})))
|
:view/components {}})))
|
||||||
|
@ -1385,9 +1386,21 @@
|
||||||
(defn get-export-block-text-indent-style []
|
(defn get-export-block-text-indent-style []
|
||||||
(:copy/export-block-text-indent-style @state))
|
(:copy/export-block-text-indent-style @state))
|
||||||
|
|
||||||
|
(defn set-export-block-text-indent-style!
|
||||||
|
[v]
|
||||||
|
(set-state! :copy/export-block-text-indent-style v)
|
||||||
|
(storage/set :copy/export-block-text-indent-style v))
|
||||||
|
|
||||||
(defn get-export-block-text-remove-options []
|
(defn get-export-block-text-remove-options []
|
||||||
(:copy/export-block-text-remove-options @state))
|
(:copy/export-block-text-remove-options @state))
|
||||||
|
|
||||||
|
(defn update-export-block-text-remove-options!
|
||||||
|
[e k]
|
||||||
|
(let [f (if (util/echecked? e) conj disj)]
|
||||||
|
(update-state! :copy/export-block-text-remove-options
|
||||||
|
#(f % k))
|
||||||
|
(storage/set :copy/export-block-text-remove-options
|
||||||
|
(get-export-block-text-remove-options))))
|
||||||
|
|
||||||
(defn set-editor-args!
|
(defn set-editor-args!
|
||||||
[args]
|
[args]
|
||||||
|
|
Loading…
Reference in New Issue