mirror of https://github.com/logseq/logseq
fix(editor): revise date-picker shortcut key handling and opening condition
parent
bbc536c2fb
commit
c92f44d22e
|
@ -655,8 +655,7 @@
|
||||||
(defmethod handle-step :editor/show-date-picker [[_ type]]
|
(defmethod handle-step :editor/show-date-picker [[_ type]]
|
||||||
(if (and
|
(if (and
|
||||||
(contains? #{:scheduled :deadline} type)
|
(contains? #{:scheduled :deadline} type)
|
||||||
(when-let [value (gobj/get (state/get-input) "value")]
|
(string/blank? (gobj/get (state/get-input) "value")))
|
||||||
(string/blank? value)))
|
|
||||||
(do
|
(do
|
||||||
(notification/show! [:div "Please add some content first."] :warning)
|
(notification/show! [:div "Please add some content first."] :warning)
|
||||||
(restore-state))
|
(restore-state))
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
[frontend.handler.dnd :as dnd]
|
[frontend.handler.dnd :as dnd]
|
||||||
[frontend.handler.editor :as editor-handler]
|
[frontend.handler.editor :as editor-handler]
|
||||||
[frontend.handler.file-sync :as file-sync]
|
[frontend.handler.file-sync :as file-sync]
|
||||||
|
[frontend.handler.notification :as notification]
|
||||||
[frontend.handler.plugin :as plugin-handler]
|
[frontend.handler.plugin :as plugin-handler]
|
||||||
[frontend.handler.query :as query-handler]
|
[frontend.handler.query :as query-handler]
|
||||||
[frontend.handler.repeated :as repeated]
|
[frontend.handler.repeated :as repeated]
|
||||||
|
@ -61,7 +62,6 @@
|
||||||
[frontend.util.drawer :as drawer]
|
[frontend.util.drawer :as drawer]
|
||||||
[frontend.util.property :as property]
|
[frontend.util.property :as property]
|
||||||
[frontend.util.text :as text-util]
|
[frontend.util.text :as text-util]
|
||||||
[frontend.handler.notification :as notification]
|
|
||||||
[goog.dom :as gdom]
|
[goog.dom :as gdom]
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[lambdaisland.glogi :as log]
|
[lambdaisland.glogi :as log]
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
:duration "d"}))}
|
:duration "d"}))}
|
||||||
"Add repeater"])))
|
"Add repeater"])))
|
||||||
|
|
||||||
(defn clear-timestamp!
|
(defn- clear-timestamp!
|
||||||
[]
|
[]
|
||||||
(reset! *timestamp default-timestamp-value)
|
(reset! *timestamp default-timestamp-value)
|
||||||
(reset! *show-time? false)
|
(reset! *show-time? false)
|
||||||
|
@ -86,6 +86,7 @@
|
||||||
(state/set-state! :date-picker/date nil))
|
(state/set-state! :date-picker/date nil))
|
||||||
|
|
||||||
(defn- on-submit
|
(defn- on-submit
|
||||||
|
"Submit handler of date picker"
|
||||||
[e]
|
[e]
|
||||||
(when e (util/stop e))
|
(when e (util/stop e))
|
||||||
(let [{:keys [repeater] :as timestamp} @*timestamp
|
(let [{:keys [repeater] :as timestamp} @*timestamp
|
||||||
|
@ -105,6 +106,7 @@
|
||||||
(when show?
|
(when show?
|
||||||
(reset! show? false)))
|
(reset! show? false)))
|
||||||
(clear-timestamp!)
|
(clear-timestamp!)
|
||||||
|
(state/set-timestamp-block! nil)
|
||||||
(commands/restore-state))
|
(commands/restore-state))
|
||||||
|
|
||||||
(rum/defc time-repeater < rum/reactive
|
(rum/defc time-repeater < rum/reactive
|
||||||
|
@ -138,7 +140,7 @@
|
||||||
(when-not (:date-picker/date @state/state)
|
(when-not (:date-picker/date @state/state)
|
||||||
(state/set-state! :date-picker/date (get ts :date (t/today)))))
|
(state/set-state! :date-picker/date (get ts :date (t/today)))))
|
||||||
state)}
|
state)}
|
||||||
[id format _ts]
|
[dom-id format _ts]
|
||||||
(let [current-command @commands/*current-command
|
(let [current-command @commands/*current-command
|
||||||
deadline-or-schedule? (and current-command
|
deadline-or-schedule? (and current-command
|
||||||
(contains? #{"deadline" "scheduled"}
|
(contains? #{"deadline" "scheduled"}
|
||||||
|
@ -154,9 +156,10 @@
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(let [date (t/to-default-time-zone date)
|
(let [date (t/to-default-time-zone date)
|
||||||
journal (date/journal-name date)]
|
journal (date/journal-name date)]
|
||||||
|
;; deadline-or-schedule? is handled in on-sumbit, not here
|
||||||
(when-not deadline-or-schedule?
|
(when-not deadline-or-schedule?
|
||||||
;; similar to page reference
|
;; similar to page reference
|
||||||
(editor-handler/insert-command! id
|
(editor-handler/insert-command! dom-id
|
||||||
(page-ref/->page-ref journal)
|
(page-ref/->page-ref journal)
|
||||||
format
|
format
|
||||||
{:command :page-ref})
|
{:command :page-ref})
|
||||||
|
|
|
@ -3065,7 +3065,8 @@
|
||||||
(defn shortcut-up-down [direction]
|
(defn shortcut-up-down [direction]
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(when (and (not (auto-complete?))
|
(when (and (not (auto-complete?))
|
||||||
(not (slide-focused?)))
|
(not (slide-focused?))
|
||||||
|
(not (state/get-timestamp-block)))
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
(cond
|
(cond
|
||||||
(state/editing?)
|
(state/editing?)
|
||||||
|
@ -3122,7 +3123,8 @@
|
||||||
|
|
||||||
(defn shortcut-left-right [direction]
|
(defn shortcut-left-right [direction]
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(when-not (auto-complete?)
|
(when (and (not (auto-complete?))
|
||||||
|
(not (state/get-timestamp-block)))
|
||||||
(cond
|
(cond
|
||||||
(state/editing?)
|
(state/editing?)
|
||||||
(do
|
(do
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
;; :inactive key is for commands that are not active for a given platform or feature condition
|
;; :inactive key is for commands that are not active for a given platform or feature condition
|
||||||
;; Avoid using single letter shortcuts to allow chords that start with those characters
|
;; Avoid using single letter shortcuts to allow chords that start with those characters
|
||||||
(def ^:large-vars/data-var all-default-keyboard-shortcuts
|
(def ^:large-vars/data-var all-default-keyboard-shortcuts
|
||||||
|
;; BUG: Actually, "enter" is registered by mixin behind a "when inputing" guard
|
||||||
|
;; So this setting item does not cover all cases.
|
||||||
|
;; See-also: frontend.components.datetime/time-repeater
|
||||||
{:date-picker/complete {:binding "enter"
|
{:date-picker/complete {:binding "enter"
|
||||||
:fn ui-handler/shortcut-complete}
|
:fn ui-handler/shortcut-complete}
|
||||||
|
|
||||||
|
@ -328,7 +331,7 @@
|
||||||
|
|
||||||
:graph/re-index {:fn (fn []
|
:graph/re-index {:fn (fn []
|
||||||
(p/let [multiple-windows? (ipc/ipc "graphHasMultipleWindows" (state/get-current-repo))]
|
(p/let [multiple-windows? (ipc/ipc "graphHasMultipleWindows" (state/get-current-repo))]
|
||||||
(state/pub-event! [:graph/ask-for-re-index (atom multiple-windows?) nil])))
|
(state/pub-event! [:graph/ask-for-re-index (atom multiple-windows?) nil])))
|
||||||
:binding false}
|
:binding false}
|
||||||
|
|
||||||
:command/run {:binding "mod+shift+1"
|
:command/run {:binding "mod+shift+1"
|
||||||
|
|
|
@ -117,7 +117,7 @@
|
||||||
:editor/content {}
|
:editor/content {}
|
||||||
:editor/block nil
|
:editor/block nil
|
||||||
:editor/block-dom-id nil
|
:editor/block-dom-id nil
|
||||||
:editor/set-timestamp-block nil
|
:editor/set-timestamp-block nil ;; click rendered block timestamp-cp to set timestamp
|
||||||
:editor/last-input-time nil
|
:editor/last-input-time nil
|
||||||
:editor/document-mode? document-mode?
|
:editor/document-mode? document-mode?
|
||||||
:editor/args nil
|
:editor/args nil
|
||||||
|
@ -1837,6 +1837,7 @@ Similar to re-frame subscriptions"
|
||||||
:editor/block block
|
:editor/block block
|
||||||
:editor/editing? {edit-input-id true}
|
:editor/editing? {edit-input-id true}
|
||||||
:editor/last-key-code nil
|
:editor/last-key-code nil
|
||||||
|
:editor/set-timestamp-block nil
|
||||||
:cursor-range cursor-range))))
|
:cursor-range cursor-range))))
|
||||||
(when-let [input (gdom/getElement edit-input-id)]
|
(when-let [input (gdom/getElement edit-input-id)]
|
||||||
(let [pos (count cursor-range)]
|
(let [pos (count cursor-range)]
|
||||||
|
|
Loading…
Reference in New Issue