From 75e8d226d9c1e78f49296382214768dadd9c0b8d Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 18 Feb 2026 13:33:57 +0100 Subject: [PATCH] :sparkles: Add textBounds property in plugins --- frontend/src/app/plugins/format.cljs | 7 +++++++ frontend/src/app/plugins/text.cljs | 6 +++++- plugins/libs/plugin-types/index.d.ts | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/plugins/format.cljs b/frontend/src/app/plugins/format.cljs index 72652d2574..6567de30f9 100644 --- a/frontend/src/app/plugins/format.cljs +++ b/frontend/src/app/plugins/format.cljs @@ -598,3 +598,10 @@ (case axis :y "horizontal" :x "vertical")) + +(defn format-geom-rect + [{:keys [x y width height]}] + #js {:x x + :y y + :width width + :height height}) diff --git a/frontend/src/app/plugins/text.cljs b/frontend/src/app/plugins/text.cljs index 1a1e83ac20..36828324b2 100644 --- a/frontend/src/app/plugins/text.cljs +++ b/frontend/src/app/plugins/text.cljs @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] + [app.common.geom.shapes.text :as gst] [app.common.record :as crc] [app.common.schema :as sm] [app.common.types.shape :as cts] @@ -651,4 +652,7 @@ (u/display-not-valid :verticalAlign "Plugin doesn't have 'content:write' permission") :else - (st/emit! (dwt/update-attrs id {:vertical-align value})))))})) + (st/emit! (dwt/update-attrs id {:vertical-align value})))))} + + {:name "textBounds" + :get #(-> % u/proxy->shape gst/shape->bounds format/format-geom-rect)})) diff --git a/plugins/libs/plugin-types/index.d.ts b/plugins/libs/plugin-types/index.d.ts index c992e5035d..cd397051ee 100644 --- a/plugins/libs/plugin-types/index.d.ts +++ b/plugins/libs/plugin-types/index.d.ts @@ -4127,6 +4127,12 @@ export interface Text extends ShapeBase { */ verticalAlign: 'top' | 'center' | 'bottom' | null; + /** + * Return the bounding box for the text as a (x, y, width, height) rectangle + * This is the box that covers the text even if it overflows its selection rectangle. + */ + readonly textBounds: { x: number; y: number; width: number; height: number }; + /** * Gets a text range within the text shape. * @param start - The start index of the text range.