💄 Cosmetic changes on text shape component.

This commit is contained in:
Andrey Antukh 2020-01-08 17:05:00 +01:00
parent b0da06bad4
commit 863c26a056

View file

@ -106,35 +106,19 @@
;; --- Text Shape Edit ;; --- Text Shape Edit
(mf/def text-shape-edit (mf/defc text-shape-edit
:mixins [mf/memo] [{:keys [shape] :as props}]
(let [ref (mf/use-ref)
:init {:keys [id x y width height content]} shape]
(fn [own props] (mf/use-effect
(assoc own ::container (mf/create-ref))) #(fn []
(let [content (-> (mf/ref-val ref)
:did-mount (dom/get-value))]
(fn [own] (st/emit! (udw/update-shape id {:content content})))))
(let [shape (get-in own [::mf/props :shape]) [:foreignObject {:x x :y y :width width :height height}
dom (mf/ref-node (::container own))] [:textarea {:style (make-style shape)
(set! (.-textContent dom) (:content shape "")) :default-value content
(.focus dom) :ref ref}]]))
own))
:will-unmount
(fn [own]
(let [dom (mf/ref-val (::container own))
shape (get-in own [::mf/props :shape])
content (dom/get-value dom)]
(st/emit! (udw/update-shape (:id shape) {:content content}))
own))
:render
(fn [own {:keys [shape] :as props}]
(let [{:keys [id x y content width height]} shape]
[:foreignObject {:x x :y y :width width :height height}
[:textarea {:style (make-style shape)
:ref (::container own)}]])))
;; --- Text Shape Wrapper ;; --- Text Shape Wrapper