mirror of
https://github.com/penpot/penpot.git
synced 2025-03-20 19:51:23 -05:00
Add specific selection handler for text edition.
This commit is contained in:
parent
b00992881c
commit
20e7afeee5
2 changed files with 25 additions and 10 deletions
|
@ -5,8 +5,7 @@
|
|||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.main.ui.shapes.common
|
||||
(:require [sablono.core :refer-macros [html]]
|
||||
[lentes.core :as l]
|
||||
(:require [lentes.core :as l]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]
|
||||
[uxbox.store :as st]
|
||||
|
@ -20,7 +19,6 @@
|
|||
|
||||
;; --- Refs
|
||||
|
||||
;; (defonce edition-ref (atom nil))
|
||||
(def edition-ref
|
||||
(-> (l/in [:workspace :edition])
|
||||
(l/derive st/state)))
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
(-> (l/lens focus-selected-shapes)
|
||||
(l/derive st/state)))
|
||||
|
||||
(def edition-ref scommon/edition-ref)
|
||||
(def ^:private edition-ref scommon/edition-ref)
|
||||
|
||||
;; --- Resize Implementation
|
||||
|
||||
|
@ -362,22 +362,39 @@
|
|||
shape (geom/selection-rect shape)]
|
||||
(controls shape zoom on-click)))
|
||||
|
||||
(mx/defc text-edition-selection-handlers
|
||||
{:mixins [mx/static]}
|
||||
[{:keys [id] :as shape} zoom]
|
||||
(let [{:keys [x1 y1 width height] :as shape} (geom/selection-rect shape)]
|
||||
[:g.controls
|
||||
[:rect.main {:x x1 :y y1
|
||||
:width width
|
||||
:height height
|
||||
;; :stroke-dasharray (str (/ 5.0 zoom) "," (/ 5 zoom))
|
||||
:style {:stroke "#333"
|
||||
:stroke-width "0.5"
|
||||
:stroke-opacity "0.5"
|
||||
:fill "transparent"}}]]))
|
||||
|
||||
(mx/defc selection-handlers
|
||||
{:mixins [mx/reactive mx/static]}
|
||||
[]
|
||||
(let [shapes (mx/react selected-shapes-ref)
|
||||
edition (mx/react scommon/edition-ref)
|
||||
edition? (mx/react edition-ref)
|
||||
zoom (mx/react wb/zoom-ref)
|
||||
shapes-num (count shapes)
|
||||
shape (first shapes)]
|
||||
num (count shapes)
|
||||
{:keys [type] :as shape} (first shapes)]
|
||||
(cond
|
||||
(zero? shapes-num)
|
||||
(zero? num)
|
||||
nil
|
||||
|
||||
(> shapes-num 1)
|
||||
(> num 1)
|
||||
(multiple-selection-handlers shapes zoom)
|
||||
|
||||
(= :path (:type shape))
|
||||
(and (= type :text) edition?)
|
||||
(text-edition-selection-handlers shape zoom)
|
||||
|
||||
(= type :path)
|
||||
(if (= @edition-ref (:id shape))
|
||||
(path-edition-selection-handlers shape zoom)
|
||||
(single-selection-handlers shape zoom))
|
||||
|
|
Loading…
Add table
Reference in a new issue