Add textBounds property in plugins

This commit is contained in:
alonso.torres 2026-02-18 13:33:57 +01:00 committed by Alonso Torres
parent d42f5db1f0
commit 75e8d226d9
3 changed files with 18 additions and 1 deletions

View File

@ -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})

View File

@ -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)}))

View File

@ -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.