mirror of https://github.com/logseq/logseq
[refactor] improve some input cases
parent
9ff67bba53
commit
66a24e99d3
|
@ -613,10 +613,10 @@
|
||||||
nil)]
|
nil)]
|
||||||
(when-not (string/blank? youtube-id)
|
(when-not (string/blank? youtube-id)
|
||||||
[:iframe
|
[:iframe
|
||||||
{:allowfullscreen "allowfullscreen"
|
{:allow-full-screen "allowfullscreen"
|
||||||
:allow
|
:allow
|
||||||
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||||
:frameborder "0"
|
:frame-border "0"
|
||||||
:src (str "https://www.youtube.com/embed/" youtube-id)
|
:src (str "https://www.youtube.com/embed/" youtube-id)
|
||||||
:height "315"
|
:height "315"
|
||||||
:width "560"}])))
|
:width "560"}])))
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
[frontend.text :as text]
|
[frontend.text :as text]
|
||||||
["/frontend/utils" :as utils]))
|
["/frontend/utils" :as utils]))
|
||||||
|
|
||||||
|
(def *warn-on-infer* false)
|
||||||
|
|
||||||
(rum/defc commands < rum/reactive
|
(rum/defc commands < rum/reactive
|
||||||
[id format]
|
[id format]
|
||||||
(when (and (util/react *show-commands)
|
(when (and (util/react *show-commands)
|
||||||
|
@ -353,6 +355,9 @@
|
||||||
false
|
false
|
||||||
*slash-caret-pos)))])
|
*slash-caret-pos)))])
|
||||||
|
|
||||||
|
(def evt-passthrough! #(if (instance? goog.events.Event %) (set! (. % -pt) true)))
|
||||||
|
(def evt-passthrough? #(if (instance? goog.events.Event %) (. % -pt)))
|
||||||
|
|
||||||
(rum/defcs box < rum/reactive
|
(rum/defcs box < rum/reactive
|
||||||
(mixins/event-mixin
|
(mixins/event-mixin
|
||||||
(fn [state]
|
(fn [state]
|
||||||
|
@ -397,6 +402,7 @@
|
||||||
insert?
|
insert?
|
||||||
(not (editor-handler/in-auto-complete? input)))
|
(not (editor-handler/in-auto-complete? input)))
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
|
(evt-passthrough! e)
|
||||||
(profile
|
(profile
|
||||||
"Insert block"
|
"Insert block"
|
||||||
(editor-handler/insert-new-block! state))))))))))
|
(editor-handler/insert-new-block! state))))))))))
|
||||||
|
@ -406,6 +412,7 @@
|
||||||
(not (gobj/get e "ctrlKey"))
|
(not (gobj/get e "ctrlKey"))
|
||||||
(not (gobj/get e "metaKey"))
|
(not (gobj/get e "metaKey"))
|
||||||
(not (editor-handler/in-auto-complete? input)))
|
(not (editor-handler/in-auto-complete? input)))
|
||||||
|
(evt-passthrough! e)
|
||||||
(editor-handler/on-up-down state e true)))
|
(editor-handler/on-up-down state e true)))
|
||||||
;; down
|
;; down
|
||||||
40 (fn [state e]
|
40 (fn [state e]
|
||||||
|
@ -413,6 +420,7 @@
|
||||||
(not (gobj/get e "ctrlKey"))
|
(not (gobj/get e "ctrlKey"))
|
||||||
(not (gobj/get e "metaKey"))
|
(not (gobj/get e "metaKey"))
|
||||||
(not (editor-handler/in-auto-complete? input)))
|
(not (editor-handler/in-auto-complete? input)))
|
||||||
|
(evt-passthrough! e)
|
||||||
(editor-handler/on-up-down state e false)))
|
(editor-handler/on-up-down state e false)))
|
||||||
;; backspace
|
;; backspace
|
||||||
8 (fn [state e]
|
8 (fn [state e]
|
||||||
|
@ -434,8 +442,9 @@
|
||||||
(not (and page
|
(not (and page
|
||||||
(util/uuid-string? page)
|
(util/uuid-string? page)
|
||||||
(= (medley/uuid page) block-id))))
|
(= (medley/uuid page) block-id))))
|
||||||
|
(do
|
||||||
(editor-handler/delete-block! state repo e)
|
(evt-passthrough! e)
|
||||||
|
(editor-handler/delete-block! state repo e))
|
||||||
|
|
||||||
(and (> current-pos 1)
|
(and (> current-pos 1)
|
||||||
(= (util/nth-safe value (dec current-pos)) commands/slash))
|
(= (util/nth-safe value (dec current-pos)) commands/slash))
|
||||||
|
@ -493,6 +502,7 @@
|
||||||
(util/move-cursor-to input pos))
|
(util/move-cursor-to input pos))
|
||||||
0)))))))}
|
0)))))))}
|
||||||
(fn [e key-code]
|
(fn [e key-code]
|
||||||
|
(when-not (evt-passthrough? e)
|
||||||
(let [key (gobj/get e "key")
|
(let [key (gobj/get e "key")
|
||||||
value (gobj/get input "value")
|
value (gobj/get input "value")
|
||||||
pos (:pos (util/get-caret-pos input))]
|
pos (:pos (util/get-caret-pos input))]
|
||||||
|
@ -568,7 +578,7 @@
|
||||||
(commands/simple-insert! input-id "^^" {:backward-pos 2})
|
(commands/simple-insert! input-id "^^" {:backward-pos 2})
|
||||||
|
|
||||||
:else
|
:else
|
||||||
nil))))
|
nil)))))
|
||||||
(mixins/on-key-up
|
(mixins/on-key-up
|
||||||
state
|
state
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
set-composition? #(reset! composition? %)
|
set-composition? #(reset! composition? %)
|
||||||
on-composition (fn [e]
|
on-composition (fn [e]
|
||||||
(case e.type
|
(case e.type
|
||||||
"compositionend" (do (set-composition? false))
|
"compositionend" (do (set-composition? false) (on-change e))
|
||||||
(set-composition? true)))
|
(set-composition? true)))
|
||||||
props (assoc -props
|
props (assoc -props
|
||||||
:on-change (fn [e] (when (not @composition?)
|
:on-change (fn [e] (when-not @composition?
|
||||||
(on-change e)))
|
(on-change e)))
|
||||||
:on-composition-start on-composition
|
:on-composition-start on-composition
|
||||||
:on-composition-update on-composition
|
:on-composition-update on-composition
|
||||||
|
|
|
@ -253,7 +253,7 @@
|
||||||
(try
|
(try
|
||||||
(bean/->clj ((gobj/get caret-pos "position") input))
|
(bean/->clj ((gobj/get caret-pos "position") input))
|
||||||
(catch js/Error e
|
(catch js/Error e
|
||||||
nil)))
|
(js/console.error e))))
|
||||||
|
|
||||||
(defn minimize-html
|
(defn minimize-html
|
||||||
[s]
|
[s]
|
||||||
|
@ -434,11 +434,11 @@
|
||||||
|
|
||||||
(defn textarea-cursor-first-row?
|
(defn textarea-cursor-first-row?
|
||||||
[input line-height]
|
[input line-height]
|
||||||
(< (:top (get-caret-pos input)) line-height))
|
(<= (:top (get-caret-pos input)) line-height))
|
||||||
|
|
||||||
(defn textarea-cursor-end-row?
|
(defn textarea-cursor-end-row?
|
||||||
[input line-height]
|
[input line-height]
|
||||||
(> (+ (:top (get-caret-pos input)) line-height)
|
(>= (+ (:top (get-caret-pos input)) line-height)
|
||||||
(get-textarea-height input)))
|
(get-textarea-height input)))
|
||||||
|
|
||||||
(defn safe-split-first [pattern s]
|
(defn safe-split-first [pattern s]
|
||||||
|
|
Loading…
Reference in New Issue