Merge branch 'master' into disable-webview-resize

This commit is contained in:
llcc
2022-05-10 17:12:14 +08:00
committed by GitHub
50 changed files with 904 additions and 292 deletions

View File

@@ -220,6 +220,8 @@
:file-sync/sync-state nil
:file-sync/sync-uploading-files nil
:file-sync/sync-downloading-files nil
:encryption/graph-parsing? false
})))
;; block uuid -> {content(String) -> ast}
@@ -753,12 +755,12 @@
(swap! state assoc :ui/sidebar-open? false))
(defn sidebar-add-block!
[repo db-id block-type block-data]
[repo db-id block-type]
(when (not (util/sm-breakpoint?))
(when db-id
(update-state! :sidebar/blocks (fn [blocks]
(->> (remove #(= (second %) db-id) blocks)
(cons [repo db-id block-type block-data])
(cons [repo db-id block-type])
(distinct))))
(open-right-sidebar!)
(when-let [elem (gdom/getElementByClass "cp__right-sidebar-scrollable")]
@@ -773,6 +775,13 @@
(when (empty? (:sidebar/blocks @state))
(hide-right-sidebar!)))
(defn sidebar-replace-block!
[old-sidebar-key new-sidebar-key]
(update-state! :sidebar/blocks (fn [blocks]
(map #(if (= % old-sidebar-key)
new-sidebar-key
%) blocks))))
(defn sidebar-block-exists?
[idx]
(some #(= (second %) idx) (:sidebar/blocks @state)))
@@ -1491,6 +1500,15 @@
[]
(get-in @state [:view/components :page-blocks]))
;; To avoid circular dependencies
(defn set-component!
[k value]
(set-state! [:view/components k] value))
(defn get-component
[k]
(get-in @state [:view/components k]))
(defn exit-editing-and-set-selected-blocks!
([blocks]
(exit-editing-and-set-selected-blocks! blocks :down))
@@ -1651,3 +1669,8 @@
(update-state! [:graph/parsing-state (get-current-repo)]
(if (fn? m) m
(fn [old-value] (merge old-value m)))))
(defn enable-encryption?
[repo]
(:feature/enable-encryption?
(get (sub-config) repo)))