mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 19:36:35 +00:00
refactor(shortcuts): up/down to navigate to the first/last block
Non-editing mode.
This commit is contained in:
@@ -2167,26 +2167,35 @@
|
||||
[block-id value]
|
||||
(set-block-property! block-id "heading" value))
|
||||
|
||||
;; Should preserve the cursor too.
|
||||
(defn open-last-block!
|
||||
[journal?]
|
||||
(let [edit-id (state/get-edit-input-id)
|
||||
last-pos (state/get-edit-pos)
|
||||
block-id (when edit-id (subs edit-id (- (count edit-id) 36)))]
|
||||
(let [last-edit-block (first (array-seq (js/document.getElementsByClassName block-id)))
|
||||
first-block (first (array-seq (js/document.getElementsByClassName "ls-block")))
|
||||
node (or last-edit-block
|
||||
(and (not journal?) first-block))]
|
||||
(defn open-block!
|
||||
[first?]
|
||||
(when-not (state/editing?)
|
||||
(let [edit-id (state/get-last-edit-input-id)
|
||||
block-id (when edit-id (subs edit-id (- (count edit-id) 36)))
|
||||
last-edit-block (first (array-seq (js/document.getElementsByClassName block-id)))
|
||||
nodes (array-seq (js/document.getElementsByClassName "ls-block"))
|
||||
first-node (first nodes)
|
||||
node (cond
|
||||
last-edit-block
|
||||
last-edit-block
|
||||
first?
|
||||
first-node
|
||||
:else
|
||||
(when-let [blocks-container (util/rec-get-blocks-container first-node)]
|
||||
(let [nodes (dom/by-class blocks-container "ls-block")]
|
||||
(last nodes))))]
|
||||
(when node
|
||||
(state/clear-selection!)
|
||||
(unhighlight-block!)
|
||||
(let [block-id (and node (d/attr node "blockid"))
|
||||
edit-block-id (string/replace (gobj/get node "id") "ls-block" "edit-block")
|
||||
block-id (medley/uuid block-id)]
|
||||
(when-let [block (db/entity [:block/uuid block-id])]
|
||||
(edit-block! block
|
||||
(or (and last-edit-block last-pos)
|
||||
:max)
|
||||
:max
|
||||
(:block/format block)
|
||||
edit-block-id)))))))
|
||||
edit-block-id))))
|
||||
false)))
|
||||
|
||||
(defn get-search-q
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user