Merge remote-tracking branch 'upstream/master' into whiteboards

This commit is contained in:
Peng Xiao
2022-06-07 10:52:11 +08:00
156 changed files with 4856 additions and 2203 deletions

View File

@@ -13,6 +13,7 @@
[goog.object :as gobj]
[promesa.core :as p]
[rum.core :as rum]
[logseq.graph-parser.config :as gp-config]
[frontend.mobile.util :as mobile-util]))
(defonce ^:large-vars/data-var state
@@ -26,6 +27,7 @@
:system/events (async/chan 100)
:db/batch-txs (async/chan 100)
:file/writes (async/chan 100)
:file/unlinked-dirs #{}
:reactive/custom-queries (async/chan 100)
:notification/show? false
:notification/content nil
@@ -145,7 +147,10 @@
:electron/user-cfgs nil
;; mobile
:mobile/show-action-bar? false
:mobile/actioned-block nil
:mobile/show-toolbar? false
:mobile/show-recording-bar? false
;;; toolbar icon doesn't update correctly when clicking after separate it from box,
;;; add a random in (<= 1000000) to observer its update
:mobile/toolbar-update-observer 0
@@ -174,7 +179,7 @@
:plugin/updates-downloading? false
:plugin/updates-unchecked #{}
:plugin/navs-settings? true
:plugin/focused-settings nil ;; plugin id
:plugin/focused-settings nil ;; plugin id
;; pdf
:pdf/current nil
@@ -566,21 +571,6 @@
[]
(sub [:editor/content (get-edit-input-id)]))
(defn append-current-edit-content!
[append-text]
(when-not (string/blank? append-text)
(when-let [input-id (get-edit-input-id)]
(when-let [input (gdom/getElement input-id)]
(let [value (gobj/get input "value")
new-value (str value append-text)
new-value (if (or (= (last value) " ")
(= (last value) "\n"))
new-value
(str "\n" new-value))]
(js/document.execCommand "insertText" false append-text)
(update-state! :editor/content (fn [m]
(assoc m input-id new-value))))))))
(defn get-cursor-range
[]
(:cursor-range @state))
@@ -858,7 +848,10 @@
(util/set-change-value input content))
(when move-cursor?
(cursor/move-cursor-to input pos))))))))
(cursor/move-cursor-to input pos))
(when (or (util/mobile?) (mobile-util/native-platform?))
(set-state! :mobile/show-action-bar? false))))))))
(defn clear-edit!
[]
@@ -1018,15 +1011,7 @@
(defn get-date-formatter
[]
(or
(when-let [repo (get-current-repo)]
(or
(get-in @state [:config repo :journal/page-title-format])
;; for compatibility
(get-in @state [:config repo :date-formatter])))
;; TODO:
(get-in @state [:me :settings :date-formatter])
"MMM do, yyyy"))
(gp-config/get-date-formatter (get-config)))
(defn shortcuts []
(get-in @state [:config (get-current-repo) :shortcuts]))
@@ -1455,7 +1440,7 @@
(defn set-copied-full-blocks
[content blocks]
(set-state! :copy/blocks {:copy/graph (get-current-repo)
:copy/content content
:copy/content (or content (get-in @state [:copy/blocks :copy/content]))
:copy/full-blocks blocks}))
(defn set-copied-full-blocks!