     (merge
      {:fontSize (str size "px")
       :color color
+      :whiteSpace "pre"
       :textAlign align
       :fontFamily family
       :fontWeight weight

        attrs (merge props size)
        style (make-style shape)]
    (html
     [:g
      (if (or drawing? editing?)
        [:g
         [:rect (merge attrs +select-rect-attrs+)]])
      [:foreignObject attrs
       [:p {:ref "container" :style style} content]]])))

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

     (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 content] :as shape}]
  (let [key (str id)
        rfm (geom/transformation-matrix shape)
        size (geom/size shape)
