Browse Source

fix: block marker lost in file graph

fixes LOG-2964
Tienson Qin 1 năm trước cách đây
mục cha
commit
82d5fc6c00

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

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

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

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

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

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

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

@@ -14,7 +14,7 @@
   (-get-left [this conn])
   (-get-left [this conn])
   (-get-right [this conn])
   (-get-right [this conn])
   (-get-down [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])
   (-del [this db children? conn])
   (-get-children [this conn]))
   (-get-children [this conn]))
 
 

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

@@ -195,7 +195,7 @@
    {:outliner-op :save-block}
    {:outliner-op :save-block}
    (doseq [block-id block-ids]
    (doseq [block-id block-ids]
      (when-let [block (set-heading-aux! block-id heading)]
      (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!
 (defn set-blocks-id!
   "Persist block uuid to file if the uuid is valid, and it's not persisted in file.
   "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-order property-ks
                          :block/properties-text-values properties-text-values
                          :block/properties-text-values properties-text-values
                          :block/content content}]
                          :block/content content}]
-              (outliner-op/save-block! block))))))
+              (outliner-op/save-block! block {:retract-attributes? false}))))))
      (let [block-id (ffirst col)
      (let [block-id (ffirst col)
            block-id (if (string? block-id) (uuid block-id) block-id)
            block-id (if (string? block-id) (uuid block-id) block-id)
            input-pos (or (state/get-edit-pos) :max)]
            input-pos (or (state/get-edit-pos) :max)]

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

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