diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 21406795d..a58bf8aa5 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -314,37 +314,41 @@ [redo-changes undo-changes]))) (defn add-shape - [attrs] - (us/verify ::shape-attrs attrs) - (ptk/reify ::add-shape - ptk/WatchEvent - (watch [it state _] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) + ([attrs] + (add-shape attrs {})) - id (or (:id attrs) (uuid/next)) - name (-> objects - (retrieve-used-names) - (generate-unique-name (:name attrs))) + ([attrs {:keys [no-select?]}] + (us/verify ::shape-attrs attrs) + (ptk/reify ::add-shape + ptk/WatchEvent + (watch [it state _] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) - selected (wsh/lookup-selected state) + id (or (:id attrs) (uuid/next)) + name (-> objects + (retrieve-used-names) + (generate-unique-name (:name attrs))) - [rchanges uchanges] (add-shape-changes - page-id - objects - selected - (-> attrs - (assoc :id id ) - (assoc :name name)))] + selected (wsh/lookup-selected state) - (rx/concat - (rx/of (dch/commit-changes {:redo-changes rchanges - :undo-changes uchanges - :origin it}) - (select-shapes (d/ordered-set id))) - (when (= :text (:type attrs)) - (->> (rx/of (start-edition-mode id)) - (rx/observe-on :async)))))))) + [rchanges uchanges] (add-shape-changes + page-id + objects + selected + (-> attrs + (assoc :id id ) + (assoc :name name)))] + + (rx/concat + (rx/of (dch/commit-changes {:redo-changes rchanges + :undo-changes uchanges + :origin it}) + (when-not no-select? + (select-shapes (d/ordered-set id)))) + (when (= :text (:type attrs)) + (->> (rx/of (start-edition-mode id)) + (rx/observe-on :async))))))))) (defn move-shapes-into-frame [frame-id shapes] (ptk/reify ::move-shapes-into-frame diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 1fc7186e9..522d0150a 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -42,6 +42,15 @@ (when (= tool :path) (rx/of (start-drawing :path))) + (when (= tool :curve) + (let [stopper (->> stream (rx/filter dwc/interrupt?))] + (->> stream + (rx/take-until stopper) + (rx/filter (ptk/type? ::common/handle-finish-drawing)) + (rx/take 1) + (rx/observe-on :async) + (rx/map #(select-for-drawing tool data))))) + ;; NOTE: comments are a special case and they manage they ;; own interrupt cycle.q (when (and (not= tool :comments) diff --git a/frontend/src/app/main/data/workspace/drawing/common.cljs b/frontend/src/app/main/data/workspace/drawing/common.cljs index fb93c6f5c..624bbf308 100644 --- a/frontend/src/app/main/data/workspace/drawing/common.cljs +++ b/frontend/src/app/main/data/workspace/drawing/common.cljs @@ -24,7 +24,8 @@ (ptk/reify ::handle-finish-drawing ptk/WatchEvent (watch [_ state _] - (let [shape (get-in state [:workspace-drawing :object])] + (let [tool (get-in state [:workspace-drawing :tool]) + shape (get-in state [:workspace-drawing :object])] (rx/concat (when (:initialized? shape) (let [page-id (:current-page-id state) @@ -55,7 +56,7 @@ (rx/of (dwu/start-undo-transaction)) (rx/empty)) - (rx/of (dwc/add-shape shape)) + (rx/of (dwc/add-shape shape {:no-select? (= tool :curve)})) (if (= :frame (:type shape)) (->> (uw/ask! {:cmd :selection/query diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 35e8f44b1..f88972c48 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -142,7 +142,7 @@ show-draw-area? drawing-obj show-gradient-handlers? (= (count selected) 1) show-grids? (contains? layout :display-grid) - show-outlines? (and (nil? transform) (not edition) (not drawing-obj) (not (#{:comments :path} drawing-tool))) + show-outlines? (and (nil? transform) (not edition) (not drawing-obj) (not (#{:comments :path :curve} drawing-tool))) show-pixel-grid? (>= zoom 8) show-presence? page-id show-prototypes? (= options-mode :prototype)