Quellcode durchsuchen

fix: preserve properties on update-block

clstb vor 2 Jahren
Ursprung
Commit
6e06057e7b
2 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen
  1. 8 1
      src/main/frontend/handler/editor.cljs
  2. 2 2
      src/main/logseq/api.cljs

+ 8 - 1
src/main/frontend/handler/editor.cljs

@@ -1231,10 +1231,17 @@
 
 (defn save-block!
   ([repo block-or-uuid content]
+    (save-block! repo block-or-uuid content {}))
+  ([repo block-or-uuid content {:keys [properties] :or {}}]
    (let [block (if (or (uuid? block-or-uuid)
                        (string? block-or-uuid))
                  (db-model/query-block-by-uuid block-or-uuid) block-or-uuid)]
-     (save-block! {:block block :repo repo} content)))
+     (save-block!
+       {:block block :repo repo}
+       (if (seq properties)
+          (property/insert-properties (:block/format block) content properties)
+        content)
+     )))
   ([{:keys [block repo] :as _state} value]
    (let [repo (or repo (state/get-current-repo))]
      (when (db/entity repo [:block/uuid (:block/uuid block)])

+ 2 - 2
src/main/logseq/api.cljs

@@ -652,13 +652,13 @@
       nil)))
 
 (def ^:export update_block
-  (fn [block-uuid content ^js _opts]
+  (fn [block-uuid content ^js opts]
     (let [repo       (state/get-current-repo)
           edit-input (state/get-edit-input-id)
           editing?   (and edit-input (string/ends-with? edit-input (str block-uuid)))]
       (if editing?
         (state/set-edit-content! edit-input content)
-        (editor-handler/save-block! repo (sdk-utils/uuid-or-throw-error block-uuid) content))
+        (editor-handler/save-block! repo (sdk-utils/uuid-or-throw-error block-uuid) content (bean/->clj opts)))
       nil)))
 
 (def ^:export move_block