From 360937f6137b01757c8c3788a1a3bdd0b9faf538 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 19 Feb 2026 12:00:05 +0100 Subject: [PATCH] :bug: Fix problem with empty text --- .../src/app/common/files/changes_builder.cljc | 40 +++++++++---------- .../src/app/main/data/workspace/shapes.cljs | 11 ++--- .../src/app/main/data/workspace/texts.cljs | 10 ++--- .../app/main/data/workspace/wasm_text.cljs | 39 +++++++++--------- 4 files changed, 51 insertions(+), 49 deletions(-) diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index 3480e6432c..93ac58d03b 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -605,31 +605,31 @@ add-undo-change-shape (fn [change-set id] (let [shape (get objects id)] - (conj - change-set - {:type :add-obj - :id id - :page-id page-id - :parent-id (:parent-id shape) - :frame-id (:frame-id shape) - :index (cfh/get-position-on-parent objects id) - :obj (cond-> shape - (contains? shape :shapes) - (assoc :shapes []))}))) + (cond-> change-set + (some? shape) + (conj {:type :add-obj + :id id + :page-id page-id + :parent-id (:parent-id shape) + :frame-id (:frame-id shape) + :index (cfh/get-position-on-parent objects id) + :obj (cond-> shape + (contains? shape :shapes) + (assoc :shapes []))})))) add-undo-change-parent (fn [change-set id] (let [shape (get objects id) prev-sibling (cfh/get-prev-sibling objects (:id shape))] - (conj - change-set - {:type :mov-objects - :page-id page-id - :parent-id (:parent-id shape) - :shapes [id] - :after-shape prev-sibling - :index 0 - :ignore-touched true})))] + (cond-> change-set + (some? shape) + (conj {:type :mov-objects + :page-id page-id + :parent-id (:parent-id shape) + :shapes [id] + :after-shape prev-sibling + :index 0 + :ignore-touched true}))))] (-> changes (update :redo-changes #(reduce add-redo-change % ids)) diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 06981f7bb9..b93258a869 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -197,11 +197,12 @@ objects (:objects page) undo-id (or (:undo-id options) (js/Symbol)) - [all-parents changes] (-> (pcb/empty-changes it (:id page)) - (cls/generate-delete-shapes fdata page objects ids - {:ignore-touched (:allow-altering-copies options) - :undo-group (:undo-group options) - :undo-id undo-id}))] + [all-parents changes] + (-> (pcb/empty-changes it (:id page)) + (cls/generate-delete-shapes fdata page objects ids + {:ignore-touched (:allow-altering-copies options) + :undo-group (:undo-group options) + :undo-id undo-id}))] (rx/of (dwu/start-undo-transaction undo-id) (dc/detach-comment-thread ids) diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index 6abc8fddc7..421b29d4d0 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -952,11 +952,11 @@ new-shape)) {:save-undo? save-undo? :undo-group (when new-shape? id)}) - (let [modifiers (dwwt/resize-wasm-text-modifiers shape content) - options {:undo-group (when new-shape? id)}] - (if (and (not= :fixed (:grow-type shape)) finalize?) - (dwm/apply-wasm-modifiers modifiers options) - (dwm/set-wasm-modifiers modifiers options)))) + (when-let [modifiers (dwwt/resize-wasm-text-modifiers shape content)] + (let [options {:undo-group (when new-shape? id)}] + (if (and (not= :fixed (:grow-type shape)) finalize?) + (dwm/apply-wasm-modifiers modifiers options) + (dwm/set-wasm-modifiers modifiers options))))) (when finalize? (rx/concat diff --git a/frontend/src/app/main/data/workspace/wasm_text.cljs b/frontend/src/app/main/data/workspace/wasm_text.cljs index ee262123cf..594a657105 100644 --- a/frontend/src/app/main/data/workspace/wasm_text.cljs +++ b/frontend/src/app/main/data/workspace/wasm_text.cljs @@ -27,27 +27,28 @@ (resize-wasm-text-modifiers shape (:content shape))) ([{:keys [id points selrect grow-type] :as shape} content] - (wasm.api/use-shape id) - (wasm.api/set-shape-text-content id content) - (wasm.api/set-shape-text-images id content) + (when id + (wasm.api/use-shape id) + (wasm.api/set-shape-text-content id content) + (wasm.api/set-shape-text-images id content) - (let [dimension (wasm.api/get-text-dimensions) - width-scale (if (#{:fixed :auto-height} grow-type) - 1.0 - (/ (:width dimension) (:width selrect))) - height-scale (if (= :fixed grow-type) - 1.0 - (/ (:height dimension) (:height selrect))) - resize-v (gpt/point width-scale height-scale) - origin (first points)] + (let [dimension (wasm.api/get-text-dimensions) + width-scale (if (#{:fixed :auto-height} grow-type) + 1.0 + (/ (:width dimension) (:width selrect))) + height-scale (if (= :fixed grow-type) + 1.0 + (/ (:height dimension) (:height selrect))) + resize-v (gpt/point width-scale height-scale) + origin (first points)] - {id - {:modifiers - (ctm/resize-modifiers - resize-v - origin - (:transform shape (gmt/matrix)) - (:transform-inverse shape (gmt/matrix)))}}))) + {id + {:modifiers + (ctm/resize-modifiers + resize-v + origin + (:transform shape (gmt/matrix)) + (:transform-inverse shape (gmt/matrix)))}})))) (defn resize-wasm-text "Resize a single text shape (auto-width/auto-height) by id.