mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 03:16:37 +00:00
remove redundant ! on property-related funcs & add some tests
enter the commit message for your changes. Lines starting
This commit is contained in:
@@ -1392,7 +1392,7 @@
|
||||
(editor-handler/unhighlight-blocks!)
|
||||
(let [block (or (db/pull [:block/uuid (:block/uuid block)]) block)
|
||||
f #(let [cursor-range (util/caret-range (gdom/getElement block-id))
|
||||
content (property/remove-built-in-properties! (:block/format block)
|
||||
content (property/remove-built-in-properties (:block/format block)
|
||||
content)]
|
||||
(state/set-editing!
|
||||
edit-input-id
|
||||
|
||||
@@ -412,7 +412,7 @@
|
||||
(drop-while #(= ["Break_Line"] %)))]
|
||||
(recur headings (conj block-body ["Paragraph" other-body]) (rest blocks) timestamps' properties last-pos last-level children))
|
||||
|
||||
(property/properties-block? block)
|
||||
(property/properties-ast? block)
|
||||
(let [properties (extract-properties block start_pos end_pos)]
|
||||
(recur headings block-body (rest blocks) timestamps properties last-pos last-level children))
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
|
||||
(defn copy-to-clipboard-without-id-property!
|
||||
[format content]
|
||||
(util/copy-to-clipboard! (property/remove-id-property! format content)))
|
||||
(util/copy-to-clipboard! (property/remove-id-property format content)))
|
||||
|
||||
(defn config-with-document-mode
|
||||
[config]
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
|
||||
:else
|
||||
(subs content 0 pos))
|
||||
content (property/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?))))))
|
||||
@@ -572,7 +572,7 @@
|
||||
(:block/properties block))
|
||||
value (or
|
||||
(when new-marker?
|
||||
(property/insert-property! (:block/format block)
|
||||
(property/insert-property (:block/format block)
|
||||
value
|
||||
new-marker
|
||||
ts))
|
||||
@@ -638,7 +638,7 @@
|
||||
[content format marker]
|
||||
(if (state/enable-timetracking?)
|
||||
(let [marker (string/lower-case marker)]
|
||||
(property/insert-property! format content marker (util/time-ms)))
|
||||
(property/insert-property format content marker (util/time-ms)))
|
||||
content))
|
||||
|
||||
(defn check
|
||||
@@ -818,8 +818,8 @@
|
||||
(assoc properties key value)
|
||||
(dissoc properties key))
|
||||
content (if value
|
||||
(property/insert-property! format content key value)
|
||||
(property/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})]
|
||||
@@ -1232,7 +1232,7 @@
|
||||
(defn- clean-content!
|
||||
[format content]
|
||||
(->> (text/remove-level-spaces content format)
|
||||
(property/remove-properties! format)
|
||||
(property/remove-properties format)
|
||||
string/trim))
|
||||
|
||||
(defn insert-command!
|
||||
@@ -1899,8 +1899,8 @@
|
||||
[(:block/content %) (:block/title %)])
|
||||
new-content
|
||||
(->> new-content
|
||||
(property/remove-property! format "id")
|
||||
(property/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])
|
||||
@@ -1946,8 +1946,8 @@
|
||||
(paste-block-tree-at-point tree [:template :including-parent]
|
||||
(fn [content]
|
||||
(->> content
|
||||
(property/remove-property! format "template")
|
||||
(property/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 {})
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
ast (mldoc/->edn content
|
||||
(mldoc/default-config format))
|
||||
first-block (ffirst ast)
|
||||
properties (let [properties (and (property/properties-block? first-block)
|
||||
properties (let [properties (and (property/properties-ast? first-block)
|
||||
(->> (last first-block)
|
||||
(into {})
|
||||
(walk/keywordize-keys)))]
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
new-properties (assoc properties key value)
|
||||
content (:block/content pre-block)
|
||||
front-matter? (property/front-matter? content)
|
||||
new-content (property/insert-property! format content key value front-matter?)
|
||||
new-content (property/insert-property format content key value front-matter?)
|
||||
block {:db/id (:db/id pre-block)
|
||||
:block/properties new-properties
|
||||
:block/content new-content
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
(defn block->index
|
||||
[{:block/keys [uuid content format page] :as block}]
|
||||
(when-let [result (->> (text/remove-level-spaces content format)
|
||||
(property/remove-id-property! format))]
|
||||
(property/remove-id-property format))]
|
||||
{:id (:db/id block)
|
||||
:uuid (str uuid)
|
||||
:page page
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
(when-let [key (get-property-key line :org)]
|
||||
(not (contains? #{:PROPERTIES :END} key))))))
|
||||
|
||||
(defn remove-properties!
|
||||
(defn remove-properties
|
||||
[format content]
|
||||
(let [org? (= format :org)]
|
||||
(cond
|
||||
@@ -137,9 +137,9 @@
|
||||
[s]
|
||||
(string/starts-with? s "---\n"))
|
||||
|
||||
(defn insert-property!
|
||||
(defn insert-property
|
||||
([format content key value]
|
||||
(insert-property! format content key value false))
|
||||
(insert-property format content key value false))
|
||||
([format content key value front-matter?]
|
||||
(when (and (not (string/blank? (name key)))
|
||||
(not (string/blank? (str value))))
|
||||
@@ -207,9 +207,9 @@
|
||||
:else
|
||||
content)))))
|
||||
|
||||
(defn remove-property!
|
||||
(defn remove-property
|
||||
([format key content]
|
||||
(remove-property! format key content true))
|
||||
(remove-property format key content true))
|
||||
([format key content first?]
|
||||
(when (not (string/blank? (name key)))
|
||||
(let [format (or format :markdown)
|
||||
@@ -224,14 +224,14 @@
|
||||
(string/starts-with? s (str key ":: ")))))))]
|
||||
(string/join "\n" lines)))))))
|
||||
|
||||
(defn remove-id-property!
|
||||
(defn remove-id-property
|
||||
[format content]
|
||||
(remove-property! format "id" content false))
|
||||
(remove-property format "id" content false))
|
||||
|
||||
(defn remove-built-in-properties!
|
||||
(defn remove-built-in-properties
|
||||
[format content]
|
||||
(reduce (fn [content key]
|
||||
(remove-property! format key content)) content built-in-properties))
|
||||
(remove-property format key content)) content built-in-properties))
|
||||
|
||||
(defn ->new-properties
|
||||
"New syntax: key:: value"
|
||||
@@ -254,7 +254,7 @@
|
||||
content))
|
||||
content))
|
||||
|
||||
(defn add-page-properties!
|
||||
(defn add-page-properties
|
||||
[page-format properties-content properties]
|
||||
(let [properties (medley/map-keys name properties)
|
||||
lines (string/split-lines properties-content)
|
||||
@@ -294,7 +294,7 @@
|
||||
(config/properties-wrapper-pattern page-format)
|
||||
(string/join "\n" lines))))
|
||||
|
||||
(defn properties-block?
|
||||
(defn properties-ast?
|
||||
[block]
|
||||
(and
|
||||
(vector? block)
|
||||
|
||||
Reference in New Issue
Block a user