mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 10:26:35 +00:00
add util.property & move unit-tests
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
[frontend.extensions.html-parser :as html-parser]
|
||||
[medley.core :as medley]
|
||||
[frontend.text :as text]
|
||||
[frontend.util.property :as property]
|
||||
[frontend.date :as date]
|
||||
[frontend.handler.repeated :as repeated]
|
||||
[frontend.template :as template]
|
||||
@@ -225,7 +226,7 @@
|
||||
|
||||
:else
|
||||
(subs content 0 pos))
|
||||
content (text/remove-built-in-properties! (:block/format block)
|
||||
content (property/remove-built-in-properties! (:block/format block)
|
||||
content)]
|
||||
(clear-selection! nil)
|
||||
(state/set-editing! edit-input-id content block text-range move-cursor?))))))
|
||||
@@ -291,7 +292,7 @@
|
||||
properties (:block/properties block)
|
||||
real-content (:block/content block)
|
||||
content (if (and (seq properties) real-content (not= real-content content))
|
||||
(text/with-built-in-properties properties content format)
|
||||
(property/with-built-in-properties properties content format)
|
||||
content)
|
||||
first-block? (= left page)
|
||||
ast (mldoc/->edn (string/trim content) (mldoc/default-config format))
|
||||
@@ -326,7 +327,7 @@
|
||||
block (update block :block/refs remove-non-existed-refs!)
|
||||
block (attach-page-properties-if-exists! block)
|
||||
new-properties (merge
|
||||
(select-keys properties text/built-in-properties)
|
||||
(select-keys properties property/built-in-properties)
|
||||
(:block/properties block))]
|
||||
(-> block
|
||||
(dissoc :block/top?
|
||||
@@ -571,13 +572,14 @@
|
||||
(:block/properties block))
|
||||
value (or
|
||||
(when new-marker?
|
||||
(text/insert-property! (:block/format block)
|
||||
(property/insert-property! (:block/format block)
|
||||
value
|
||||
new-marker
|
||||
ts))
|
||||
value)]
|
||||
[properties value]))
|
||||
|
||||
|
||||
(defn insert-new-block!
|
||||
([state]
|
||||
(insert-new-block! state nil))
|
||||
@@ -636,7 +638,7 @@
|
||||
[content format marker]
|
||||
(if (state/enable-timetracking?)
|
||||
(let [marker (string/lower-case marker)]
|
||||
(text/insert-property! format content marker (util/time-ms)))
|
||||
(property/insert-property! format content marker (util/time-ms)))
|
||||
content))
|
||||
|
||||
(defn check
|
||||
@@ -816,8 +818,8 @@
|
||||
(assoc properties key value)
|
||||
(dissoc properties key))
|
||||
content (if value
|
||||
(text/insert-property! format content key value)
|
||||
(text/remove-property! format key content))
|
||||
(property/insert-property! format content key value)
|
||||
(property/remove-property! format key content))
|
||||
block (outliner-core/block {:block/uuid block-id
|
||||
:block/properties properties
|
||||
:block/content content})]
|
||||
@@ -1230,7 +1232,7 @@
|
||||
(defn- clean-content!
|
||||
[format content]
|
||||
(->> (text/remove-level-spaces content format)
|
||||
(text/remove-properties! format)
|
||||
(property/remove-properties! format)
|
||||
string/trim))
|
||||
|
||||
(defn insert-command!
|
||||
@@ -1897,8 +1899,8 @@
|
||||
[(:block/content %) (:block/title %)])
|
||||
new-content
|
||||
(->> new-content
|
||||
(text/remove-property! format "id")
|
||||
(text/remove-property! format "custom_id"))]
|
||||
(property/remove-property! format "id")
|
||||
(property/remove-property! format "custom_id"))]
|
||||
(conj {:block/uuid uuid
|
||||
:block/page (select-keys page [:db/id])
|
||||
:block/file (select-keys file [:db/id])
|
||||
@@ -1944,8 +1946,8 @@
|
||||
(paste-block-tree-at-point tree [:template :including-parent]
|
||||
(fn [content]
|
||||
(->> content
|
||||
(text/remove-property! format "template")
|
||||
(text/remove-property! format "including-parent")
|
||||
(property/remove-property! format "template")
|
||||
(property/remove-property! format "including-parent")
|
||||
template/resolve-dynamic-template!)))
|
||||
(clear-when-saved!)
|
||||
(insert-command! id "" format {})
|
||||
|
||||
Reference in New Issue
Block a user