Browse Source

fix(ux): turn the block into ordered item when it's moved to the first item from target ordered children

charlie 2 years ago
parent
commit
f55ccda97e
2 changed files with 10 additions and 13 deletions
  1. 0 4
      src/main/frontend/handler/editor.cljs
  2. 10 9
      src/main/frontend/modules/outliner/core.cljs

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

@@ -79,10 +79,6 @@
   (when-let [uuid (:block/uuid block)]
     (remove-block-property! uuid :logseq.order-list-type)))
 
-(defn own-order-list?
-  [block]
-  (not (string/blank? (get-block-own-order-list-type block))))
-
 (defn own-order-number-list?
   [block]
   (= (get-block-own-order-list-type block) "number"))

+ 10 - 9
src/main/frontend/modules/outliner/core.cljs

@@ -411,15 +411,16 @@
 
 (defn blocks-with-?ordered-list-props
   [blocks target-block sibling?]
-  (letfn [(list-type-fn [b] (some-> b :block/properties :logseq.order-list-type))]
-    (if-let [list-type (and sibling? target-block (list-type-fn target-block))]
-      (mapv
-        (fn [block]
-          (cond-> block
-            (some? (:block/properties block))
-            (assoc-in [:block/properties :logseq.order-list-type] list-type)))
-        blocks)
-      blocks)))
+  (let [target-block (if sibling? target-block (some-> target-block :db/id db/pull block tree/-get-down :data))]
+    (letfn [(list-type-fn [b] (some-> b :block/properties :logseq.order-list-type))]
+      (if-let [list-type (and target-block (list-type-fn target-block))]
+        (mapv
+          (fn [block]
+            (cond-> block
+              (some? (:block/uuid block))
+              (update :block/properties #(assoc % :logseq.order-list-type list-type))))
+          blocks)
+        blocks))))
 
 ;;; ### insert-blocks, delete-blocks, move-blocks