mirror of https://github.com/logseq/logseq
chore: add debugger
parent
8c5314d449
commit
72277222d9
|
@ -17,6 +17,8 @@
|
|||
[frontend.state :as state]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.util :as util]
|
||||
[frontend.config :as config]
|
||||
[frontend.modules.editor.undo-redo :as undo-redo]
|
||||
[goog.object :as gobj]
|
||||
[medley.core :as medley]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
|
@ -66,6 +68,45 @@
|
|||
[:div.ml-2
|
||||
(block-cp repo idx block)]]))
|
||||
|
||||
(rum/defc history-action-info
|
||||
[[k v]]
|
||||
(when v [:.ml-4 (ui/foldable
|
||||
[:div (str k)]
|
||||
[:.ml-4 (case k
|
||||
:blocks
|
||||
(map (fn [block]
|
||||
[:.my-1 [:pre.code.pre-wrap-white-space.bg-base-4 (str block)]]) v)
|
||||
|
||||
:txs
|
||||
(map (fn [[_ key val]]
|
||||
(when val
|
||||
[:pre.code.pre-wrap-white-space.bg-base-4
|
||||
[:span.font-bold (str key) " "] (str val)])) v)
|
||||
|
||||
(map (fn [[key val]]
|
||||
(when val
|
||||
[:pre.code.pre-wrap-white-space.bg-base-4
|
||||
[:span.font-bold (str key) " "] (str val)])) v))]
|
||||
{:default-collapsed? true})]))
|
||||
|
||||
(rum/defc history-stack
|
||||
[label stack]
|
||||
[:.ml-4 (ui/foldable
|
||||
[:div label " (" (count stack) ")"]
|
||||
(map-indexed (fn [index item]
|
||||
[:.ml-4 (ui/foldable [:div (str index " " (-> item :tx-meta :outliner-op))]
|
||||
(map history-action-info item)
|
||||
{:default-collapsed? true})]) stack)
|
||||
{:default-collapsed? true})])
|
||||
|
||||
(rum/defc history < rum/reactive
|
||||
[]
|
||||
(let [state (undo-redo/get-state)]
|
||||
[:div.ml-4
|
||||
[:div.p-4 [:.ml-4.mb-2
|
||||
(history-stack "Undos" (rum/react (:undo-stack state)))
|
||||
(history-stack "Redos" (rum/react (:redo-stack state)))]]]))
|
||||
|
||||
(defn build-sidebar-item
|
||||
[repo idx db-id block-type]
|
||||
(case block-type
|
||||
|
@ -80,6 +121,10 @@
|
|||
[(str (t :right-side-bar/page-graph))
|
||||
(page/page-graph)]
|
||||
|
||||
:history
|
||||
[(str (t :right-side-bar/history))
|
||||
(history)]
|
||||
|
||||
:block-ref
|
||||
#_:clj-kondo/ignore
|
||||
(let [lookup (if (integer? db-id) db-id [:block/uuid db-id])]
|
||||
|
@ -281,7 +326,12 @@
|
|||
[:div.text-sm
|
||||
[:button.button.cp__right-sidebar-settings-btn {:on-click (fn [_e]
|
||||
(state/sidebar-add-block! repo "help" :help))}
|
||||
(t :right-side-bar/help)]]]
|
||||
(t :right-side-bar/help)]]
|
||||
|
||||
(when config/dev? [:div.text-sm
|
||||
[:button.button.cp__right-sidebar-settings-btn {:on-click (fn [_e]
|
||||
(state/sidebar-add-block! repo "history" :history))}
|
||||
(t :right-side-bar/history)]])]
|
||||
|
||||
(toggle)]
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
:right-side-bar/switch-theme "Theme modes"
|
||||
:right-side-bar/contents "Contents"
|
||||
:right-side-bar/page-graph "Page graph"
|
||||
:right-side-bar/history "(Dev) Undo/Redo history"
|
||||
:right-side-bar/block-ref "Block references"
|
||||
:right-side-bar/graph-view "Graph view"
|
||||
:right-side-bar/all-pages "All pages"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
(def ^:private undo-redo-states (atom {}))
|
||||
(def *pause-listener (atom false))
|
||||
|
||||
(defn- get-state
|
||||
(defn get-state
|
||||
[]
|
||||
(let [repo (state/get-current-repo)]
|
||||
(assert (string? repo) "Repo should satisfy string?")
|
||||
|
|
Loading…
Reference in New Issue