      (when line-height {:lineHeight line-height})
      (when letter-spacing {:letterSpacing letter-spacing}))))
 
+;; --- Text Shape Edit
+
+(defn- text-shape-edit-did-mount
+  [own]
+  (let [[shape] (:rum/props own)
+        dom (mx/get-ref-dom own "container")]
+    (set! (.-textContent dom) (:content shape ""))
+    (.focus dom)
+    own))
+
+(defn- text-shape-edit-render
+  [own {:keys [id x1 y1 content] :as shape} on-done]
+  (let [size (geom/size shape)
+        style (make-style shape)
+        rfm (geom/transformation-matrix shape)
+        props {:x x1 :y y1
+               :transform (str rfm)}
+        props (merge props size)]
+    (letfn [(on-blur [ev]
+              (ui/release-action! "ui.text.edit")
+              (on-done))
+            (on-input [ev]
+              (let [content (dom/event->inner-text ev)
+                    sid (:id (first (:rum/props own)))]
+                (rs/emit! (uds/update-text sid {:content content}))))]
+      (html
+       [:g
+        [:rect (merge props +select-rect-attrs+)]
+        [:foreignObject props
+         [:p {:ref "container"
+              :on-blur on-blur
+              :on-input on-input
+              :contentEditable true
+              :style style}]]]))))
+
+(def text-shape-edit
+  (mx/component
+   {:render text-shape-edit-render
+    :did-mount text-shape-edit-did-mount
+    :name "text-shape-edit"
+    :mixins [mx/static]}))
+
+;; --- Text Shape
+
 (defn- text-shape-render
-  [own {:keys [id x1 y1 x2 y2 content drawing? editing?] :as shape}]
+  [own {:keys [id x1 y1 content] :as shape}]
   (let [key (str id)
         rfm (geom/transformation-matrix shape)
         size (geom/size shape)

            [lentes.core :as l]
            [goog.events :as events]
            [uxbox.rstore :as rs]
            [uxbox.state :as st]
            [uxbox.data.shapes :as uds]
            [uxbox.ui.core :as ui]
            [uxbox.ui.mixins :as mx]
            [uxbox.ui.keyboard :as kbd]
            [uxbox.ui.shapes.common :as common]
            [uxbox.ui.shapes.attrs :as attrs]
            [uxbox.util.geom :as geom]

        attrs (merge props size)
        style (make-style shape)]
    (html
     [:foreignObject attrs
      [:p {:style style} content]])))

(def text-shape
  (mx/component
   {:render text-shape-render
    :name "text-shape"
    :mixins [mx/static]}))
