mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
🐛 Fix text edition.
This commit is contained in:
parent
26b2b89b69
commit
040dd73599
5 changed files with 44 additions and 41 deletions
|
@ -1832,7 +1832,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(->> stream
|
||||
(rx/filter #(= % :interrupt))
|
||||
(rx/filter interrupt?)
|
||||
(rx/take 1)
|
||||
(rx/map (constantly clear-edition-mode))))))
|
||||
|
||||
|
@ -2428,7 +2428,7 @@
|
|||
"ctrl+t" #(st/emit! (select-for-drawing :text))
|
||||
"ctrl+c" #(st/emit! copy-selected)
|
||||
"ctrl+v" #(st/emit! paste)
|
||||
"esc" #(st/emit! :interrupt deselect-all)
|
||||
"escape" #(st/emit! :interrupt deselect-all)
|
||||
"del" #(st/emit! delete-selected)
|
||||
"ctrl+up" #(st/emit! (vertical-order-selected :up))
|
||||
"ctrl+down" #(st/emit! (vertical-order-selected :down))
|
||||
|
|
|
@ -60,44 +60,43 @@
|
|||
(rx/of (dw/materialize-frame-displacement frame-id)))))))
|
||||
|
||||
(defn on-mouse-down
|
||||
([event shape] (on-mouse-down event shape nil))
|
||||
([event {:keys [id type] :as shape} kk-tmp]
|
||||
(let [selected @refs/selected-shapes
|
||||
selected? (contains? selected id)
|
||||
drawing? @refs/selected-drawing-tool
|
||||
button (.-which (.-nativeEvent event))]
|
||||
(when-not (:blocked shape)
|
||||
(cond
|
||||
(not= 1 button)
|
||||
nil
|
||||
[event {:keys [id type] :as shape}]
|
||||
(let [selected @refs/selected-shapes
|
||||
selected? (contains? selected id)
|
||||
drawing? @refs/selected-drawing-tool
|
||||
button (.-which (.-nativeEvent event))]
|
||||
(when-not (:blocked shape)
|
||||
(cond
|
||||
(not= 1 button)
|
||||
nil
|
||||
|
||||
drawing?
|
||||
nil
|
||||
drawing?
|
||||
nil
|
||||
|
||||
(= type :frame)
|
||||
(when selected?
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! start-move-frame))
|
||||
(= type :frame)
|
||||
(when selected?
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! start-move-frame))
|
||||
|
||||
(and (not selected?) (empty? selected))
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! dw/deselect-all
|
||||
(dw/select-shape id)
|
||||
start-move-selected))
|
||||
(and (not selected?) (empty? selected))
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! dw/deselect-all
|
||||
(dw/select-shape id)
|
||||
start-move-selected))
|
||||
|
||||
(and (not selected?) (not (empty? selected)))
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(if (kbd/shift? event)
|
||||
(st/emit! (dw/select-shape id))
|
||||
(st/emit! dw/deselect-all
|
||||
(dw/select-shape id)
|
||||
start-move-selected)))
|
||||
:else
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! start-move-selected)))))))
|
||||
(and (not selected?) (not (empty? selected)))
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(if (kbd/shift? event)
|
||||
(st/emit! (dw/select-shape id))
|
||||
(st/emit! dw/deselect-all
|
||||
(dw/select-shape id)
|
||||
start-move-selected)))
|
||||
:else
|
||||
(do
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! start-move-selected))))))
|
||||
|
||||
|
||||
(defn on-context-menu
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
[{:keys [shape frame] :as props}]
|
||||
(let [selected (mf/deref refs/selected-shapes)
|
||||
selected? (contains? selected (:id shape))
|
||||
on-mouse-down #(common/on-mouse-down % shape selected)]
|
||||
on-mouse-down #(common/on-mouse-down % shape)]
|
||||
[:g.shape {:class (when selected? "selected")
|
||||
:on-mouse-down on-mouse-down}
|
||||
[:& icon-shape {:shape (geom/transform-shape frame shape)}]]))
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
[{:keys [shape frame] :as props}]
|
||||
(let [selected (mf/deref refs/selected-shapes)
|
||||
selected? (contains? selected (:id shape))
|
||||
on-mouse-down #(common/on-mouse-down % shape selected)]
|
||||
on-mouse-down #(common/on-mouse-down % shape)]
|
||||
[:g.shape {:class (when selected? "selected")
|
||||
:on-mouse-down on-mouse-down}
|
||||
[:& image-shape {:shape (geom/transform-shape frame shape)}]]))
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
;; --- Events
|
||||
|
||||
(defn handle-mouse-down
|
||||
[event {:keys [id group] :as shape} selected]
|
||||
[event {:keys [id group] :as shape}]
|
||||
(if (and (not (:blocked shape))
|
||||
(or @refs/selected-drawing-tool
|
||||
@refs/selected-edition))
|
||||
(dom/stop-propagation event)
|
||||
(common/on-mouse-down event shape selected)))
|
||||
(common/on-mouse-down event shape)))
|
||||
|
||||
;; --- Text Wrapper
|
||||
|
||||
|
@ -45,12 +45,16 @@
|
|||
selected? (and (contains? selected id)
|
||||
(= (count selected) 1))
|
||||
|
||||
on-mouse-down #(common/on-mouse-down % shape)
|
||||
on-mouse-down #(handle-mouse-down % shape)
|
||||
on-context-menu #(common/on-context-menu % shape)
|
||||
|
||||
on-double-click
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(dom/prevent-default event)
|
||||
(when selected?
|
||||
(st/emit! (dw/start-edition-mode (:id shape)))))]
|
||||
|
||||
[:g.shape {:on-double-click on-double-click
|
||||
:on-mouse-down on-mouse-down
|
||||
:on-context-menu on-context-menu}
|
||||
|
|
Loading…
Reference in a new issue