Forráskód Böngészése

fix: page refs not saved in quick capture

Tienson Qin 2 hónapja
szülő
commit
0696a556d9

+ 11 - 9
deps/outliner/src/logseq/outliner/core.cljs

@@ -718,15 +718,17 @@
                        (if-let [eid (or (:db/id b)
                                         (when-let [id (:block/uuid b)]
                                           [:block/uuid id]))]
-                         (->
-                          (if-let [e (if (de/entity? b) b (d/entity db eid))]
-                            (merge
-                             (into {} e)
-                             {:db/id (:db/id e)
-                              :block/title (or (:block/raw-title e) (:block/title e))}
-                             b)
-                            b)
-                          (dissoc :block/tx-id :block/refs :block/path-refs))
+                         (let [b (if-let [e (if (de/entity? b) b (d/entity db eid))]
+                                   (merge
+                                    (into {} e)
+                                    {:db/id (:db/id e)
+                                     :block/title (or (:block/raw-title e) (:block/title e))}
+                                    b)
+                                   b)
+                               dissoc-keys (concat [:block/tx-id :block/path-refs]
+                                                   (when (contains? #{:insert-template-blocks :paste} outliner-op)
+                                                     [:block/refs]))]
+                           (apply dissoc b dissoc-keys))
                          b))
                      blocks)
         [target-block sibling?] (get-target-block db blocks target-block opts)

+ 22 - 22
src/main/frontend/handler/editor.cljs

@@ -597,31 +597,31 @@
                             (wrap-parse-block)
                             (assoc :block/uuid (or custom-uuid (db/new-block-id))))
               new-block (merge new-block other-attrs)
-              [block-m sibling?] (cond
-                                   before?
-                                   (let [left-or-parent (or (ldb/get-left-sibling block)
-                                                            (:block/parent block))
-                                         sibling? (if (= (:db/id (:block/parent block)) (:db/id left-or-parent))
-                                                    false sibling?)]
-                                     [left-or-parent sibling?])
-
-                                   sibling?
-                                   [(db/entity (:db/id block)) sibling?]
-
-                                   last-block
-                                   [last-block true]
-
-                                   block
-                                   [(db/entity (:db/id block)) sibling?]
-
-                                   ;; FIXME: assert
-                                   :else
-                                   nil)]
-          (when block-m
+              [target-block sibling?] (cond
+                                        before?
+                                        (let [left-or-parent (or (ldb/get-left-sibling block)
+                                                                 (:block/parent block))
+                                              sibling? (if (= (:db/id (:block/parent block)) (:db/id left-or-parent))
+                                                         false sibling?)]
+                                          [left-or-parent sibling?])
+
+                                        sibling?
+                                        [(db/entity (:db/id block)) sibling?]
+
+                                        last-block
+                                        [last-block true]
+
+                                        block
+                                        [(db/entity (:db/id block)) sibling?]
+
+                                        ;; FIXME: assert
+                                        :else
+                                        nil)]
+          (when target-block
             (p/do!
              (ui-outliner-tx/transact!
               {:outliner-op :insert-blocks}
-              (outliner-insert-block! config block-m new-block
+              (outliner-insert-block! config target-block new-block
                                       {:sibling? sibling?
                                        :keep-uuid? true
                                        :ordered-list? ordered-list?

+ 2 - 1
src/main/frontend/worker/pipeline.cljs

@@ -93,7 +93,8 @@
                                        (let [result (outliner-core/insert-blocks
                                                      repo db template-blocks object
                                                      {:sibling? false
-                                                      :keep-uuid? journal-template?})]
+                                                      :keep-uuid? journal-template?
+                                                      :outliner-op :insert-template-blocks})]
                                          (:tx-data result)))))))]
     tx-data))