mirror of https://github.com/logseq/logseq
feat: g t for tomorrow, g p for prev journal, g n for next journal
parent
7c061e4605
commit
311f9701ac
|
@ -19,6 +19,7 @@
|
|||
[frontend.extensions.graph :as graph]
|
||||
[frontend.extensions.pdf.assets :as pdf-assets]
|
||||
[frontend.format.mldoc :as mldoc]
|
||||
[frontend.format.block :as format-block]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.config :as config-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
|
@ -300,9 +301,8 @@
|
|||
(db/entity repo))
|
||||
(do
|
||||
(when-not (db/entity repo [:block/name page-name])
|
||||
(db/transact! repo [{:block/name page-name
|
||||
:block/original-name path-page-name
|
||||
:block/uuid (db/new-block-id)}]))
|
||||
(let [m (format-block/page-name->map path-page-name true)]
|
||||
(db/transact! repo [m])))
|
||||
(db/pull [:block/name page-name])))
|
||||
{:keys [title emoji] :as properties} (:block/properties page)
|
||||
page-name (:block/name page)
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
(ns frontend.handler.journal
|
||||
(:require [clojure.string :as string]
|
||||
[frontend.date :as date]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]
|
||||
[cljs-time.coerce :as tc]
|
||||
[cljs-time.core :as t]))
|
||||
|
||||
(defn- redirect-to-journal!
|
||||
[page]
|
||||
(when (and page (state/enable-journals? (state/get-current-repo)))
|
||||
(prn {:page page})
|
||||
(route-handler/redirect! {:to :page
|
||||
:path-params {:name page}})
|
||||
(editor-handler/insert-first-page-block-if-not-exists! page)))
|
||||
|
||||
(defn go-to-tomorrow!
|
||||
[]
|
||||
(redirect-to-journal! (date/tomorrow)))
|
||||
|
||||
(defn- get-current-journal
|
||||
[]
|
||||
(let [current-page (state/get-current-page)]
|
||||
(or (date/journal-title->long current-page)
|
||||
(util/time-ms))))
|
||||
|
||||
(defn go-to-prev-journal!
|
||||
[]
|
||||
(let [current-journal (get-current-journal)
|
||||
day (tc/from-long current-journal)
|
||||
page (date/journal-name (t/minus day (t/days 1)))]
|
||||
(redirect-to-journal! page)))
|
||||
|
||||
(defn go-to-next-journal!
|
||||
[]
|
||||
(let [current-journal (get-current-journal)
|
||||
day (tc/from-long current-journal)
|
||||
page (date/journal-name (t/plus day (t/days 1)))]
|
||||
(redirect-to-journal! page)))
|
|
@ -7,6 +7,7 @@
|
|||
[frontend.handler.history :as history]
|
||||
[frontend.handler.page :as page-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.journal :as journal-handler]
|
||||
[frontend.handler.search :as search-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.plugin :as plugin-handler]
|
||||
|
@ -351,6 +352,18 @@
|
|||
{:desc "Go to keyboard shortcuts"
|
||||
:binding "g s"
|
||||
:fn #(route-handler/redirect! {:to :shortcut-setting})}
|
||||
:go/tomorrow
|
||||
{:desc "Go to tomorrow"
|
||||
:binding "g t"
|
||||
:fn journal-handler/go-to-tomorrow!}
|
||||
:go/next-journal
|
||||
{:desc "Go to next journal"
|
||||
:binding "g n"
|
||||
:fn journal-handler/go-to-next-journal!}
|
||||
:go/prev-journal
|
||||
{:desc "Go to previous journal"
|
||||
:binding "g p"
|
||||
:fn journal-handler/go-to-prev-journal!}
|
||||
:ui/toggle-document-mode
|
||||
{:desc "Toggle document mode"
|
||||
:binding "t d"
|
||||
|
@ -509,6 +522,9 @@
|
|||
^{:doc "Others"}
|
||||
[:go/home
|
||||
:go/journals
|
||||
:go/tomorrow
|
||||
:go/next-journal
|
||||
:go/prev-journal
|
||||
:command/run
|
||||
:command-palette/toggle
|
||||
:sidebar/clear
|
||||
|
|
Loading…
Reference in New Issue