mirror of
https://github.com/penpot/penpot.git
synced 2026-09-10 22:19:19 +00:00
Merge pull request #8413 from penpot/alotor-fix-error-emtpy-text
🐛 Fix problem with empty text
This commit is contained in:
commit
cb5cacbcee
@ -605,31 +605,31 @@
|
|||||||
add-undo-change-shape
|
add-undo-change-shape
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
(let [shape (get objects id)]
|
(let [shape (get objects id)]
|
||||||
(conj
|
(cond-> change-set
|
||||||
change-set
|
(some? shape)
|
||||||
{:type :add-obj
|
(conj {:type :add-obj
|
||||||
:id id
|
:id id
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:parent-id (:parent-id shape)
|
:parent-id (:parent-id shape)
|
||||||
:frame-id (:frame-id shape)
|
:frame-id (:frame-id shape)
|
||||||
:index (cfh/get-position-on-parent objects id)
|
:index (cfh/get-position-on-parent objects id)
|
||||||
:obj (cond-> shape
|
:obj (cond-> shape
|
||||||
(contains? shape :shapes)
|
(contains? shape :shapes)
|
||||||
(assoc :shapes []))})))
|
(assoc :shapes []))}))))
|
||||||
|
|
||||||
add-undo-change-parent
|
add-undo-change-parent
|
||||||
(fn [change-set id]
|
(fn [change-set id]
|
||||||
(let [shape (get objects id)
|
(let [shape (get objects id)
|
||||||
prev-sibling (cfh/get-prev-sibling objects (:id shape))]
|
prev-sibling (cfh/get-prev-sibling objects (:id shape))]
|
||||||
(conj
|
(cond-> change-set
|
||||||
change-set
|
(some? shape)
|
||||||
{:type :mov-objects
|
(conj {:type :mov-objects
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:parent-id (:parent-id shape)
|
:parent-id (:parent-id shape)
|
||||||
:shapes [id]
|
:shapes [id]
|
||||||
:after-shape prev-sibling
|
:after-shape prev-sibling
|
||||||
:index 0
|
:index 0
|
||||||
:ignore-touched true})))]
|
:ignore-touched true}))))]
|
||||||
|
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes #(reduce add-redo-change % ids))
|
(update :redo-changes #(reduce add-redo-change % ids))
|
||||||
|
|||||||
@ -197,11 +197,12 @@
|
|||||||
objects (:objects page)
|
objects (:objects page)
|
||||||
|
|
||||||
undo-id (or (:undo-id options) (js/Symbol))
|
undo-id (or (:undo-id options) (js/Symbol))
|
||||||
[all-parents changes] (-> (pcb/empty-changes it (:id page))
|
[all-parents changes]
|
||||||
(cls/generate-delete-shapes fdata page objects ids
|
(-> (pcb/empty-changes it (:id page))
|
||||||
{:ignore-touched (:allow-altering-copies options)
|
(cls/generate-delete-shapes fdata page objects ids
|
||||||
:undo-group (:undo-group options)
|
{:ignore-touched (:allow-altering-copies options)
|
||||||
:undo-id undo-id}))]
|
:undo-group (:undo-group options)
|
||||||
|
:undo-id undo-id}))]
|
||||||
|
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dc/detach-comment-thread ids)
|
(dc/detach-comment-thread ids)
|
||||||
|
|||||||
@ -952,11 +952,11 @@
|
|||||||
new-shape))
|
new-shape))
|
||||||
{:save-undo? save-undo? :undo-group (when new-shape? id)})
|
{:save-undo? save-undo? :undo-group (when new-shape? id)})
|
||||||
|
|
||||||
(let [modifiers (dwwt/resize-wasm-text-modifiers shape content)
|
(when-let [modifiers (dwwt/resize-wasm-text-modifiers shape content)]
|
||||||
options {:undo-group (when new-shape? id)}]
|
(let [options {:undo-group (when new-shape? id)}]
|
||||||
(if (and (not= :fixed (:grow-type shape)) finalize?)
|
(if (and (not= :fixed (:grow-type shape)) finalize?)
|
||||||
(dwm/apply-wasm-modifiers modifiers options)
|
(dwm/apply-wasm-modifiers modifiers options)
|
||||||
(dwm/set-wasm-modifiers modifiers options))))
|
(dwm/set-wasm-modifiers modifiers options)))))
|
||||||
|
|
||||||
(when finalize?
|
(when finalize?
|
||||||
(rx/concat
|
(rx/concat
|
||||||
|
|||||||
@ -27,27 +27,28 @@
|
|||||||
(resize-wasm-text-modifiers shape (:content shape)))
|
(resize-wasm-text-modifiers shape (:content shape)))
|
||||||
|
|
||||||
([{:keys [id points selrect grow-type] :as shape} content]
|
([{:keys [id points selrect grow-type] :as shape} content]
|
||||||
(wasm.api/use-shape id)
|
(when id
|
||||||
(wasm.api/set-shape-text-content id content)
|
(wasm.api/use-shape id)
|
||||||
(wasm.api/set-shape-text-images id content)
|
(wasm.api/set-shape-text-content id content)
|
||||||
|
(wasm.api/set-shape-text-images id content)
|
||||||
|
|
||||||
(let [dimension (wasm.api/get-text-dimensions)
|
(let [dimension (wasm.api/get-text-dimensions)
|
||||||
width-scale (if (#{:fixed :auto-height} grow-type)
|
width-scale (if (#{:fixed :auto-height} grow-type)
|
||||||
1.0
|
1.0
|
||||||
(/ (:width dimension) (:width selrect)))
|
(/ (:width dimension) (:width selrect)))
|
||||||
height-scale (if (= :fixed grow-type)
|
height-scale (if (= :fixed grow-type)
|
||||||
1.0
|
1.0
|
||||||
(/ (:height dimension) (:height selrect)))
|
(/ (:height dimension) (:height selrect)))
|
||||||
resize-v (gpt/point width-scale height-scale)
|
resize-v (gpt/point width-scale height-scale)
|
||||||
origin (first points)]
|
origin (first points)]
|
||||||
|
|
||||||
{id
|
{id
|
||||||
{:modifiers
|
{:modifiers
|
||||||
(ctm/resize-modifiers
|
(ctm/resize-modifiers
|
||||||
resize-v
|
resize-v
|
||||||
origin
|
origin
|
||||||
(:transform shape (gmt/matrix))
|
(:transform shape (gmt/matrix))
|
||||||
(:transform-inverse shape (gmt/matrix)))}})))
|
(:transform-inverse shape (gmt/matrix)))}}))))
|
||||||
|
|
||||||
(defn resize-wasm-text
|
(defn resize-wasm-text
|
||||||
"Resize a single text shape (auto-width/auto-height) by id.
|
"Resize a single text shape (auto-width/auto-height) by id.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user