From f55ccda97ed506cc35cbab980323e0900d1e7627 Mon Sep 17 00:00:00 2001 From: charlie Date: Wed, 26 Apr 2023 13:03:14 +0800 Subject: [PATCH] fix(ux): turn the block into ordered item when it's moved to the first item from target ordered children --- src/main/frontend/handler/editor.cljs | 4 ---- src/main/frontend/modules/outliner/core.cljs | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 6caa32fa58..4308257eab 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/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")) diff --git a/src/main/frontend/modules/outliner/core.cljs b/src/main/frontend/modules/outliner/core.cljs index a4d38c9131..3afbf999f9 100644 --- a/src/main/frontend/modules/outliner/core.cljs +++ b/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