Browse Source

fix: block marker lost in file graph

fixes LOG-2964
Tienson Qin 1 year ago
parent
commit
82d5fc6c00

+ 0 - 5
deps/db/src/logseq/db/frontend/schema.cljs

@@ -153,11 +153,6 @@
 ;; If only block/content changes
 (def db-version-retract-attributes
   #{:block/refs
-    :block/marker
-    :block/priority
-    :block/scheduled
-    :block/deadline
-    :block/repeated?
     :block/macros
     :block/warning})
 

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

@@ -371,7 +371,8 @@
     (let [parent-id (otree/-get-id this conn)]
       (get-by-parent-&-left @conn parent-id parent-id)))
 
-  (-save [this txs-state conn repo date-formatter]
+  (-save [this txs-state conn repo date-formatter {:keys [retract-attributes?]
+                                                   :or {retract-attributes? true}}]
     (assert (ds/outliner-txs-state? txs-state)
             "db should be satisfied outliner-tx-state?")
     (let [data (:data this)
@@ -414,7 +415,7 @@
 
       (when eid
         ;; Retract attributes to prepare for tx which rewrites block attributes
-        (when (:block/content m)
+        (when (and retract-attributes? (:block/content m))
           (let [retract-attributes (if db-based?
                                      (conj db-schema/db-version-retract-attributes :block/tags)
                                      db-schema/retract-attributes)]
@@ -627,10 +628,10 @@
 
 (defn ^:api save-block
   "Save the `block`."
-  [repo conn date-formatter block']
+  [repo conn date-formatter block' opts]
   {:pre [(map? block')]}
   (let [txs-state (atom [])]
-    (otree/-save (block @conn block') txs-state conn repo date-formatter)
+    (otree/-save (block @conn block') txs-state conn repo date-formatter opts)
     {:tx-data @txs-state}))
 
 (defn- get-right-siblings
@@ -946,7 +947,7 @@
       (when (otree/satisfied-inode? right-node)
         (let [left-node (otree/-get-left node conn)
               new-right-node (otree/-set-left-id right-node (otree/-get-id left-node conn) conn)]
-          (otree/-save new-right-node txs-state conn repo date-formatter)))
+          (otree/-save new-right-node txs-state conn repo date-formatter {})))
       @txs-state)))
 
 (defn- ^:large-vars/cleanup-todo delete-blocks
@@ -1005,7 +1006,7 @@
                                     :right-node (d/entity @conn [:block/uuid (otree/-get-id right-node conn)])}))))
             (when left-node-id
               (let [new-right-node (otree/-set-left-id right-node left-node-id conn)]
-                (otree/-save new-right-node txs-state conn repo date-formatter)))))
+                (otree/-save new-right-node txs-state conn repo date-formatter {})))))
         (doseq [id block-ids]
           (let [node (block @conn (d/entity @conn id))]
             (otree/-del node txs-state true conn)))
@@ -1186,8 +1187,8 @@
     result))
 
 (defn save-block!
-  [repo conn date-formatter block]
-  (op-transact! #'save-block repo conn date-formatter block))
+  [repo conn date-formatter block & {:as opts}]
+  (op-transact! #'save-block repo conn date-formatter block opts))
 
 (defn insert-blocks!
   [repo conn blocks target-block opts]

+ 1 - 1
deps/outliner/src/logseq/outliner/op.cljs

@@ -10,7 +10,7 @@
    [:save-block
     [:catn
      [:op :keyword]
-     [:args [:tuple ::block]]]]
+     [:args [:tuple ::block ::option]]]]
    [:insert-blocks
     [:catn
      [:op :keyword]

+ 1 - 1
deps/outliner/src/logseq/outliner/tree.cljs

@@ -14,7 +14,7 @@
   (-get-left [this conn])
   (-get-right [this conn])
   (-get-down [this conn])
-  (-save [this txs-state conn repo date-formatter])
+  (-save [this txs-state conn repo date-formatter opts])
   (-del [this db children? conn])
   (-get-children [this conn]))
 

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

@@ -195,7 +195,7 @@
    {:outliner-op :save-block}
    (doseq [block-id block-ids]
      (when-let [block (set-heading-aux! block-id heading)]
-       (outliner-op/save-block! block)))))
+       (outliner-op/save-block! block {:retract-attributes? false})))))
 
 (defn set-blocks-id!
   "Persist block uuid to file if the uuid is valid, and it's not persisted in file.

+ 1 - 1
src/main/frontend/handler/file_based/property.cljs

@@ -55,7 +55,7 @@
                          :block/properties-order property-ks
                          :block/properties-text-values properties-text-values
                          :block/content content}]
-              (outliner-op/save-block! block))))))
+              (outliner-op/save-block! block {:retract-attributes? false}))))))
      (let [block-id (ffirst col)
            block-id (if (string? block-id) (uuid block-id) block-id)
            input-pos (or (state/get-edit-pos) :max)]

+ 4 - 4
src/main/frontend/modules/outliner/op.cljs

@@ -16,11 +16,11 @@
     result))
 
 (defn save-block
-  [block]
+  [block opts]
   (when-let [block' (if (de/entity? block)
                       (assoc (.-kv ^js block) :db/id (:db/id block))
                       block)]
-    [:save-block [block']]))
+    [:save-block [block' opts]]))
 
 (defn insert-blocks
   [blocks target-block opts]
@@ -49,8 +49,8 @@
     [:indent-outdent-blocks [ids indent? opts]]))
 
 (defn save-block!
-  [block]
-  (op-transact! #'save-block block))
+  [block & {:as opts}]
+  (op-transact! #'save-block block opts))
 
 (defn insert-blocks!
   [blocks target-block opts]