|
@@ -53,7 +53,10 @@
|
|
|
[goog.object :as gobj]
|
|
[goog.object :as gobj]
|
|
|
[lambdaisland.glogi :as log]
|
|
[lambdaisland.glogi :as log]
|
|
|
[medley.core :as medley]
|
|
[medley.core :as medley]
|
|
|
- [promesa.core :as p]))
|
|
|
|
|
|
|
+ [promesa.core :as p]
|
|
|
|
|
+ [frontend.util.keycode :as keycode]
|
|
|
|
|
+ [logseq.graph-parser.util :as gp-util]
|
|
|
|
|
+ ["path" :as path]))
|
|
|
|
|
|
|
|
;; FIXME: should support multiple images concurrently uploading
|
|
;; FIXME: should support multiple images concurrently uploading
|
|
|
|
|
|
|
@@ -256,7 +259,7 @@
|
|
|
(defn- another-block-with-same-id-exists?
|
|
(defn- another-block-with-same-id-exists?
|
|
|
[current-id block-id]
|
|
[current-id block-id]
|
|
|
(and (string? block-id)
|
|
(and (string? block-id)
|
|
|
- (util/uuid-string? block-id)
|
|
|
|
|
|
|
+ (gp-util/uuid-string? block-id)
|
|
|
(not= current-id (cljs.core/uuid block-id))
|
|
(not= current-id (cljs.core/uuid block-id))
|
|
|
(db/entity [:block/uuid (cljs.core/uuid block-id)])))
|
|
(db/entity [:block/uuid (cljs.core/uuid block-id)])))
|
|
|
|
|
|
|
@@ -337,7 +340,7 @@
|
|
|
(if (and (state/enable-timetracking?)
|
|
(if (and (state/enable-timetracking?)
|
|
|
(not= (:block/content block) value))
|
|
(not= (:block/content block) value))
|
|
|
(let [format (:block/format block)
|
|
(let [format (:block/format block)
|
|
|
- new-marker (last (util/safe-re-find (marker/marker-pattern format) (or value "")))
|
|
|
|
|
|
|
+ new-marker (last (gp-util/safe-re-find (marker/marker-pattern format) (or value "")))
|
|
|
new-value (with-marker-time value block format
|
|
new-value (with-marker-time value block format
|
|
|
new-marker
|
|
new-marker
|
|
|
(:block/marker block))]
|
|
(:block/marker block))]
|
|
@@ -481,10 +484,10 @@
|
|
|
(let [current-page (state/get-current-page)
|
|
(let [current-page (state/get-current-page)
|
|
|
block-id (or
|
|
block-id (or
|
|
|
(and (:id config)
|
|
(and (:id config)
|
|
|
- (util/uuid-string? (:id config))
|
|
|
|
|
|
|
+ (gp-util/uuid-string? (:id config))
|
|
|
(:id config))
|
|
(:id config))
|
|
|
(and current-page
|
|
(and current-page
|
|
|
- (util/uuid-string? current-page)
|
|
|
|
|
|
|
+ (gp-util/uuid-string? current-page)
|
|
|
current-page))]
|
|
current-page))]
|
|
|
(= uuid (and block-id (medley/uuid block-id)))))
|
|
(= uuid (and block-id (medley/uuid block-id)))))
|
|
|
|
|
|
|
@@ -1143,7 +1146,7 @@
|
|
|
[]
|
|
[]
|
|
|
(when-let [page (get-nearest-page)]
|
|
(when-let [page (get-nearest-page)]
|
|
|
(let [page-name (string/lower-case page)
|
|
(let [page-name (string/lower-case page)
|
|
|
- block? (util/uuid-string? page-name)]
|
|
|
|
|
|
|
+ block? (gp-util/uuid-string? page-name)]
|
|
|
(when-let [page (db/get-page page-name)]
|
|
(when-let [page (db/get-page page-name)]
|
|
|
(if block?
|
|
(if block?
|
|
|
(state/sidebar-add-block!
|
|
(state/sidebar-add-block!
|
|
@@ -1175,7 +1178,7 @@
|
|
|
(let [page (state/get-current-page)
|
|
(let [page (state/get-current-page)
|
|
|
block-id (and
|
|
block-id (and
|
|
|
(string? page)
|
|
(string? page)
|
|
|
- (util/uuid-string? page)
|
|
|
|
|
|
|
+ (gp-util/uuid-string? page)
|
|
|
(medley/uuid page))]
|
|
(medley/uuid page))]
|
|
|
(when block-id
|
|
(when block-id
|
|
|
(let [block-parent (db/get-block-parent block-id)]
|
|
(let [block-parent (db/get-block-parent block-id)]
|
|
@@ -1296,7 +1299,7 @@
|
|
|
elem (and input-id (gdom/getElement input-id))
|
|
elem (and input-id (gdom/getElement input-id))
|
|
|
db-content (:block/content db-block)
|
|
db-content (:block/content db-block)
|
|
|
db-content-without-heading (and db-content
|
|
db-content-without-heading (and db-content
|
|
|
- (util/safe-subs db-content (:block/level db-block)))
|
|
|
|
|
|
|
+ (gp-util/safe-subs db-content (:block/level db-block)))
|
|
|
value (and elem (gobj/get elem "value"))]
|
|
value (and elem (gobj/get elem "value"))]
|
|
|
(cond
|
|
(cond
|
|
|
force?
|
|
force?
|
|
@@ -1764,7 +1767,7 @@
|
|
|
edit-content (or (state/sub [:editor/content id]) "")]
|
|
edit-content (or (state/sub [:editor/content id]) "")]
|
|
|
(or
|
|
(or
|
|
|
@*selected-text
|
|
@*selected-text
|
|
|
- (util/safe-subs edit-content pos current-pos))))))
|
|
|
|
|
|
|
+ (gp-util/safe-subs edit-content pos current-pos))))))
|
|
|
|
|
|
|
|
(defn close-autocomplete-if-outside
|
|
(defn close-autocomplete-if-outside
|
|
|
[input]
|
|
[input]
|
|
@@ -1777,7 +1780,7 @@
|
|
|
(let [value (gobj/get input "value")
|
|
(let [value (gobj/get input "value")
|
|
|
pos (state/get-editor-last-pos)
|
|
pos (state/get-editor-last-pos)
|
|
|
current-pos (cursor/pos input)
|
|
current-pos (cursor/pos input)
|
|
|
- between (util/safe-subs value (min pos current-pos) (max pos current-pos))]
|
|
|
|
|
|
|
+ between (gp-util/safe-subs value (min pos current-pos) (max pos current-pos))]
|
|
|
(when (and between
|
|
(when (and between
|
|
|
(or
|
|
(or
|
|
|
(string/includes? between "[")
|
|
(string/includes? between "[")
|
|
@@ -2038,7 +2041,7 @@
|
|
|
(defn- last-top-level-child?
|
|
(defn- last-top-level-child?
|
|
|
[{:keys [id]} current-node]
|
|
[{:keys [id]} current-node]
|
|
|
(when id
|
|
(when id
|
|
|
- (when-let [entity (if (util/uuid-string? (str id))
|
|
|
|
|
|
|
+ (when-let [entity (if (gp-util/uuid-string? (str id))
|
|
|
(db/entity [:block/uuid (uuid id)])
|
|
(db/entity [:block/uuid (uuid id)])
|
|
|
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
|
|
(db/entity [:block/name (util/page-name-sanity-lc id)]))]
|
|
|
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
|
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
|
@@ -2852,7 +2855,7 @@
|
|
|
(string/join "\n"
|
|
(string/join "\n"
|
|
|
(mapv (fn [p] (->> (string/trim p)
|
|
(mapv (fn [p] (->> (string/trim p)
|
|
|
((fn [p]
|
|
((fn [p]
|
|
|
- (if (util/safe-re-find (if (= format :org)
|
|
|
|
|
|
|
+ (if (gp-util/safe-re-find (if (= format :org)
|
|
|
#"\s*\*+\s+"
|
|
#"\s*\*+\s+"
|
|
|
#"\s*-\s+") p)
|
|
#"\s*-\s+") p)
|
|
|
p
|
|
p
|
|
@@ -2915,9 +2918,9 @@
|
|
|
;; from external
|
|
;; from external
|
|
|
(let [format (or (db/get-page-format (state/get-current-page)) :markdown)]
|
|
(let [format (or (db/get-page-format (state/get-current-page)) :markdown)]
|
|
|
(match [format
|
|
(match [format
|
|
|
- (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))]
|
|
|
|
|
|
|
+ (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))]
|
|
|
[:markdown false _ _]
|
|
[:markdown false _ _]
|
|
|
(paste-text-parseable format text)
|
|
(paste-text-parseable format text)
|
|
|
|
|
|
|
@@ -3202,7 +3205,7 @@
|
|
|
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
|
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
|
|
(when-let [page (or (state/get-current-page)
|
|
(when-let [page (or (state/get-current-page)
|
|
|
(date/today))]
|
|
(date/today))]
|
|
|
- (let [block? (util/uuid-string? page)
|
|
|
|
|
|
|
+ (let [block? (gp-util/uuid-string? page)
|
|
|
block-id (or root-block (and block? (uuid page)))
|
|
block-id (or root-block (and block? (uuid page)))
|
|
|
blocks (if block-id
|
|
blocks (if block-id
|
|
|
(db/get-block-and-children (state/get-current-repo) block-id)
|
|
(db/get-block-and-children (state/get-current-repo) block-id)
|