mirror of
https://github.com/penpot/penpot.git
synced 2025-07-05 14:27:16 +02:00
✨ Add context menu to all shapes.
This commit is contained in:
parent
cae5b5e778
commit
06ec1e00ee
2 changed files with 31 additions and 28 deletions
|
@ -24,17 +24,18 @@
|
||||||
(mf/defc path-wrapper
|
(mf/defc path-wrapper
|
||||||
[{:keys [shape] :as props}]
|
[{:keys [shape] :as props}]
|
||||||
(let [selected (mf/deref refs/selected-shapes)
|
(let [selected (mf/deref refs/selected-shapes)
|
||||||
selected? (contains? selected (:id shape))]
|
selected? (contains? selected (:id shape))
|
||||||
(letfn [(on-mouse-down [event]
|
on-mouse-down #(common/on-mouse-down % shape)
|
||||||
(common/on-mouse-down event shape selected))
|
on-context-menu #(common/on-context-menu % shape)
|
||||||
(on-double-click [event]
|
on-double-click
|
||||||
(when selected?
|
(fn [event]
|
||||||
(st/emit! (dw/start-edition-mode (:id shape)))))]
|
(when selected?
|
||||||
[:g.shape {:class (when selected? "selected")
|
(st/emit! (dw/start-edition-mode (:id shape)))))]
|
||||||
:on-double-click on-double-click
|
[:g.shape {:on-double-click on-double-click
|
||||||
:on-mouse-down on-mouse-down}
|
:on-mouse-down on-mouse-down
|
||||||
[:& path-shape {:shape shape
|
:on-context-menu on-context-menu}
|
||||||
:background? true}]])))
|
[:& path-shape {:shape shape
|
||||||
|
:background? true}]]))
|
||||||
|
|
||||||
;; --- Path Shape
|
;; --- Path Shape
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[rumext.core :as mx]
|
[rumext.core :as mx]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
@ -45,18 +45,20 @@
|
||||||
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))
|
||||||
(letfn [(on-mouse-down [event]
|
|
||||||
(handle-mouse-down event shape selected))
|
on-mouse-down #(common/on-mouse-down % shape)
|
||||||
(on-double-click [event]
|
on-context-menu #(common/on-context-menu % shape)
|
||||||
(dom/stop-propagation event)
|
on-double-click
|
||||||
(st/emit! (udw/start-edition-mode id)))]
|
(fn [event]
|
||||||
[:g.shape {:class (when selected? "selected")
|
(when selected?
|
||||||
:on-double-click on-double-click
|
(st/emit! (dw/start-edition-mode (:id shape)))))]
|
||||||
:on-mouse-down on-mouse-down}
|
[:g.shape {:on-double-click on-double-click
|
||||||
(if edition?
|
:on-mouse-down on-mouse-down
|
||||||
[:& text-shape-edit {:shape shape}]
|
:on-context-menu on-context-menu}
|
||||||
[:& text-shape {:shape shape}])])))
|
(if edition?
|
||||||
|
[:& text-shape-edit {:shape shape}]
|
||||||
|
[:& text-shape {:shape shape}])]))
|
||||||
|
|
||||||
;; --- Text Styles Helpers
|
;; --- Text Styles Helpers
|
||||||
|
|
||||||
|
@ -118,13 +120,13 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [content (-> (mf/ref-val ref)
|
(let [content (-> (mf/ref-val ref)
|
||||||
(dom/get-value))]
|
(dom/get-value))]
|
||||||
(st/emit! (udw/update-shape id {:content content}))))
|
(st/emit! (dw/update-shape id {:content content}))))
|
||||||
|
|
||||||
|
|
||||||
on-blur
|
on-blur
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(st/emit! udw/clear-edition-mode
|
(st/emit! dw/clear-edition-mode
|
||||||
udw/deselect-all))]
|
dw/deselect-all))]
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
#(let [dom (mf/ref-val ref)
|
#(let [dom (mf/ref-val ref)
|
||||||
val (dom/get-value dom)]
|
val (dom/get-value dom)]
|
||||||
|
@ -134,7 +136,7 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [content (-> (mf/ref-val ref)
|
(let [content (-> (mf/ref-val ref)
|
||||||
(dom/get-value))]
|
(dom/get-value))]
|
||||||
(st/emit! (udw/update-shape id {:content content}))))))
|
(st/emit! (dw/update-shape id {:content content}))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue