|
|
@@ -887,9 +887,8 @@
|
|
|
|
|
|
(defn set-block-timestamp!
|
|
|
[block-id key value]
|
|
|
- (let [key (string/lower-case key)
|
|
|
+ (let [key (string/lower-case (str key))
|
|
|
block-id (if (string? block-id) (uuid block-id) block-id)
|
|
|
- key (string/lower-case (str key))
|
|
|
value (str value)]
|
|
|
(when-let [block (db/pull [:block/uuid block-id])]
|
|
|
(let [{:block/keys [content]} block
|
|
|
@@ -903,6 +902,20 @@
|
|
|
(state/set-edit-content! input-id new-content)
|
|
|
(save-block-if-changed! block new-content))))))))
|
|
|
|
|
|
+(defn set-editing-block-timestamp!
|
|
|
+ "Almost the same as set-block-timestamp! except for:
|
|
|
+ - it doesn't save the block
|
|
|
+ - it extracts current content from current input"
|
|
|
+ [key value]
|
|
|
+ (let [key (string/lower-case (str key))
|
|
|
+ value (str value)
|
|
|
+ content (state/get-edit-content)
|
|
|
+ new-content (-> (text-util/remove-timestamp content key)
|
|
|
+ (text-util/add-timestamp key value))]
|
|
|
+ (when (not= content new-content)
|
|
|
+ (let [input-id (state/get-edit-input-id)]
|
|
|
+ (state/set-edit-content! input-id new-content)))))
|
|
|
+
|
|
|
(defn set-blocks-id!
|
|
|
"Persist block uuid to file if the uuid is valid, and it's not persisted in file.
|
|
|
Accepts a list of uuids."
|