Fix selection for referenced blocks

pull/645/head
Tienson Qin 2020-08-23 16:22:08 +08:00
parent d558a6bc4c
commit 5885529120
4 changed files with 14 additions and 22 deletions

View File

@ -127,21 +127,6 @@
(js/setTimeout #(state/set-selection-blocks! blocks)
200)))))))
(mixins/listen state js/window "click"
(fn [e]
;; hide context menu
(state/hide-custom-context-menu!)
;; enable scroll
(let [main (d/by-id "main-content")]
(d/remove-class! main "overflow-hidden")
(d/add-class! main "overflow-y-auto"))
(when-not (state/get-selection-start-block)
(editor-handler/clear-selection! e))
(state/set-selection-start-block! nil)))
(mixins/listen state js/window "contextmenu"
(fn [e]
(let [target (gobj/get e "target")

View File

@ -1027,7 +1027,7 @@
(when (and
(not (state/get-selection-start-block))
(= (gobj/get e "buttons") 1))
(state/set-selection-start-block! block-id)))
(when block-id (state/set-selection-start-block! block-id))))
:on-mouse-over (fn [e]
(util/stop e)
(when has-child?

View File

@ -131,6 +131,19 @@
;; TODO: move this to keyboards
(mixins/event-mixin
(fn [state]
(mixins/listen state js/window "click"
(fn [e]
;; hide context menu
(state/hide-custom-context-menu!)
;; enable scroll
(let [main (d/by-id "main-content")]
(d/remove-class! main "overflow-hidden")
(d/add-class! main "overflow-y-auto"))
(if-not (state/get-selection-start-block)
(editor-handler/clear-selection! e)
(state/set-selection-start-block! nil))))
(mixins/on-key-down
state
{

View File

@ -319,12 +319,6 @@
[]
(get @state :selection/start-block))
(defn clear-selection-region!
[]
(swap! state assoc
:selection/start-block nil
:selection/end-block nil))
(defn set-selection-blocks!
[blocks]
(when (seq blocks)