🐛 Fix text shape edition mode.

This commit is contained in:
Andrey Antukh 2019-08-24 12:41:11 +02:00
parent eebd56d738
commit 5af263c70e

View file

@ -39,22 +39,17 @@
(declare text-shape-wrapper) (declare text-shape-wrapper)
(declare text-shape-edit) (declare text-shape-edit)
(mf/def text-component (mf/defc text-component
:mixins [mf/memo mf/reactive] [{:keys [shape] :as props}]
:render
(fn [own {:keys [shape] :as props}]
(let [{:keys [id x1 y1 content group]} shape (let [{:keys [id x1 y1 content group]} shape
modifiers (mf/react (refs/selected-modifiers id)) selected (mf/deref refs/selected-shapes)
selected (mf/react refs/selected-shapes) edition (mf/deref refs/selected-edition)
edition? (= (mf/react refs/selected-edition) id) edition? (= edition id)
selected? (and (contains? selected id) selected? (and (contains? selected id)
(= (count selected) 1)) (= (count selected) 1))]
shape (assoc shape :modifiers modifiers)]
(letfn [(on-mouse-down [event] (letfn [(on-mouse-down [event]
(handle-mouse-down event shape selected)) (handle-mouse-down event shape selected))
(on-double-click [event] (on-double-click [event]
;; TODO: handle grouping event propagation
;; TODO: handle actions locking properly
(dom/stop-propagation event) (dom/stop-propagation event)
(st/emit! (udw/start-edition-mode id)))] (st/emit! (udw/start-edition-mode id)))]
[:g.shape {:class (when selected? "selected") [:g.shape {:class (when selected? "selected")
@ -62,7 +57,7 @@
:on-mouse-down on-mouse-down} :on-mouse-down on-mouse-down}
(if edition? (if edition?
[:& text-shape-edit {:shape shape}] [:& text-shape-edit {:shape shape}]
[:& text-shape-wrapper {:shape shape}])])))) [:& text-shape-wrapper {:shape shape}])])))
;; --- Text Styles Helpers ;; --- Text Styles Helpers