diff --git a/src/main/frontend/commands.cljs b/src/main/frontend/commands.cljs index 3eb0b5afe..62060c642 100644 --- a/src/main/frontend/commands.cljs +++ b/src/main/frontend/commands.cljs @@ -655,8 +655,7 @@ (defmethod handle-step :editor/show-date-picker [[_ type]] (if (and (contains? #{:scheduled :deadline} type) - (when-let [value (gobj/get (state/get-input) "value")] - (string/blank? value))) + (string/blank? (gobj/get (state/get-input) "value"))) (do (notification/show! [:div "Please add some content first."] :warning) (restore-state)) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 7c1fed4f3..f7c474e56 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -43,6 +43,7 @@ [frontend.handler.dnd :as dnd] [frontend.handler.editor :as editor-handler] [frontend.handler.file-sync :as file-sync] + [frontend.handler.notification :as notification] [frontend.handler.plugin :as plugin-handler] [frontend.handler.query :as query-handler] [frontend.handler.repeated :as repeated] @@ -61,7 +62,6 @@ [frontend.util.drawer :as drawer] [frontend.util.property :as property] [frontend.util.text :as text-util] - [frontend.handler.notification :as notification] [goog.dom :as gdom] [goog.object :as gobj] [lambdaisland.glogi :as log] diff --git a/src/main/frontend/components/datetime.cljs b/src/main/frontend/components/datetime.cljs index 80aa91875..30ec8b5a0 100644 --- a/src/main/frontend/components/datetime.cljs +++ b/src/main/frontend/components/datetime.cljs @@ -78,7 +78,7 @@ :duration "d"}))} "Add repeater"]))) -(defn clear-timestamp! +(defn- clear-timestamp! [] (reset! *timestamp default-timestamp-value) (reset! *show-time? false) @@ -86,6 +86,7 @@ (state/set-state! :date-picker/date nil)) (defn- on-submit + "Submit handler of date picker" [e] (when e (util/stop e)) (let [{:keys [repeater] :as timestamp} @*timestamp @@ -105,6 +106,7 @@ (when show? (reset! show? false))) (clear-timestamp!) + (state/set-timestamp-block! nil) (commands/restore-state)) (rum/defc time-repeater < rum/reactive @@ -138,7 +140,7 @@ (when-not (:date-picker/date @state/state) (state/set-state! :date-picker/date (get ts :date (t/today))))) state)} - [id format _ts] + [dom-id format _ts] (let [current-command @commands/*current-command deadline-or-schedule? (and current-command (contains? #{"deadline" "scheduled"} @@ -154,9 +156,10 @@ (util/stop e) (let [date (t/to-default-time-zone date) journal (date/journal-name date)] + ;; deadline-or-schedule? is handled in on-sumbit, not here (when-not deadline-or-schedule? ;; similar to page reference - (editor-handler/insert-command! id + (editor-handler/insert-command! dom-id (page-ref/->page-ref journal) format {:command :page-ref}) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index b8bc6ebf9..67cbf70bb 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -3065,7 +3065,8 @@ (defn shortcut-up-down [direction] (fn [e] (when (and (not (auto-complete?)) - (not (slide-focused?))) + (not (slide-focused?)) + (not (state/get-timestamp-block))) (util/stop e) (cond (state/editing?) @@ -3122,7 +3123,8 @@ (defn shortcut-left-right [direction] (fn [e] - (when-not (auto-complete?) + (when (and (not (auto-complete?)) + (not (state/get-timestamp-block))) (cond (state/editing?) (do diff --git a/src/main/frontend/modules/shortcut/config.cljs b/src/main/frontend/modules/shortcut/config.cljs index f167c6ab0..6d4b09d24 100644 --- a/src/main/frontend/modules/shortcut/config.cljs +++ b/src/main/frontend/modules/shortcut/config.cljs @@ -36,6 +36,9 @@ ;; :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 (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" :fn ui-handler/shortcut-complete} @@ -328,7 +331,7 @@ :graph/re-index {:fn (fn [] (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} :command/run {:binding "mod+shift+1" diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index f3554d0f0..dfbe741b5 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -117,7 +117,7 @@ :editor/content {} :editor/block 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/document-mode? document-mode? :editor/args nil @@ -1837,6 +1837,7 @@ Similar to re-frame subscriptions" :editor/block block :editor/editing? {edit-input-id true} :editor/last-key-code nil + :editor/set-timestamp-block nil :cursor-range cursor-range)))) (when-let [input (gdom/getElement edit-input-id)] (let [pos (count cursor-range)]