mirror of https://github.com/logseq/logseq
enhance: jump to edit the first block when creating a new page
parent
8b1e548658
commit
7a78e805fd
|
@ -1238,7 +1238,7 @@
|
|||
priority]
|
||||
(if title
|
||||
(map-inline config title)
|
||||
[[:span.opacity-50 "Click here to start writing"]])
|
||||
[[:span.opacity-50 "Click here to start writing, type '/' to see all the commands."]])
|
||||
[tags])))))
|
||||
|
||||
(defn show-dnd-separator
|
||||
|
@ -1418,9 +1418,6 @@
|
|||
(merge attrs))
|
||||
|
||||
(cond
|
||||
dummy?
|
||||
[:span.opacity-50 "Click here to start writing"]
|
||||
|
||||
(seq title)
|
||||
(build-block-title config block)
|
||||
|
||||
|
|
|
@ -54,6 +54,31 @@
|
|||
(page-handler/add-page-to-recent! repo page-original-name)
|
||||
(db/get-page-blocks repo page-name)))))
|
||||
|
||||
(rum/defc page-blocks-inner <
|
||||
{:did-mount (fn [state]
|
||||
(let [block (first (nth (:rum/args state) 1))]
|
||||
(when (:block/dummy? block)
|
||||
(editor-handler/edit-block! block 0 (:block/format block) (:block/uuid block))))
|
||||
state)}
|
||||
[page-name page-blocks hiccup sidebar?]
|
||||
[:div.page-blocks-inner
|
||||
;; (when (and (seq grouped-blocks-by-file)
|
||||
;; (> (count grouped-blocks-by-file) 1))
|
||||
;; (ui/admonition
|
||||
;; :warning
|
||||
;; [:div.text-sm
|
||||
;; [:p.font-medium "Those pages have the same title, you might want to only keep one file."]
|
||||
;; [:ol
|
||||
;; (for [[file-path blocks] (into (sorted-map) grouped-blocks-by-file)]
|
||||
;; [:li [:a {:key file-path
|
||||
;; :href (rfe/href :file {:path file-path})} file-path]])]]))
|
||||
|
||||
(rum/with-key
|
||||
(content/content page-name
|
||||
{:hiccup hiccup
|
||||
:sidebar? sidebar?})
|
||||
(str page-name "-hiccup"))])
|
||||
|
||||
(rum/defc page-blocks-cp < rum/reactive
|
||||
db-mixins/query
|
||||
[repo page file-path page-name page-original-name encoded-page-name sidebar? journal? block? block-id format]
|
||||
|
@ -78,23 +103,7 @@
|
|||
:editor-box editor/box}
|
||||
hiccup-config (common-handler/config-with-document-mode hiccup-config)
|
||||
hiccup (block/->hiccup page-blocks hiccup-config {})]
|
||||
[:div.page-blocks-inner
|
||||
;; (when (and (seq grouped-blocks-by-file)
|
||||
;; (> (count grouped-blocks-by-file) 1))
|
||||
;; (ui/admonition
|
||||
;; :warning
|
||||
;; [:div.text-sm
|
||||
;; [:p.font-medium "Those pages have the same title, you might want to only keep one file."]
|
||||
;; [:ol
|
||||
;; (for [[file-path blocks] (into (sorted-map) grouped-blocks-by-file)]
|
||||
;; [:li [:a {:key file-path
|
||||
;; :href (rfe/href :file {:path file-path})} file-path]])]]))
|
||||
|
||||
(rum/with-key
|
||||
(content/content page-name
|
||||
{:hiccup hiccup
|
||||
:sidebar? sidebar?})
|
||||
(str encoded-page-name "-hiccup"))]))
|
||||
(page-blocks-inner page-name page-blocks hiccup sidebar?)))
|
||||
|
||||
(defn contents-page
|
||||
[{:block/keys [name original-name file] :as contents}]
|
||||
|
|
|
@ -225,9 +225,8 @@
|
|||
(subs content 0 pos))
|
||||
content (text/remove-built-in-properties! (:block/format block)
|
||||
content)]
|
||||
(do
|
||||
(clear-selection! nil)
|
||||
(state/set-editing! edit-input-id content block text-range move-cursor?)))))))
|
||||
(clear-selection! nil)
|
||||
(state/set-editing! edit-input-id content block text-range move-cursor?))))))
|
||||
|
||||
(defn edit-last-block-for-new-page!
|
||||
[last-block pos]
|
||||
|
|
Loading…
Reference in New Issue