mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 14:36:10 +02:00
🐛 Fix problem with some data and text input
This commit is contained in:
parent
6e9a77edcd
commit
541168aee4
3 changed files with 46 additions and 24 deletions
|
@ -82,6 +82,7 @@
|
||||||
|
|
||||||
frame? (= :frame type)
|
frame? (= :frame type)
|
||||||
group? (= :group type)
|
group? (= :group type)
|
||||||
|
text? (= :text type)
|
||||||
mask? (and group? masked-group?)]
|
mask? (and group? masked-group?)]
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
|
@ -103,6 +104,10 @@
|
||||||
(dom/query-all shape-defs ".svg-def")
|
(dom/query-all shape-defs ".svg-def")
|
||||||
(dom/query-all shape-defs ".svg-mask-wrapper")))
|
(dom/query-all shape-defs ".svg-mask-wrapper")))
|
||||||
|
|
||||||
|
text?
|
||||||
|
[shape-node
|
||||||
|
(dom/query shape-node ".text-container")]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[shape-node])))
|
[shape-node])))
|
||||||
|
|
||||||
|
@ -185,6 +190,15 @@
|
||||||
(dom/class? node "frame-children")
|
(dom/class? node "frame-children")
|
||||||
(set-transform-att! node "transform" (gmt/inverse transform))
|
(set-transform-att! node "transform" (gmt/inverse transform))
|
||||||
|
|
||||||
|
(dom/class? node "text-container")
|
||||||
|
(let [modifiers (dissoc modifiers :displacement :rotation)]
|
||||||
|
(when (not (gsh/empty-modifiers? modifiers))
|
||||||
|
(let [mtx (-> shape
|
||||||
|
(assoc :modifiers modifiers)
|
||||||
|
(gsh/transform-shape)
|
||||||
|
(gsh/transform-matrix {:no-flip true}))]
|
||||||
|
(override-transform-att! node "transform" mtx))))
|
||||||
|
|
||||||
(or (= (dom/get-tag-name node) "mask")
|
(or (= (dom/get-tag-name node) "mask")
|
||||||
(= (dom/get-tag-name node) "filter"))
|
(= (dom/get-tag-name node) "filter"))
|
||||||
(transform-region! node modifiers)
|
(transform-region! node modifiers)
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
(ns app.main.ui.workspace.shapes.text.editor
|
(ns app.main.ui.workspace.shapes.text.editor
|
||||||
(:require
|
(:require
|
||||||
["draft-js" :as draft]
|
["draft-js" :as draft]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.common.geom.shapes.text :as gsht]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.texts :as dwt]
|
[app.main.data.workspace.texts :as dwt]
|
||||||
|
@ -255,30 +256,37 @@
|
||||||
(-> (gpt/subtract pt box)
|
(-> (gpt/subtract pt box)
|
||||||
(gpt/multiply zoom)))))
|
(gpt/multiply zoom)))))
|
||||||
|
|
||||||
(mf/defc text-editor-viewport
|
(mf/defc text-editor-svg
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (obj/get props "shape")
|
(let [shape (obj/get props "shape")
|
||||||
viewport-ref (obj/get props "viewport-ref")
|
|
||||||
zoom (obj/get props "zoom")
|
|
||||||
|
|
||||||
position
|
clip-id
|
||||||
(-> (gpt/point (-> shape :selrect :x)
|
(dm/str "text-edition-clip" (:id shape))
|
||||||
(-> shape :selrect :y))
|
|
||||||
(translate-point-from-viewport (mf/ref-val viewport-ref) zoom))
|
|
||||||
|
|
||||||
top-left-corner (gpt/point (/ (:width shape) 2) (/ (:height shape) 2))
|
text-modifier-ref
|
||||||
|
(mf/use-memo (mf/deps (:id shape)) #(refs/workspace-text-modifier-by-id (:id shape)))
|
||||||
|
|
||||||
transform
|
text-modifier
|
||||||
(-> (gmt/matrix)
|
(mf/deref text-modifier-ref)
|
||||||
(gmt/scale (gpt/point zoom))
|
|
||||||
(gmt/multiply (gsh/transform-matrix shape nil top-left-corner)))]
|
|
||||||
|
|
||||||
[:div {:style {:position "absolute"
|
bounding-box
|
||||||
:left (str (:x position) "px")
|
(gsht/position-data-bounding-box text-modifier)]
|
||||||
:top (str (:y position) "px")
|
|
||||||
:pointer-events "all"
|
|
||||||
:transform (str transform)
|
|
||||||
:transform-origin "left top"}}
|
|
||||||
|
|
||||||
[:& text-shape-edit-html {:shape shape :key (str (:id shape))}]]))
|
[:g.text-editor {:clip-path (dm/fmt "url(#%)" clip-id)
|
||||||
|
:transform (dm/str (gsh/transform-matrix shape))}
|
||||||
|
[:defs
|
||||||
|
[:clipPath {:id clip-id}
|
||||||
|
[:rect {:x (min (:x bounding-box) (:x shape))
|
||||||
|
:y (min (:y bounding-box) (:y shape))
|
||||||
|
:width (max (:width bounding-box) (:width shape))
|
||||||
|
:height (max (:height bounding-box) (:height shape))
|
||||||
|
:fill "red"}]]]
|
||||||
|
|
||||||
|
[:foreignObject {:x (:x shape) :y (:y shape) :width "100%" :height "100%"
|
||||||
|
:externalResourcesRequired true}
|
||||||
|
[:div {:style {:position "absolute"
|
||||||
|
:left 0
|
||||||
|
:top 0
|
||||||
|
:pointer-events "all"}}
|
||||||
|
[:& text-shape-edit-html {:shape shape :key (str (:id shape))}]]]]))
|
||||||
|
|
|
@ -187,10 +187,7 @@
|
||||||
|
|
||||||
[:div.viewport
|
[:div.viewport
|
||||||
[:div.viewport-overlays {:ref overlays-ref}
|
[:div.viewport-overlays {:ref overlays-ref}
|
||||||
(when show-text-editor?
|
|
||||||
[:& editor/text-editor-viewport {:shape editing-shape
|
|
||||||
:viewport-ref viewport-ref
|
|
||||||
:zoom zoom}])
|
|
||||||
(when show-comments?
|
(when show-comments?
|
||||||
[:& comments/comments-layer {:vbox vbox
|
[:& comments/comments-layer {:vbox vbox
|
||||||
:vport vport
|
:vport vport
|
||||||
|
@ -275,6 +272,9 @@
|
||||||
:on-pointer-up on-pointer-up}
|
:on-pointer-up on-pointer-up}
|
||||||
|
|
||||||
[:g {:style {:pointer-events (if disable-events? "none" "auto")}}
|
[:g {:style {:pointer-events (if disable-events? "none" "auto")}}
|
||||||
|
(when show-text-editor?
|
||||||
|
[:& editor/text-editor-svg {:shape editing-shape}])
|
||||||
|
|
||||||
(when show-outlines?
|
(when show-outlines?
|
||||||
[:& outline/shape-outlines
|
[:& outline/shape-outlines
|
||||||
{:objects base-objects
|
{:objects base-objects
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue