Merge branch 'master' into gesture-support-on-block

This commit is contained in:
llcc
2022-05-12 09:58:53 +08:00
committed by GitHub
113 changed files with 2194 additions and 1126 deletions

View File

@@ -13,6 +13,7 @@
[goog.object :as gobj]
[promesa.core :as p]
[rum.core :as rum]
[logseq.graph-parser.util :as gp-util]
[frontend.mobile.util :as mobile-util]))
(defonce ^:large-vars/data-var state
@@ -184,7 +185,9 @@
:graph/parsing-state {}
;; copied blocks
:copy/blocks {:copy/content nil :copy/block-ids nil}
:copy/blocks {:copy/content nil
:copy/block-ids nil
:copy/graph nil}
:copy/export-block-text-indent-style (or (storage/get :copy/export-block-text-indent-style)
"dashes")
@@ -218,6 +221,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}
@@ -450,7 +455,7 @@
(or
(when-let [workflow (:preferred-workflow (get-config))]
(let [workflow (name workflow)]
(if (util/safe-re-find #"now|NOW" workflow)
(if (gp-util/safe-re-find #"now|NOW" workflow)
:now
:todo)))
(get-in @state [:me :preferred_workflow] :now))))
@@ -751,12 +756,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")]
@@ -771,6 +776,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)))
@@ -1420,13 +1432,15 @@
(defn set-copied-blocks
[content ids]
(set-state! :copy/blocks {:copy/content content
(set-state! :copy/blocks {:copy/graph (get-current-repo)
:copy/content content
:copy/block-ids ids
:copy/full-blocks nil}))
(defn set-copied-full-blocks
[content blocks]
(set-state! :copy/blocks {:copy/content content
(set-state! :copy/blocks {:copy/graph (get-current-repo)
:copy/content content
:copy/full-blocks blocks}))
(defn set-copied-full-blocks!
@@ -1493,6 +1507,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))
@@ -1661,3 +1684,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)))