mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
✨ Add textBounds property in plugins
This commit is contained in:
parent
d42f5db1f0
commit
75e8d226d9
@ -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})
|
||||
|
||||
@ -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)}))
|
||||
|
||||
6
plugins/libs/plugin-types/index.d.ts
vendored
6
plugins/libs/plugin-types/index.d.ts
vendored
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user