mirror of
https://github.com/logseq/logseq.git
synced 2026-05-02 09:56:31 +00:00
Merge branch 'master' into gesture-support-on-block
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
[medley.core :as medley]
|
||||
[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
|
||||
@@ -157,13 +158,12 @@
|
||||
(defn open-block-in-sidebar!
|
||||
[block-id]
|
||||
(when block-id
|
||||
(when-let [block (db/pull [:block/uuid block-id])]
|
||||
(when-let [block (db/entity [:block/uuid block-id])]
|
||||
(let [page? (nil? (:block/page block))]
|
||||
(state/sidebar-add-block!
|
||||
(state/get-current-repo)
|
||||
(:db/id block)
|
||||
(if page? :page :block)
|
||||
block)))))
|
||||
(if page? :page :block))))))
|
||||
|
||||
(defn reset-cursor-range!
|
||||
[node]
|
||||
@@ -255,7 +255,7 @@
|
||||
(defn- another-block-with-same-id-exists?
|
||||
[current-id 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))
|
||||
(db/entity [:block/uuid (cljs.core/uuid block-id)])))
|
||||
|
||||
@@ -336,7 +336,7 @@
|
||||
(if (and (state/enable-timetracking?)
|
||||
(not= (:block/content block) value))
|
||||
(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-marker
|
||||
(:block/marker block))]
|
||||
@@ -453,11 +453,12 @@
|
||||
(declare save-current-block!)
|
||||
(defn outliner-insert-block!
|
||||
[config current-block new-block {:keys [sibling? keep-uuid? replace-empty-target?]}]
|
||||
(let [ref-top-block? (and (:ref? config)
|
||||
(not (:ref-child? config)))
|
||||
(let [ref-query-top-block? (and (or (:ref? config)
|
||||
(:custom-query? config))
|
||||
(not (:ref-query-child? config)))
|
||||
has-children? (db/has-children? (:block/uuid current-block))
|
||||
sibling? (cond
|
||||
ref-top-block?
|
||||
ref-query-top-block?
|
||||
false
|
||||
|
||||
(boolean? sibling?)
|
||||
@@ -480,10 +481,10 @@
|
||||
(let [current-page (state/get-current-page)
|
||||
block-id (or
|
||||
(and (:id config)
|
||||
(util/uuid-string? (:id config))
|
||||
(gp-util/uuid-string? (:id config))
|
||||
(:id config))
|
||||
(and current-page
|
||||
(util/uuid-string? current-page)
|
||||
(gp-util/uuid-string? current-page)
|
||||
current-page))]
|
||||
(= uuid (and block-id (medley/uuid block-id)))))
|
||||
|
||||
@@ -657,12 +658,12 @@
|
||||
new-block))))))
|
||||
|
||||
(defn insert-first-page-block-if-not-exists!
|
||||
([page-name]
|
||||
(insert-first-page-block-if-not-exists! page-name {}))
|
||||
([page-name opts]
|
||||
(when (and (string? page-name)
|
||||
(not (string/blank? page-name)))
|
||||
(state/pub-event! [:page/create page-name opts]))))
|
||||
([page-title]
|
||||
(insert-first-page-block-if-not-exists! page-title {}))
|
||||
([page-title opts]
|
||||
(when (and (string? page-title)
|
||||
(not (string/blank? page-title)))
|
||||
(state/pub-event! [:page/create page-title opts]))))
|
||||
|
||||
(defn properties-block
|
||||
[properties format page]
|
||||
@@ -1140,19 +1141,17 @@
|
||||
[]
|
||||
(when-let [page (get-nearest-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)]
|
||||
(if block?
|
||||
(state/sidebar-add-block!
|
||||
(state/get-current-repo)
|
||||
(:db/id page)
|
||||
:block
|
||||
page)
|
||||
:block)
|
||||
(state/sidebar-add-block!
|
||||
(state/get-current-repo)
|
||||
(:db/id page)
|
||||
:page
|
||||
{:page page}))))))
|
||||
:page))))))
|
||||
|
||||
(defn zoom-in! []
|
||||
(if (state/editing?)
|
||||
@@ -1172,7 +1171,7 @@
|
||||
(let [page (state/get-current-page)
|
||||
block-id (and
|
||||
(string? page)
|
||||
(util/uuid-string? page)
|
||||
(gp-util/uuid-string? page)
|
||||
(medley/uuid page))]
|
||||
(when block-id
|
||||
(let [block-parent (db/get-block-parent block-id)]
|
||||
@@ -1293,7 +1292,7 @@
|
||||
elem (and input-id (gdom/getElement input-id))
|
||||
db-content (:block/content db-block)
|
||||
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"))]
|
||||
(cond
|
||||
force?
|
||||
@@ -1760,7 +1759,7 @@
|
||||
edit-content (or (state/sub [:editor/content id]) "")]
|
||||
(or
|
||||
@*selected-text
|
||||
(util/safe-subs edit-content pos current-pos))))))
|
||||
(gp-util/safe-subs edit-content pos current-pos))))))
|
||||
|
||||
(defn close-autocomplete-if-outside
|
||||
[input]
|
||||
@@ -1773,7 +1772,7 @@
|
||||
(let [value (gobj/get input "value")
|
||||
pos (state/get-editor-last-pos)
|
||||
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
|
||||
(or
|
||||
(string/includes? between "[")
|
||||
@@ -2034,7 +2033,7 @@
|
||||
(defn- last-top-level-child?
|
||||
[{:keys [id]} current-node]
|
||||
(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/name (util/page-name-sanity-lc id)]))]
|
||||
(= (:block/uuid entity) (tree/-get-parent-id current-node)))))
|
||||
@@ -2861,7 +2860,7 @@
|
||||
(string/join "\n"
|
||||
(mapv (fn [p] (->> (string/trim p)
|
||||
((fn [p]
|
||||
(if (util/safe-re-find (if (= format :org)
|
||||
(if (gp-util/safe-re-find (if (= format :org)
|
||||
#"\s*\*+\s+"
|
||||
#"\s*-\s+") p)
|
||||
p
|
||||
@@ -2883,11 +2882,13 @@
|
||||
[text e]
|
||||
(let [copied-blocks (state/get-copied-blocks)
|
||||
copied-block-ids (:copy/block-ids copied-blocks)
|
||||
copied-graph (:copy/graph copied-blocks)
|
||||
input (state/get-input)
|
||||
*stop-event? (atom true)]
|
||||
(cond
|
||||
;; Internal blocks by either copy or cut blocks
|
||||
(and
|
||||
(= copied-graph (state/get-current-repo))
|
||||
(or (seq copied-block-ids)
|
||||
(seq (:copy/full-blocks copied-blocks)))
|
||||
text
|
||||
@@ -2924,9 +2925,9 @@
|
||||
;; from external
|
||||
(let [format (or (db/get-page-format (state/get-current-page)) :markdown)]
|
||||
(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 _ _]
|
||||
(paste-text-parseable format text)
|
||||
|
||||
@@ -3211,7 +3212,7 @@
|
||||
:or {collapse? false expanded? false incremental? true root-block nil}}]
|
||||
(when-let [page (or (state/get-current-page)
|
||||
(date/today))]
|
||||
(let [block? (util/uuid-string? page)
|
||||
(let [block? (gp-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)
|
||||
@@ -3473,12 +3474,11 @@
|
||||
1. References.
|
||||
2. Custom queries."
|
||||
[block config]
|
||||
(if (or (:ref? config)
|
||||
(:custom-query? config))
|
||||
(and
|
||||
(seq (:block/children block))
|
||||
(or
|
||||
(:custom-query? config)
|
||||
(>= (:ref/level block)
|
||||
(state/get-ref-open-blocks-level))))
|
||||
(util/collapsed? block)))
|
||||
(or
|
||||
(and
|
||||
(or (:ref? config) (:custom-query? config))
|
||||
(>= (inc (:block/level block))
|
||||
(state/get-ref-open-blocks-level))
|
||||
;; has children
|
||||
(first (:block/_parent (db/entity (:db/id block)))))
|
||||
(util/collapsed? block)))
|
||||
|
||||
Reference in New Issue
Block a user