Merge branch 'master' into disable-webview-resize

This commit is contained in:
llcc
2022-05-16 19:39:18 +08:00
committed by GitHub
65 changed files with 1347 additions and 1339 deletions

View File

@@ -55,7 +55,8 @@
[medley.core :as medley]
[promesa.core :as p]
[logseq.graph-parser.util :as gp-util]
[logseq.graph-parser.mldoc :as gp-mldoc]))
[logseq.graph-parser.mldoc :as gp-mldoc]
[logseq.graph-parser.block :as gp-block]))
;; FIXME: should support multiple images concurrently uploading
@@ -257,7 +258,7 @@
(defn- another-block-with-same-id-exists?
[current-id block-id]
(and (string? block-id)
(gp-util/uuid-string? block-id)
(util/uuid-string? block-id)
(not= current-id (cljs.core/uuid block-id))
(db/entity [:block/uuid (cljs.core/uuid block-id)])))
@@ -338,7 +339,7 @@
(if (and (state/enable-timetracking?)
(not= (:block/content block) value))
(let [format (:block/format block)
new-marker (last (gp-util/safe-re-find (marker/marker-pattern format) (or value "")))
new-marker (last (util/safe-re-find (marker/marker-pattern format) (or value "")))
new-value (with-marker-time value block format
new-marker
(:block/marker block))]
@@ -483,10 +484,10 @@
(let [current-page (state/get-current-page)
block-id (or
(and (:id config)
(gp-util/uuid-string? (:id config))
(util/uuid-string? (:id config))
(:id config))
(and current-page
(gp-util/uuid-string? current-page)
(util/uuid-string? current-page)
current-page))]
(= uuid (and block-id (medley/uuid block-id)))))
@@ -670,7 +671,9 @@
(defn properties-block
[properties format page]
(let [content (property/insert-properties format "" properties)
refs (block/get-page-refs-from-properties properties)]
refs (gp-block/get-page-refs-from-properties properties
(db/get-db (state/get-current-repo))
(state/get-date-formatter))]
{:block/pre-block? true
:block/uuid (db/new-block-id)
:block/properties properties
@@ -1145,7 +1148,7 @@
[]
(when-let [page (get-nearest-page)]
(let [page-name (string/lower-case page)
block? (gp-util/uuid-string? page-name)]
block? (util/uuid-string? page-name)]
(when-let [page (db/get-page page-name)]
(if block?
(state/sidebar-add-block!
@@ -1175,7 +1178,7 @@
(let [page (state/get-current-page)
block-id (and
(string? page)
(gp-util/uuid-string? page)
(util/uuid-string? page)
(medley/uuid page))]
(when block-id
(let [block-parent (db/get-block-parent block-id)]
@@ -1959,7 +1962,7 @@
(let [blocks (block-tree->blocks tree-vec format)
target-block (db/pull target-block-id)
page-id (:db/id (:block/page target-block))
blocks (block/with-parent-and-left page-id blocks)]
blocks (gp-block/with-parent-and-left page-id blocks)]
(paste-blocks
blocks
{:target-block target-block
@@ -2039,7 +2042,7 @@
(defn- last-top-level-child?
[{:keys [id]} current-node]
(when id
(when-let [entity (if (gp-util/uuid-string? (str id))
(when-let [entity (if (util/uuid-string? (str id))
(db/entity [:block/uuid (uuid id)])
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
@@ -2843,7 +2846,7 @@
(let [page-id (:db/id (:block/page editing-block))
blocks (block/extract-blocks
(mldoc/->edn text (gp-mldoc/default-config format)) text true format)
blocks' (block/with-parent-and-left page-id blocks)]
blocks' (gp-block/with-parent-and-left page-id blocks)]
(paste-blocks blocks' {}))))
(defn- paste-segmented-text
@@ -2853,7 +2856,7 @@
(string/join "\n"
(mapv (fn [p] (->> (string/trim p)
((fn [p]
(if (gp-util/safe-re-find (if (= format :org)
(if (util/safe-re-find (if (= format :org)
#"\s*\*+\s+"
#"\s*-\s+") p)
p
@@ -2918,9 +2921,9 @@
;; from external
(let [format (or (db/get-page-format (state/get-current-page)) :markdown)]
(match [format
(nil? (gp-util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text))
(nil? (gp-util/safe-re-find #"(?m)^\s*\*+\s+" text))
(nil? (gp-util/safe-re-find #"(?:\r?\n){2,}" text))]
(nil? (util/safe-re-find #"(?m)^\s*(?:[-+*]|#+)\s+" text))
(nil? (util/safe-re-find #"(?m)^\s*\*+\s+" text))
(nil? (util/safe-re-find #"(?:\r?\n){2,}" text))]
[:markdown false _ _]
(paste-text-parseable format text)
@@ -3205,7 +3208,7 @@
:or {collapse? false expanded? false incremental? true root-block nil}}]
(when-let [page (or (state/get-current-page)
(date/today))]
(let [block? (gp-util/uuid-string? page)
(let [block? (util/uuid-string? page)
block-id (or root-block (and block? (uuid page)))
blocks (if block-id
(db/get-block-and-children (state/get-current-repo) block-id)