mirror of https://github.com/logseq/logseq
fix: disable move when moving to the original position
parent
28dfe9759a
commit
bb804a520a
|
@ -599,12 +599,23 @@
|
|||
(swap! txs-state concat fix-non-consecutive-tx))))
|
||||
{:tx-data @txs-state}))
|
||||
|
||||
(defn- move-to-original-position?
|
||||
[blocks target-block sibling?]
|
||||
(let [non-consecutive-blocks (db-model/get-non-consecutive-blocks blocks)]
|
||||
(and (empty? non-consecutive-blocks)
|
||||
(= (:db/id (:block/left (first blocks))) (:db/id target-block))
|
||||
(not= (= (:db/id (:block/parent (first blocks)))
|
||||
(:db/id target-block))
|
||||
sibling?))))
|
||||
|
||||
(defn move-blocks
|
||||
"Move `blocks` to `target-block` as siblings or children."
|
||||
[blocks target-block {:keys [sibling? outliner-op]}]
|
||||
[:pre [(seq blocks)
|
||||
(s/valid? ::block-map-or-entity target-block)]]
|
||||
(when (not (contains? (set (map :db/id blocks)) (:db/id target-block)))
|
||||
(let [original-position? (move-to-original-position? blocks target-block sibling?)]
|
||||
(when (and (not (contains? (set (map :db/id blocks)) (:db/id target-block)))
|
||||
(not original-position?))
|
||||
(let [parents (->> (db/get-block-parents (state/get-current-repo) (:block/uuid target-block))
|
||||
(map :db/id)
|
||||
(set))
|
||||
|
@ -634,7 +645,7 @@
|
|||
(assoc :from-page first-block-page
|
||||
:target-page target-page))]
|
||||
{:tx-data full-tx
|
||||
:tx-meta tx-meta})))))))
|
||||
:tx-meta tx-meta}))))))))
|
||||
|
||||
(defn move-blocks-up-down
|
||||
"Move blocks up/down."
|
||||
|
|
Loading…
Reference in New Issue