🐛 Fix text shape edition mode after creation.

This commit is contained in:
Andrey Antukh 2020-07-21 15:05:40 +02:00 committed by Hirunatan
parent 36f4948ad1
commit 86b5ed48fd
3 changed files with 16 additions and 14 deletions

View file

@ -35,6 +35,7 @@
[uxbox.common.geom.point :as gpt] [uxbox.common.geom.point :as gpt]
[uxbox.common.geom.shapes :as geom] [uxbox.common.geom.shapes :as geom]
[uxbox.common.math :as mth] [uxbox.common.math :as mth]
[uxbox.util.timers :as ts]
[uxbox.util.router :as rt] [uxbox.util.router :as rt]
[uxbox.util.transit :as t] [uxbox.util.transit :as t]
[uxbox.util.webapi :as wapi])) [uxbox.util.webapi :as wapi]))
@ -464,10 +465,11 @@
uchange {:type :del-obj uchange {:type :del-obj
:id id}] :id id}]
(rx/of (dwc/commit-changes [rchange] [uchange] {:commit-local? true}) (rx/concat
(dws/select-shapes (d/ordered-set id)) (rx/of (dwc/commit-changes [rchange] [uchange] {:commit-local? true})
(when (= :text (:type attrs)) (dws/select-shapes (d/ordered-set id)))
(start-edition-mode id))))))) (->> (rx/of (start-edition-mode id))
(rx/observe-on :async)))))))
(defn- calculate-centered-box (defn- calculate-centered-box
[state aspect-ratio] [state aspect-ratio]

View file

@ -12,15 +12,15 @@
(:require (:require
[beicon.core :as rx] [beicon.core :as rx]
[potok.core :as ptk] [potok.core :as ptk]
[uxbox.main.data.workspace :as dw]
[uxbox.common.geom.shapes :as geom]
[uxbox.common.geom.point :as gpt] [uxbox.common.geom.point :as gpt]
[uxbox.common.geom.shapes :as geom]
[uxbox.common.pages :as cp] [uxbox.common.pages :as cp]
[uxbox.common.pages-helpers :as cph] [uxbox.common.pages-helpers :as cph]
[uxbox.util.geom.path :as path] [uxbox.common.uuid :as uuid]
[uxbox.main.data.workspace :as dw]
[uxbox.main.snap :as snap] [uxbox.main.snap :as snap]
[uxbox.main.streams :as ms] [uxbox.main.streams :as ms]
[uxbox.common.uuid :as uuid])) [uxbox.util.geom.path :as path]))
(declare handle-drawing) (declare handle-drawing)
(declare handle-drawing-generic) (declare handle-drawing-generic)

View file

@ -51,15 +51,15 @@
(mf/defc text-wrapper (mf/defc text-wrapper
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [shape (unchecked-get props "shape") (let [{:keys [id x1 y1 content group] :as shape} (unchecked-get props "shape")
{:keys [id x1 y1 content group]} shape
selected (mf/deref refs/selected-shapes) selected (mf/deref refs/selected-shapes)
edition (mf/deref refs/selected-edition) edition (mf/deref refs/selected-edition)
edition? (= edition id) edition? (= edition id)
selected? (and (contains? selected id) selected? (and (contains? selected id)
(= (count selected) 1)) (= (count selected) 1))
on-mouse-down #(handle-mouse-down % shape) on-mouse-down #(handle-mouse-down % shape)
on-context-menu #(common/on-context-menu % shape) on-context-menu #(common/on-context-menu % shape)
on-double-click on-double-click