Explorar o código

fix: set timestamp to another editing block

close https://github.com/logseq/logseq/issues/3783
llcc %!s(int64=3) %!d(string=hai) anos
pai
achega
03d8c8a8d2

+ 3 - 2
src/main/frontend/components/datetime.cljs

@@ -82,6 +82,7 @@
   (reset! *timestamp default-timestamp-value)
   (reset! *show-time? false)
   (reset! *show-repeater? false)
+  (state/set-timestamp-block! nil)
   (state/set-state! :date-picker/date nil))
 
 (defn- on-submit
@@ -95,8 +96,8 @@
         text (repeated/timestamp-map->text timestamp)
         block-data (state/get-timestamp-block)
         {:keys [block typ show?]} block-data
-        block-id (or (:block/uuid (state/get-edit-block))
-                     (:block/uuid block))
+        block-id (or (:block/uuid block)
+                     (:block/uuid (state/get-edit-block)))
         typ (or @commands/*current-command typ)]
     (editor-handler/set-block-timestamp! block-id
                                          typ

+ 6 - 4
src/main/frontend/handler/editor.cljs

@@ -1040,13 +1040,15 @@
         value (str value)]
     (when-let [block (db/pull [:block/uuid block-id])]
       (let [{:block/keys [content]} block
-            content (or (state/get-edit-content) content)
+            content (or content (state/get-edit-content))
             new-content (-> (text/remove-timestamp content key)
                             (text/add-timestamp key value))]
         (when (not= content new-content)
-          (if-let [input-id (state/get-edit-input-id)]
-            (state/set-edit-content! input-id new-content)
-            (save-block-if-changed! block new-content)))))))
+          (let [input-id (state/get-edit-input-id)]
+            (if (and input-id
+                     (string/ends-with? input-id (str block-id)))
+              (state/set-edit-content! input-id new-content)
+              (save-block-if-changed! block new-content))))))))
 
 (defn- set-blocks-id!
   [block-ids]