|
@@ -16,129 +16,129 @@
|
|
|
|
|
|
|
|
(defonce ^:private state
|
|
(defonce ^:private state
|
|
|
(atom
|
|
(atom
|
|
|
- {:route-match nil
|
|
|
|
|
- :today nil
|
|
|
|
|
- :system/events (async/chan 100)
|
|
|
|
|
- :db/batch-txs (async/chan 100)
|
|
|
|
|
- :file/writes (async/chan 100)
|
|
|
|
|
- :notification/show? false
|
|
|
|
|
- :notification/content nil
|
|
|
|
|
- :repo/cloning? false
|
|
|
|
|
- :repo/loading-files? nil
|
|
|
|
|
- :repo/importing-to-db? nil
|
|
|
|
|
- :repo/sync-status {}
|
|
|
|
|
- :repo/changed-files nil
|
|
|
|
|
- :nfs/user-granted? {}
|
|
|
|
|
- :nfs/refreshing? nil
|
|
|
|
|
- :instrument/disabled? (storage/get "instrument-disabled")
|
|
|
|
|
- ;; TODO: how to detect the network reliably?
|
|
|
|
|
- :network/online? true
|
|
|
|
|
- :indexeddb/support? true
|
|
|
|
|
- :me nil
|
|
|
|
|
- :git/current-repo (storage/get :git/current-repo)
|
|
|
|
|
- :git/status {}
|
|
|
|
|
- :format/loading {}
|
|
|
|
|
- :draw? false
|
|
|
|
|
- :db/restoring? nil
|
|
|
|
|
-
|
|
|
|
|
- :journals-length 2
|
|
|
|
|
-
|
|
|
|
|
- :search/q ""
|
|
|
|
|
- :search/mode :global
|
|
|
|
|
- :search/result nil
|
|
|
|
|
-
|
|
|
|
|
- ;; modals
|
|
|
|
|
- :modal/show? false
|
|
|
|
|
-
|
|
|
|
|
- ;; right sidebar
|
|
|
|
|
- :ui/settings-open? false
|
|
|
|
|
- :ui/sidebar-open? false
|
|
|
|
|
- :ui/left-sidebar-open? false
|
|
|
|
|
- :ui/theme (or (storage/get :ui/theme) "dark")
|
|
|
|
|
- :ui/system-theme? ((fnil identity (or util/mac? util/win32? false)) (storage/get :ui/system-theme?))
|
|
|
|
|
- :ui/wide-mode? false
|
|
|
|
|
- ;; :show-all, :hide-block-body, :hide-block-children
|
|
|
|
|
- :ui/cycle-collapse :show-all
|
|
|
|
|
- :ui/sidebar-collapsed-blocks {}
|
|
|
|
|
- :ui/root-component nil
|
|
|
|
|
- :ui/file-component nil
|
|
|
|
|
- :ui/custom-query-components {}
|
|
|
|
|
- :ui/show-recent? false
|
|
|
|
|
- :ui/developer-mode? (or (= (storage/get "developer-mode") "true")
|
|
|
|
|
- false)
|
|
|
|
|
- ;; remember scroll positions of visited paths
|
|
|
|
|
- :ui/paths-scroll-positions {}
|
|
|
|
|
-
|
|
|
|
|
- :document/mode? (or (storage/get :document/mode?) false)
|
|
|
|
|
-
|
|
|
|
|
- :github/contents {}
|
|
|
|
|
- :config {}
|
|
|
|
|
- :block/component-editing-mode? false
|
|
|
|
|
- :editor/draw-mode? false
|
|
|
|
|
- :editor/show-page-search? false
|
|
|
|
|
- :editor/show-page-search-hashtag? false
|
|
|
|
|
- :editor/show-date-picker? false
|
|
|
|
|
- ;; With label or other data
|
|
|
|
|
- :editor/show-input nil
|
|
|
|
|
- :editor/last-saved-cursor nil
|
|
|
|
|
- :editor/editing? nil
|
|
|
|
|
- :editor/last-edit-block-input-id nil
|
|
|
|
|
- :editor/last-edit-block-id nil
|
|
|
|
|
- :editor/in-composition? false
|
|
|
|
|
- :editor/content {}
|
|
|
|
|
- :editor/block nil
|
|
|
|
|
- :editor/block-dom-id nil
|
|
|
|
|
- :editor/set-timestamp-block nil
|
|
|
|
|
- :editor/last-input-time nil
|
|
|
|
|
- :editor/new-block-toggle? false
|
|
|
|
|
- :editor/args nil
|
|
|
|
|
- :db/last-transact-time {}
|
|
|
|
|
- :db/last-persist-transact-ids {}
|
|
|
|
|
- ;; whether database is persisted
|
|
|
|
|
- :db/persisted? {}
|
|
|
|
|
- :db/latest-txs (or (storage/get-transit :db/latest-txs) {})
|
|
|
|
|
- :cursor-range nil
|
|
|
|
|
-
|
|
|
|
|
- :selection/mode false
|
|
|
|
|
- :selection/blocks []
|
|
|
|
|
- :selection/start-block nil
|
|
|
|
|
- ;; either :up or :down, defaults to down
|
|
|
|
|
- ;; used to determine selection direction when two or more blocks are selected
|
|
|
|
|
- :selection/direction :down
|
|
|
|
|
- :custom-context-menu/show? false
|
|
|
|
|
- :custom-context-menu/links nil
|
|
|
|
|
-
|
|
|
|
|
- ;; pages or blocks in the right sidebar
|
|
|
|
|
- ;; It is a list of `[repo db-id block-type block-data]` 4-tuple
|
|
|
|
|
- :sidebar/blocks '()
|
|
|
|
|
-
|
|
|
|
|
- :preferred-language (storage/get :preferred-language)
|
|
|
|
|
-
|
|
|
|
|
- ;; electron
|
|
|
|
|
- :electron/updater-pending? false
|
|
|
|
|
- :electron/updater {}
|
|
|
|
|
-
|
|
|
|
|
- ;; plugin
|
|
|
|
|
- :plugin/indicator-text nil
|
|
|
|
|
- :plugin/installed-plugins {}
|
|
|
|
|
- :plugin/installed-themes []
|
|
|
|
|
- :plugin/installed-commands {}
|
|
|
|
|
- :plugin/installed-ui-items {}
|
|
|
|
|
- :plugin/simple-commands {}
|
|
|
|
|
- :plugin/selected-theme nil
|
|
|
|
|
- :plugin/selected-unpacked-pkg nil
|
|
|
|
|
- :plugin/active-readme nil
|
|
|
|
|
-
|
|
|
|
|
- ;; all notification contents as k-v pairs
|
|
|
|
|
- :notification/contents {}
|
|
|
|
|
- :graph/syncing? false
|
|
|
|
|
-
|
|
|
|
|
- ;; copied blocks
|
|
|
|
|
- :copy/blocks {:copy/content nil :copy/block-tree nil}
|
|
|
|
|
-
|
|
|
|
|
- :date-picker/date nil
|
|
|
|
|
-
|
|
|
|
|
- :view/components {}}))
|
|
|
|
|
|
|
+ (let [document-mode? (or (storage/get :document/mode?) false)]
|
|
|
|
|
+ {:route-match nil
|
|
|
|
|
+ :today nil
|
|
|
|
|
+ :system/events (async/chan 100)
|
|
|
|
|
+ :db/batch-txs (async/chan 100)
|
|
|
|
|
+ :file/writes (async/chan 100)
|
|
|
|
|
+ :notification/show? false
|
|
|
|
|
+ :notification/content nil
|
|
|
|
|
+ :repo/cloning? false
|
|
|
|
|
+ :repo/loading-files? nil
|
|
|
|
|
+ :repo/importing-to-db? nil
|
|
|
|
|
+ :repo/sync-status {}
|
|
|
|
|
+ :repo/changed-files nil
|
|
|
|
|
+ :nfs/user-granted? {}
|
|
|
|
|
+ :nfs/refreshing? nil
|
|
|
|
|
+ :instrument/disabled? (storage/get "instrument-disabled")
|
|
|
|
|
+ ;; TODO: how to detect the network reliably?
|
|
|
|
|
+ :network/online? true
|
|
|
|
|
+ :indexeddb/support? true
|
|
|
|
|
+ :me nil
|
|
|
|
|
+ :git/current-repo (storage/get :git/current-repo)
|
|
|
|
|
+ :git/status {}
|
|
|
|
|
+ :format/loading {}
|
|
|
|
|
+ :draw? false
|
|
|
|
|
+ :db/restoring? nil
|
|
|
|
|
+
|
|
|
|
|
+ :journals-length 2
|
|
|
|
|
+
|
|
|
|
|
+ :search/q ""
|
|
|
|
|
+ :search/mode :global
|
|
|
|
|
+ :search/result nil
|
|
|
|
|
+
|
|
|
|
|
+ ;; modals
|
|
|
|
|
+ :modal/show? false
|
|
|
|
|
+
|
|
|
|
|
+ ;; right sidebar
|
|
|
|
|
+ :ui/settings-open? false
|
|
|
|
|
+ :ui/sidebar-open? false
|
|
|
|
|
+ :ui/left-sidebar-open? false
|
|
|
|
|
+ :ui/theme (or (storage/get :ui/theme) "dark")
|
|
|
|
|
+ :ui/system-theme? ((fnil identity (or util/mac? util/win32? false)) (storage/get :ui/system-theme?))
|
|
|
|
|
+ :ui/wide-mode? false
|
|
|
|
|
+ ;; :show-all, :hide-block-body, :hide-block-children
|
|
|
|
|
+ :ui/cycle-collapse :show-all
|
|
|
|
|
+ :ui/sidebar-collapsed-blocks {}
|
|
|
|
|
+ :ui/root-component nil
|
|
|
|
|
+ :ui/file-component nil
|
|
|
|
|
+ :ui/custom-query-components {}
|
|
|
|
|
+ :ui/show-recent? false
|
|
|
|
|
+ :ui/developer-mode? (or (= (storage/get "developer-mode") "true")
|
|
|
|
|
+ false)
|
|
|
|
|
+ ;; remember scroll positions of visited paths
|
|
|
|
|
+ :ui/paths-scroll-positions {}
|
|
|
|
|
+
|
|
|
|
|
+ :document/mode? document-mode?
|
|
|
|
|
+
|
|
|
|
|
+ :github/contents {}
|
|
|
|
|
+ :config {}
|
|
|
|
|
+ :block/component-editing-mode? false
|
|
|
|
|
+ :editor/draw-mode? false
|
|
|
|
|
+ :editor/show-page-search? false
|
|
|
|
|
+ :editor/show-page-search-hashtag? false
|
|
|
|
|
+ :editor/show-date-picker? false
|
|
|
|
|
+ ;; With label or other data
|
|
|
|
|
+ :editor/show-input nil
|
|
|
|
|
+ :editor/last-saved-cursor nil
|
|
|
|
|
+ :editor/editing? nil
|
|
|
|
|
+ :editor/last-edit-block-input-id nil
|
|
|
|
|
+ :editor/last-edit-block-id nil
|
|
|
|
|
+ :editor/in-composition? false
|
|
|
|
|
+ :editor/content {}
|
|
|
|
|
+ :editor/block nil
|
|
|
|
|
+ :editor/block-dom-id nil
|
|
|
|
|
+ :editor/set-timestamp-block nil
|
|
|
|
|
+ :editor/last-input-time nil
|
|
|
|
|
+ :editor/new-block-toggle? document-mode?
|
|
|
|
|
+ :editor/args nil
|
|
|
|
|
+ :db/last-transact-time {}
|
|
|
|
|
+ :db/last-persist-transact-ids {}
|
|
|
|
|
+ ;; whether database is persisted
|
|
|
|
|
+ :db/persisted? {}
|
|
|
|
|
+ :db/latest-txs (or (storage/get-transit :db/latest-txs) {})
|
|
|
|
|
+ :cursor-range nil
|
|
|
|
|
+
|
|
|
|
|
+ :selection/mode false
|
|
|
|
|
+ :selection/blocks []
|
|
|
|
|
+ :selection/start-block nil
|
|
|
|
|
+ ;; either :up or :down, defaults to down
|
|
|
|
|
+ ;; used to determine selection direction when two or more blocks are selected
|
|
|
|
|
+ :selection/direction :down
|
|
|
|
|
+ :custom-context-menu/show? false
|
|
|
|
|
+ :custom-context-menu/links nil
|
|
|
|
|
+
|
|
|
|
|
+ ;; pages or blocks in the right sidebar
|
|
|
|
|
+ ;; It is a list of `[repo db-id block-type block-data]` 4-tuple
|
|
|
|
|
+ :sidebar/blocks '()
|
|
|
|
|
+
|
|
|
|
|
+ :preferred-language (storage/get :preferred-language)
|
|
|
|
|
+
|
|
|
|
|
+ ;; electron
|
|
|
|
|
+ :electron/updater-pending? false
|
|
|
|
|
+ :electron/updater {}
|
|
|
|
|
+
|
|
|
|
|
+ ;; plugin
|
|
|
|
|
+ :plugin/indicator-text nil
|
|
|
|
|
+ :plugin/installed-plugins {}
|
|
|
|
|
+ :plugin/installed-themes []
|
|
|
|
|
+ :plugin/installed-commands {}
|
|
|
|
|
+ :plugin/simple-commands {}
|
|
|
|
|
+ :plugin/selected-theme nil
|
|
|
|
|
+ :plugin/selected-unpacked-pkg nil
|
|
|
|
|
+ :plugin/active-readme nil
|
|
|
|
|
+
|
|
|
|
|
+ ;; all notification contents as k-v pairs
|
|
|
|
|
+ :notification/contents {}
|
|
|
|
|
+ :graph/syncing? false
|
|
|
|
|
+
|
|
|
|
|
+ ;; copied blocks
|
|
|
|
|
+ :copy/blocks {:copy/content nil :copy/block-tree nil}
|
|
|
|
|
+
|
|
|
|
|
+ :date-picker/date nil
|
|
|
|
|
+
|
|
|
|
|
+ :view/components {}})))
|
|
|
|
|
|
|
|
(defn get-route-match
|
|
(defn get-route-match
|
|
|
[]
|
|
[]
|
|
@@ -155,8 +155,8 @@
|
|
|
(defn get-current-page
|
|
(defn get-current-page
|
|
|
[]
|
|
[]
|
|
|
(when (= :page (get-current-route))
|
|
(when (= :page (get-current-route))
|
|
|
- (get-in (get-route-match)
|
|
|
|
|
- [:path-params :name])))
|
|
|
|
|
|
|
+ (get-in (get-route-match)
|
|
|
|
|
+ [:path-params :name])))
|
|
|
|
|
|
|
|
(defn route-has-p?
|
|
(defn route-has-p?
|
|
|
[]
|
|
[]
|
|
@@ -899,18 +899,12 @@
|
|
|
[value]
|
|
[value]
|
|
|
(set-state! :today value))
|
|
(set-state! :today value))
|
|
|
|
|
|
|
|
-(defn toggle-document-mode!
|
|
|
|
|
- []
|
|
|
|
|
- (let [mode (get @state :document/mode?)]
|
|
|
|
|
- (set-state! :document/mode? (not mode))
|
|
|
|
|
- (storage/set :document/mode? (not mode))))
|
|
|
|
|
-
|
|
|
|
|
(defn get-date-formatter
|
|
(defn get-date-formatter
|
|
|
[]
|
|
[]
|
|
|
(or
|
|
(or
|
|
|
(when-let [repo (get-current-repo)]
|
|
(when-let [repo (get-current-repo)]
|
|
|
(get-in @state [:config repo :date-formatter]))
|
|
(get-in @state [:config repo :date-formatter]))
|
|
|
- ;; TODO:
|
|
|
|
|
|
|
+ ;; TODO:
|
|
|
(get-in @state [:me :settings :date-formatter])
|
|
(get-in @state [:me :settings :date-formatter])
|
|
|
"MMM do, yyyy"))
|
|
"MMM do, yyyy"))
|
|
|
|
|
|
|
@@ -1055,6 +1049,13 @@
|
|
|
[]
|
|
[]
|
|
|
(update-state! :editor/new-block-toggle? not))
|
|
(update-state! :editor/new-block-toggle? not))
|
|
|
|
|
|
|
|
|
|
+(defn toggle-document-mode!
|
|
|
|
|
+ []
|
|
|
|
|
+ (let [mode (get @state :document/mode?)]
|
|
|
|
|
+ (set-state! :document/mode? (not mode))
|
|
|
|
|
+ (storage/set :document/mode? (not mode)))
|
|
|
|
|
+ (toggle-new-block-shortcut!))
|
|
|
|
|
+
|
|
|
(defn enable-tooltip?
|
|
(defn enable-tooltip?
|
|
|
[]
|
|
[]
|
|
|
(get (get (sub-config) (get-current-repo))
|
|
(get (get (sub-config) (get-current-repo))
|
|
@@ -1114,12 +1115,6 @@
|
|
|
(filterv #(= (keyword (first %)) (keyword type))
|
|
(filterv #(= (keyword (first %)) (keyword type))
|
|
|
(apply concat (vals (:plugin/simple-commands @state)))))
|
|
(apply concat (vals (:plugin/simple-commands @state)))))
|
|
|
|
|
|
|
|
-(defn get-plugins-ui-items-with-type
|
|
|
|
|
- [type]
|
|
|
|
|
- (filterv #(= (keyword (first %)) (keyword type))
|
|
|
|
|
- (apply concat (vals (:plugin/installed-ui-items @state)))))
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
(defn get-scheduled-future-days
|
|
(defn get-scheduled-future-days
|
|
|
[]
|
|
[]
|
|
|
(let [days (:scheduled/future-days (get-config))]
|
|
(let [days (:scheduled/future-days (get-config))]
|
|
@@ -1183,7 +1178,7 @@
|
|
|
(when-let [last-time (get-in @state [:editor/last-input-time repo])]
|
|
(when-let [last-time (get-in @state [:editor/last-input-time repo])]
|
|
|
(let [now (util/time-ms)]
|
|
(let [now (util/time-ms)]
|
|
|
(>= (- now last-time) 500)))
|
|
(>= (- now last-time) 500)))
|
|
|
- ;; not in editing mode
|
|
|
|
|
|
|
+ ;; not in editing mode
|
|
|
(not (get-edit-input-id)))))
|
|
(not (get-edit-input-id)))))
|
|
|
|
|
|
|
|
(defn set-last-persist-transact-id!
|
|
(defn set-last-persist-transact-id!
|