mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
Merge branch 'master' into feat/db
This commit is contained in:
@@ -341,8 +341,8 @@
|
||||
(select-keys properties (property/hidden-properties))
|
||||
(:block/properties block))]
|
||||
(-> block
|
||||
(dissoc :block/top?
|
||||
:block/bottom?)
|
||||
(dissoc :block.temp/top?
|
||||
:block.temp/bottom?)
|
||||
(assoc :block/content content
|
||||
:block/properties new-properties)
|
||||
(merge (if level {:block/level level} {})))))
|
||||
@@ -826,7 +826,7 @@
|
||||
(let [prev-block' (if (seq (:block/_refs block-e))
|
||||
(assoc prev-block
|
||||
:block/uuid (:block/uuid block)
|
||||
:block/additional-properties (:block/properties block))
|
||||
:block.temp/additional-properties (:block/properties block))
|
||||
prev-block)]
|
||||
(delete-block-aux! block delete-children?)
|
||||
(save-block! repo prev-block' new-content {:editor/op :delete}))
|
||||
@@ -1193,10 +1193,6 @@
|
||||
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) md-content html sorted-blocks)
|
||||
(delete-block-aux! block true))))
|
||||
|
||||
(defn clear-last-selected-block!
|
||||
[]
|
||||
(state/drop-last-selection-block!))
|
||||
|
||||
(defn highlight-selection-area!
|
||||
[end-block]
|
||||
(when-let [start-block (state/get-selection-start-block-or-first)]
|
||||
@@ -1212,13 +1208,17 @@
|
||||
(cond
|
||||
;; when editing, quit editing and select current block
|
||||
(state/editing?)
|
||||
(state/exit-editing-and-set-selected-blocks! [(gdom/getElement (state/get-editing-block-dom-id))])
|
||||
(let [element (gdom/getElement (state/get-editing-block-dom-id))]
|
||||
(when element
|
||||
(util/scroll-to-block element)
|
||||
(state/exit-editing-and-set-selected-blocks! [element])))
|
||||
|
||||
;; when selection and one block selected, select next block
|
||||
(and (state/selection?) (== 1 (count (state/get-selection-blocks))))
|
||||
(let [f (if (= :up direction) util/get-prev-block-non-collapsed util/get-next-block-non-collapsed-skip)
|
||||
element (f (first (state/get-selection-blocks)))]
|
||||
(when element
|
||||
(util/scroll-to-block element)
|
||||
(state/conj-selection-block! element direction)))
|
||||
|
||||
;; if same direction, keep conj on same direction
|
||||
@@ -1227,11 +1227,17 @@
|
||||
first-last (if (= :up direction) first last)
|
||||
element (f (first-last (state/get-selection-blocks)))]
|
||||
(when element
|
||||
(util/scroll-to-block element)
|
||||
(state/conj-selection-block! element direction)))
|
||||
|
||||
;; if different direction, keep clear until one left
|
||||
(state/selection?)
|
||||
(clear-last-selected-block!))
|
||||
(let [f (if (= :up direction) util/get-prev-block-non-collapsed util/get-next-block-non-collapsed)
|
||||
last-first (if (= :up direction) last first)
|
||||
element (f (last-first (state/get-selection-blocks)))]
|
||||
(when element
|
||||
(util/scroll-to-block element)
|
||||
(state/drop-last-selection-block!))))
|
||||
nil)
|
||||
|
||||
(defn on-select-block
|
||||
@@ -2480,13 +2486,6 @@
|
||||
(.preventDefault e)
|
||||
(keydown-new-line))))
|
||||
|
||||
(defn- scroll-to-block
|
||||
[block]
|
||||
(when block
|
||||
(when-not (util/element-visible? block)
|
||||
(.scrollIntoView block #js {:behavior "smooth"
|
||||
:block "center"}))))
|
||||
|
||||
(defn- select-first-last
|
||||
"Select first or last block in viewpoint"
|
||||
[direction]
|
||||
@@ -2494,7 +2493,7 @@
|
||||
block (->> (util/get-blocks-noncollapse)
|
||||
(f))]
|
||||
(when block
|
||||
(scroll-to-block block)
|
||||
(util/scroll-to-block block)
|
||||
(state/exit-editing-and-set-selected-blocks! [block]))))
|
||||
|
||||
(defn- select-up-down [direction]
|
||||
@@ -2507,7 +2506,7 @@
|
||||
:down util/get-next-block-non-collapsed)
|
||||
sibling-block (f selected)]
|
||||
(when (and sibling-block (dom/attr sibling-block "blockid"))
|
||||
(scroll-to-block sibling-block)
|
||||
(util/scroll-to-block sibling-block)
|
||||
(state/exit-editing-and-set-selected-blocks! [sibling-block]))))
|
||||
|
||||
(defn- move-cross-boundary-up-down
|
||||
@@ -2645,7 +2644,7 @@
|
||||
edit-block' (if next-block-has-refs?
|
||||
(assoc edit-block
|
||||
:block/uuid (:block/uuid next-block)
|
||||
:block/additional-properties (dissoc (:block/properties next-block) :block/uuid))
|
||||
:block.temp/additional-properties (dissoc (:block/properties next-block) :block/uuid))
|
||||
edit-block)]
|
||||
(outliner-tx/transact! transact-opts
|
||||
(delete-block-aux! next-block false)
|
||||
@@ -2690,7 +2689,7 @@
|
||||
repo (state/get-current-repo)
|
||||
top-block? (= (:block/left block) (:block/page block))
|
||||
single-block? (inside-of-single-block (.-target e))
|
||||
root-block? (= (:block/container block) (str (:block/uuid block)))]
|
||||
root-block? (= (:block.temp/container block) (str (:block/uuid block)))]
|
||||
(mark-last-input-time! repo)
|
||||
(cond
|
||||
(not= selected-start selected-end)
|
||||
|
||||
Reference in New Issue
Block a user