mirror of https://github.com/logseq/logseq
Only remove heading patterns when there're followed spaces
Resolved https://github.com/logseq/logseq/issues/523pull/645/head
parent
34dae70d5a
commit
63df7efbff
|
@ -1283,7 +1283,7 @@
|
||||||
[{:keys [format block id repo dummy?] :as state} value]
|
[{:keys [format block id repo dummy?] :as state} value]
|
||||||
(when (or (:db/id (db/entity repo [:block/uuid (:block/uuid block)]))
|
(when (or (:db/id (db/entity repo [:block/uuid (:block/uuid block)]))
|
||||||
dummy?)
|
dummy?)
|
||||||
(let [value (text/remove-level-spaces value format)
|
(let [value (text/remove-level-spaces value format true)
|
||||||
new-value (block/with-levels value format block)]
|
new-value (block/with-levels value format block)]
|
||||||
(let [cache [(:block/uuid block) value]]
|
(let [cache [(:block/uuid block) value]]
|
||||||
(when (not= @*last-edit-block cache)
|
(when (not= @*last-edit-block cache)
|
||||||
|
|
|
@ -6,13 +6,17 @@
|
||||||
[frontend.db :as db]))
|
[frontend.db :as db]))
|
||||||
|
|
||||||
(defn remove-level-spaces
|
(defn remove-level-spaces
|
||||||
[text format]
|
([text format]
|
||||||
|
(remove-level-spaces text format false))
|
||||||
|
([text format space?]
|
||||||
(if-not (string/blank? text)
|
(if-not (string/blank? text)
|
||||||
(let [pattern (util/format
|
(let [pattern (util/format
|
||||||
"^[%s]+\\s?"
|
(if space?
|
||||||
|
"^[%s]+\\s+"
|
||||||
|
"^[%s]+\\s?")
|
||||||
(config/get-block-pattern format))]
|
(config/get-block-pattern format))]
|
||||||
(string/replace-first text (re-pattern pattern) ""))
|
(string/replace-first text (re-pattern pattern) ""))
|
||||||
""))
|
"")))
|
||||||
|
|
||||||
(defn append-newline-after-level-spaces
|
(defn append-newline-after-level-spaces
|
||||||
[text format]
|
[text format]
|
||||||
|
|
Loading…
Reference in New Issue