AI-native design editor. Open-source Figma alternative.
feat(figma-api): create shapes with text and set their kind and label from scripts (#1325)
Niraj Sangani31bed1afab03
diff --git a/changes/1325/added.md b/changes/1325/added.mdnew file mode 100644index 000000000..0c19d7b8f--- /dev/null+++ b/changes/1325/added.md@@ -0,0 +1 @@+- Scripts can create shapes with text and read or set their kind and label: `figma.createShapeWithText()`, `shapeType` (refusing kinds FigJam does not have), and `text` as the label's text node (#1114).diff --git a/packages/core/src/editor/shapes/defaults.ts b/packages/core/src/editor/shapes/defaults.tsindex a7d63b201..6810e9579 100644--- a/packages/core/src/editor/shapes/defaults.ts+++ b/packages/core/src/editor/shapes/defaults.ts@@ -3,7 +3,7 @@ import {DEFAULT_STROKE_WEIGHT,figJamColor,figJamPairedStroke,- SHAPE_WITH_TEXT_TOOL_SIZE+ SHAPE_WITH_TEXT_SIZE} from '@open-pencil/scene-graph'import { copyFills, copyStrokes } from '@open-pencil/scene-graph/copy'@@ -71,8 +71,8 @@ export function newLayerDefaults(return {fills: copyFills([SHAPE_WITH_TEXT_FILL]),strokes: copyStrokes([SHAPE_WITH_TEXT_STROKE]),- width: SHAPE_WITH_TEXT_TOOL_SIZE,- height: SHAPE_WITH_TEXT_TOOL_SIZE,+ width: SHAPE_WITH_TEXT_SIZE,+ height: SHAPE_WITH_TEXT_SIZE,shapeWithTextType: 'SQUARE'}default:diff --git a/packages/core/src/figma-api/accessor-utils.ts b/packages/core/src/figma-api/accessor-utils.tsindex 1dc3e82a6..d7bdc8fd1 100644--- a/packages/core/src/figma-api/accessor-utils.ts+++ b/packages/core/src/figma-api/accessor-utils.ts@@ -74,6 +74,7 @@ export function prepareFollowedFieldEdit(| 'vector-data'| 'handle-mirroring'| 'stack-counter-align-content'+ | 'shape-type'): void {if (!node.parentId) returnconst scope = slotScope(scene, node.parentId)diff --git a/packages/core/src/figma-api/compatibility.ts b/packages/core/src/figma-api/compatibility.tsindex 5b859f00b..efb307028 100644--- a/packages/core/src/figma-api/compatibility.ts+++ b/packages/core/src/figma-api/compatibility.ts@@ -30,6 +30,7 @@ export type SupportedPluginAPI = Pick<| 'createPolygon'| 'createRectangle'| 'createSection'+ | 'createShapeWithText'| 'createStar'| 'createText'| 'createVector'diff --git a/packages/core/src/figma-api/index.ts b/packages/core/src/figma-api/index.tsindex ef3ed03ba..6eedcf6ab 100644--- a/packages/core/src/figma-api/index.ts+++ b/packages/core/src/figma-api/index.ts@@ -47,6 +47,7 @@ import type {FigmaPolygonNode,FigmaRectangleNode,FigmaSectionNode,+ FigmaShapeWithTextNode,FigmaStarNode,FigmaTextNode,FigmaVectorNode@@ -60,6 +61,7 @@ import {type FigmaFontName,type NodeProxyHost} from './proxy'+import { newShapeWithText } from './shape-with-text'import type { ExportImageOptions } from './types'const noop = () => undefined@@ -82,6 +84,7 @@ export type {FigmaPolygonNode,FigmaRectangleNode,FigmaSectionNode,+ FigmaShapeWithTextNode,FigmaSlotNode,FigmaStarNode,FigmaTextNode,@@ -219,6 +222,10 @@ export class FigmaAPI implements NodeProxyHost {return this._createNode('STAR') as FigmaStarNode}+ createShapeWithText(): FigmaShapeWithTextNode {+ return this.wrapNode(newShapeWithText(this).id) as FigmaShapeWithTextNode+ }+createVector(): FigmaVectorNode {return this._createNode('VECTOR') as FigmaVectorNode}diff --git a/packages/core/src/figma-api/node-types.ts b/packages/core/src/figma-api/node-types.tsindex 435311734..86517a694 100644--- a/packages/core/src/figma-api/node-types.ts+++ b/packages/core/src/figma-api/node-types.ts@@ -10,6 +10,7 @@ export type FigmaLineNode = FigmaNodeProxy & LineNodeexport type FigmaVectorNode = FigmaNodeProxy & VectorNodeexport type FigmaPolygonNode = FigmaNodeProxy & PolygonNodeexport type FigmaStarNode = FigmaNodeProxy & StarNode+export type FigmaShapeWithTextNode = FigmaNodeProxy & ShapeWithTextNodeexport type FigmaComponentNode = FigmaNodeProxy & ComponentNodeexport type FigmaComponentSetNode = FigmaNodeProxy & ComponentSetNodeexport type FigmaInstanceNode = FigmaNodeProxy & InstanceNodediff --git a/packages/core/src/figma-api/proxy.ts b/packages/core/src/figma-api/proxy.tsindex d009a167e..dc56bf8d4 100644--- a/packages/core/src/figma-api/proxy.ts+++ b/packages/core/src/figma-api/proxy.ts@@ -23,6 +23,7 @@ import {} from '@open-pencil/scene-graph/color'import type { OkHCLColor, OkHCLPayload } from '@open-pencil/scene-graph/color'import type { Rect, Vector } from '@open-pencil/scene-graph/primitives'+import type { ShapeWithTextType } from '@open-pencil/scene-graph/shape-with-text'import { assertNodeEditable } from '#core/editor/capabilities'import type { FigmaEffect } from '#core/figma-api/effects'@@ -54,6 +55,7 @@ import { installInstanceOverrideAccessors, type FigmaInstanceOverride } from './import { getPageBackgrounds, setPageBackgrounds } from './page-backgrounds'import * as PluginData from './plugin-data'import { nodeProxyToJSON } from './serialization'+import { installShapeWithTextAccessors } from './shape-with-text'import { installSlotAccessors, prepareSlotMove, prepareSlotRemoval } from './slots'import type { FigmaLetterSpacing, FigmaLineHeight } from './text'import * as TextProxy from './text'@@ -167,11 +169,12 @@ export class FigmaNodeProxy {declare readonly explicitVariableModes: Readonly<Record<string, string>>declare readonly resolvedVariableModes: Readonly<Record<string, string>>declare readonly overrides: FigmaInstanceOverride[] | undefined- /** A sticky note's body, its author line, and whether it is wide; undefined on other layers. */+ /** A sticky note's body or a shape's label, a sticky's author line, and whether it is wide. */declare readonly text: FigmaNodeProxy | undefineddeclare readonly authorName: string | undefineddeclare authorVisible: boolean | undefineddeclare isWideWidth: boolean | undefined+ declare shapeType: ShapeWithTextType | undefineddeclare resetOverrides: () => voiddeclare strokeWeight: number@@ -593,3 +596,4 @@ installComponentPropertyAccessors(FigmaNodeProxy.prototype, proxyInternals)installInstanceOverrideAccessors(FigmaNodeProxy.prototype, proxyInternals)installSlotAccessors(FigmaNodeProxy.prototype, proxyInternals)installDevStatusAccessors(FigmaNodeProxy.prototype, proxyInternals)+installShapeWithTextAccessors(FigmaNodeProxy.prototype, proxyInternals)diff --git a/packages/core/src/figma-api/shape-with-text.ts b/packages/core/src/figma-api/shape-with-text.tsnew file mode 100644index 000000000..4cba0dddc--- /dev/null+++ b/packages/core/src/figma-api/shape-with-text.ts@@ -0,0 +1,71 @@+import {+ createShapeWithText,+ shapeWithTextFrameFields,+ type SceneGraph,+ type SceneNode+} from '@open-pencil/scene-graph'+import {+ isShapeWithTextType,+ SHAPE_WITH_TEXT_TYPES,+ type ShapeWithTextType+} from '@open-pencil/scene-graph/shape-with-text'++import type { InterfaceTheme } from '#core/constants'+import { newLayerDefaults } from '#core/editor/shapes/defaults'++import type { NodeProxyInternals, ProxyThis } from './accessor-utils'+import { graph, prepareFollowedFieldEdit, raw, updateNode } from './accessor-utils'++/** `value` as a kind for `node`, refused in the words Figma's plugin API refuses it with. */+function checkedShapeType(node: SceneNode, value: unknown): ShapeWithTextType {+ if (node.type !== 'SHAPE_WITH_TEXT') {+ throw new Error('in set_shapeType: Only a shape with text has a shape type')+ }+ if (!isShapeWithTextType(value)) {+ const expected = SHAPE_WITH_TEXT_TYPES.map((kind) => `'${kind}'`).join(' | ')+ throw new Error(+ `in set_shapeType: Property "shapeType" failed validation: Invalid enum value. Expected ${expected}, received '${String(value)}'`+ )+ }+ return value+}++/**+ * A new, empty shape with text on the API's current page, as FigJam's plugin API creates it: an+ * ellipse 176 px square, painted as the shape tool paints a new shape. Measured in FigJam.+ */+export function newShapeWithText(api: {+ graph: SceneGraph+ currentPageId: string+ theme: InterfaceTheme+}): SceneNode {+ return createShapeWithText(api.graph, api.currentPageId, {+ ...newLayerDefaults('SHAPE_WITH_TEXT', api.theme),+ shapeWithTextType: 'ELLIPSE'+ })+}++/** `shapeType`, a shape with text's FigJam kind; other layers have none. */+export function installShapeWithTextAccessors(+ prototype: object,+ internals: NodeProxyInternals+): void {+ Object.defineProperties(prototype, {+ shapeType: {+ get(this: ProxyThis): ShapeWithTextType | undefined {+ const node = raw(this, internals)+ return node.type === 'SHAPE_WITH_TEXT' ? node.shapeWithTextType : undefined+ },+ set(this: ProxyThis, value: unknown) {+ const node = raw(this, internals)+ const kind = checkedShapeType(node, value)+ prepareFollowedFieldEdit(graph(this, internals), node, 'shapeType', 'shape-type')+ // The new kind lays the label out in its own area, as FigJam's shape switcher does.+ updateNode(this, internals, {+ shapeWithTextType: kind,+ ...shapeWithTextFrameFields(kind, node.width, node.height)+ })+ }+ }+ })+}diff --git a/packages/core/tests/design-jsx/shapes-with-text.test.ts b/packages/core/tests/design-jsx/shapes-with-text.test.tsindex 6a6e6e371..92422c75b 100644--- a/packages/core/tests/design-jsx/shapes-with-text.test.ts+++ b/packages/core/tests/design-jsx/shapes-with-text.test.ts@@ -22,8 +22,8 @@ describe('shapes with text in design JSX', () => {shapeWithTextType: 'SQUARE',name: 'Start',autoRename: true,- width: 208,- height: 208,+ width: 176,+ height: 176,cornerRadius: 6})expect(shapeWithTextLabel(graph, square)?.text).toBe('Start')@@ -72,7 +72,7 @@ describe('shapes with text in design JSX', () => {])expect(getNodeOrThrow(graph, result.id)).toMatchObject({shapeWithTextType: 'SQUARE',- width: 208+ width: 176})})diff --git a/packages/core/tests/figma-api/shape-with-text.test.ts b/packages/core/tests/figma-api/shape-with-text.test.tsnew file mode 100644index 000000000..5ba0aa663--- /dev/null+++ b/packages/core/tests/figma-api/shape-with-text.test.ts@@ -0,0 +1,96 @@+import { describe, expect, test } from 'bun:test'++import { pick } from 'es-toolkit'++import { SceneGraph, shapeWithTextFrameFields } from '@open-pencil/scene-graph'++import { FigmaAPI } from '#core/figma-api'++const RED = [+ { type: 'SOLID' as const, color: { r: 1, g: 0, b: 0, a: 1 }, opacity: 1, visible: true }+]++function api() {+ return new FigmaAPI(new SceneGraph())+}++function colour(paints: unknown): number[] | undefined {+ if (!Array.isArray(paints)) return undefined+ const [paint] = paints as { color?: { r: number; g: number; b: number } }[]+ return paint?.color ? [paint.color.r, paint.color.g, paint.color.b] : undefined+}++describe('shapes with text in the plugin API', () => {+ // As FigJam's plugin API creates one, measured in FigJam.+ test('a new shape with text is a 176 px ellipse, painted as the shape tool paints one', () => {+ const shape = api().createShapeWithText()+ expect(shape.type).toBe('SHAPE_WITH_TEXT')+ expect(shape.name).toBe('Shape with text')+ expect(shape.shapeType).toBe('ELLIPSE')+ expect([shape.width, shape.height]).toEqual([176, 176])+ expect(colour(shape.fills)).toEqual([1, 1, 1])+ expect(shape.strokeWeight).toBe(4)+ expect(shape.text?.characters).toBe('')+ expect(shape.text?.fontSize).toBe(16)+ expect(shape.text?.textAlignHorizontal).toBe('CENTER')+ })++ test('the shape type changes the kind and refuses names FigJam does not have', () => {+ const shape = api().createShapeWithText()+ shape.shapeType = 'ENG_DATABASE'+ expect(shape.shapeType).toBe('ENG_DATABASE')+ // The label moves into the new kind's label area, as FigJam's shape switcher puts it.+ const fields = shapeWithTextFrameFields('ENG_DATABASE', 176, 176)+ expect(pick(fields, ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'])).toEqual({+ paddingTop: shape.paddingTop,+ paddingRight: shape.paddingRight,+ paddingBottom: shape.paddingBottom,+ paddingLeft: shape.paddingLeft+ })+ expect(() => {+ shape.shapeType = 'CLOUD' as never+ }).toThrow(+ `in set_shapeType: Property "shapeType" failed validation: Invalid enum value. Expected 'SQUARE' | 'ELLIPSE'`+ )+ })++ test('the label is a text layer of its own, whose fills colour the words, not the shape', () => {+ const shape = api().createShapeWithText()+ const before = colour(shape.fills)+ const label = shape.text+ if (!label) throw new Error('no label')+ label.characters = 'Check stock'+ label.fills = RED+ expect(shape.text?.characters).toBe('Check stock')+ expect(colour(label.fills)).toEqual([1, 0, 0])+ expect(colour(shape.fills)).toEqual(before)+ })++ test('fills set on an empty label colour the words typed afterwards', () => {+ const label = api().createShapeWithText().text+ if (!label) throw new Error('no label')+ label.fills = RED+ label.characters = 'Later'+ expect(colour(label.fills)).toEqual([1, 0, 0])+ })++ test("the label is not one of the shape's children", () => {+ const shape = api().createShapeWithText()+ expect(shape.children).toEqual([])+ })++ test('a resize sets the size, as FigJam keeps it', () => {+ const shape = api().createShapeWithText()+ shape.resize(160, 90)+ expect([shape.width, shape.height]).toEqual([160, 90])+ })++ test('other layers have no shape type and no label', () => {+ const rectangle = api().createRectangle()+ expect(rectangle.shapeType).toBeUndefined()+ expect(rectangle.text).toBeUndefined()+ expect(() => {+ rectangle.shapeType = 'SQUARE'+ }).toThrow('Only a shape with text has a shape type')+ })+})diff --git a/packages/core/tests/layout/generated/shape-with-text.test.ts b/packages/core/tests/layout/generated/shape-with-text.test.tsindex d7e36a1ae..433a8f384 100644--- a/packages/core/tests/layout/generated/shape-with-text.test.ts+++ b/packages/core/tests/layout/generated/shape-with-text.test.ts@@ -35,9 +35,9 @@ describe('shape with text size', () => {const id = drawnShape(graph)graph.updateNode(id, { width: 400, height: 300 })computeAllLayouts(graph, id)- graph.updateNode(id, { width: 208, height: 208 })+ graph.updateNode(id, { width: 176, height: 176 })computeAllLayouts(graph, id)- expect(getNodeOrThrow(graph, id)).toMatchObject({ width: 208, height: 208 })+ expect(getNodeOrThrow(graph, id)).toMatchObject({ width: 176, height: 176 })})test('growing for its label leaves the given size, so a shorter label shrinks it back', () => {@@ -48,10 +48,10 @@ describe('shape with text size', () => {graph.updateNode(label.id, { text: Array.from({ length: 8 }, () => 'line').join('\n') })computeAllLayouts(graph, id)const grown = getNodeOrThrow(graph, id)- expect(grown.height).toBeGreaterThan(208)- expect(grown.shapeUserHeight).toBe(208)+ expect(grown.height).toBeGreaterThan(176)+ expect(grown.shapeUserHeight).toBe(176)graph.updateNode(label.id, { text: 'Hi' })computeAllLayouts(graph, id)- expect(getNodeOrThrow(graph, id).height).toBe(208)+ expect(getNodeOrThrow(graph, id).height).toBe(176)})})diff --git a/packages/design-jsx/src/reference/authoring.md b/packages/design-jsx/src/reference/authoring.mdindex 6328d0664..36343d4f9 100644--- a/packages/design-jsx/src/reference/authoring.md+++ b/packages/design-jsx/src/reference/authoring.md@@ -26,7 +26,7 @@ This reference describes scene creation, not React DOM output. Use the `render`- `Span` styles some characters of a `Text` with `Text`'s own prop names: `size`, `font`, `weight`, `italic`, `color`, `fills`, `lineHeight`, `letterSpacing`, `textDecoration`, the decoration details, and `textCase`. `href` links its characters to a URL without changing how they look. Spans nest; the inner one wins. `Paragraph` writes one paragraph: `list="ordered"` or `list="unordered"` makes it a list item nested at `level` 1–5, and `spacing`, `listSpacing`, and `indent` override the `Text`'s `paragraphSpacing`, `listSpacing`, and `paragraphIndent` for it; `hangingList` on the `Text` hangs list markers outside the text box. A `Text` holds only `Paragraph`s or none; without them, a line break in its text still starts a paragraph.- `Icon` uses an Iconify name, size, and color. Prefer icons to emoji when reliable vector output is needed. Image fills belong on appropriate leaf shapes, not containers whose children must remain visible.- `Sticky` makes a FigJam sticky note whose text is its body: `<Sticky color="yellow" author="Ada">Ship it</Sticky>`. `color` takes a FigJam palette name (`white`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, `pink`) or any colour, `author` signs it (`authorVisible={false}` hides the line), `wide` makes it 416 wide instead of 240, `textSize` is `small`, `medium`, `large`, `extraLarge`, or `huge`, `typeface` is `simple`, `bookish`, `technical`, or `scribbled`, and `scale` scales the whole note. A note sizes itself; it takes no `w`, `h`, fills, or layout props.-- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (208 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.+- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (176 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.- `Connector` draws a FigJam connector that follows the layers it joins: `<Connector from="Start" to="Done">Next</Connector>`. `from` and `to` name layers of the same JSX, take a `ref()` a layer is marked with (`const card = ref()`, then `<Frame ref={card}>` and `from={card}`), or give `{ x, y }` points in the connector's parent; `fromSide`/`toSide` (`top`, `right`, `bottom`, `left`) fix the side it attaches by, `line` is `elbowed` (default), `straight`, or `curved`, and `startCap`/`endCap` take the same caps as `strokeCap`: `none`, `round`, `square`, `arrow_lines`, `arrow_equilateral`, `triangle_filled`, `diamond_filled`, or `circle_filled` (it starts with none and ends with `arrow_lines`). Its text is the label; `stroke`, `strokeWidth`, and `dashPattern` style the line. When layers share a name, join them by `ref()`; a name more than one layer has joins the first, with a warning.- Design JSX props are the portable authoring interface. Some CSS-style aliases are supported, but this is not a browser CSS engine; do not assume arbitrary HTML, classes, or styles work.diff --git a/packages/docs/reference/design-authoring.md b/packages/docs/reference/design-authoring.mdindex 5d64ae9a1..3cd2f50b4 100644--- a/packages/docs/reference/design-authoring.md+++ b/packages/docs/reference/design-authoring.md@@ -28,7 +28,7 @@ This reference describes scene creation, not React DOM output. Use the `render`- `Span` styles some characters of a `Text` with `Text`'s own prop names: `size`, `font`, `weight`, `italic`, `color`, `fills`, `lineHeight`, `letterSpacing`, `textDecoration`, the decoration details, and `textCase`. `href` links its characters to a URL without changing how they look. Spans nest; the inner one wins. `Paragraph` writes one paragraph: `list="ordered"` or `list="unordered"` makes it a list item nested at `level` 1–5, and `spacing`, `listSpacing`, and `indent` override the `Text`'s `paragraphSpacing`, `listSpacing`, and `paragraphIndent` for it; `hangingList` on the `Text` hangs list markers outside the text box. A `Text` holds only `Paragraph`s or none; without them, a line break in its text still starts a paragraph.- `Icon` uses an Iconify name, size, and color. Prefer icons to emoji when reliable vector output is needed. Image fills belong on appropriate leaf shapes, not containers whose children must remain visible.- `Sticky` makes a FigJam sticky note whose text is its body: `<Sticky color="yellow" author="Ada">Ship it</Sticky>`. `color` takes a FigJam palette name (`white`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, `pink`) or any colour, `author` signs it (`authorVisible={false}` hides the line), `wide` makes it 416 wide instead of 240, `textSize` is `small`, `medium`, `large`, `extraLarge`, or `huge`, `typeface` is `simple`, `bookish`, `technical`, or `scribbled`, and `scale` scales the whole note. A note sizes itself; it takes no `w`, `h`, fills, or layout props.-- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (208 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.+- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (176 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.- `Connector` draws a FigJam connector that follows the layers it joins: `<Connector from="Start" to="Done">Next</Connector>`. `from` and `to` name layers of the same JSX, take a `ref()` a layer is marked with (`const card = ref()`, then `<Frame ref={card}>` and `from={card}`), or give `{ x, y }` points in the connector's parent; `fromSide`/`toSide` (`top`, `right`, `bottom`, `left`) fix the side it attaches by, `line` is `elbowed` (default), `straight`, or `curved`, and `startCap`/`endCap` take the same caps as `strokeCap`: `none`, `round`, `square`, `arrow_lines`, `arrow_equilateral`, `triangle_filled`, `diamond_filled`, or `circle_filled` (it starts with none and ends with `arrow_lines`). Its text is the label; `stroke`, `strokeWidth`, and `dashPattern` style the line. When layers share a name, join them by `ref()`; a name more than one layer has joins the first, with a warning.- Design JSX props are the portable authoring interface. Some CSS-style aliases are supported, but this is not a browser CSS engine; do not assume arbitrary HTML, classes, or styles work.diff --git a/packages/scene-graph/src/generated/shape-with-text.ts b/packages/scene-graph/src/generated/shape-with-text.tsindex a75d2144f..2ab4556bb 100644--- a/packages/scene-graph/src/generated/shape-with-text.ts+++ b/packages/scene-graph/src/generated/shape-with-text.ts@@ -6,10 +6,8 @@ import type { ShapeWithTextType } from '../shape-with-text/kinds'import type { Fill, SceneNode } from '../types'import type { GeneratedFrameKind } from './kind'-/** FigJam's plugin API makes a shape with text 208 px square. */-export const SHAPE_WITH_TEXT_SIZE = 208-/** FigJam's shape tool places a shape 176 px square where it is clicked. */-export const SHAPE_WITH_TEXT_TOOL_SIZE = 176+/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */+export const SHAPE_WITH_TEXT_SIZE = 176/** FigJam rounds every corner of a shape by 6 px. */export const SHAPE_WITH_TEXT_CORNER_RADIUS = 6diff --git a/packages/vue/src/shared/input/draw.ts b/packages/vue/src/shared/input/draw.tsindex 25914a8e2..2d9d1560c 100644--- a/packages/vue/src/shared/input/draw.ts+++ b/packages/vue/src/shared/input/draw.ts@@ -1,6 +1,6 @@import { DEFAULT_TEXT_HEIGHT, DEFAULT_TEXT_WIDTH } from '@open-pencil/core/constants'import type { Editor } from '@open-pencil/core/editor'-import { generatedFrameText, SHAPE_WITH_TEXT_TOOL_SIZE } from '@open-pencil/scene-graph'+import { generatedFrameText, SHAPE_WITH_TEXT_SIZE } from '@open-pencil/scene-graph'import type { NodeType, SceneNode } from '@open-pencil/scene-graph'import { getWorldMatrix } from '@open-pencil/scene-graph/coordinate'import Matrix from '@open-pencil/scene-graph/matrix'@@ -108,7 +108,7 @@ function settleDrawnSize(preview: ReturnType<Editor['beginNodePreview']>, node:preview.update(node.id, { width: 100, height: 0, rotation: 0 })return true} else if (clicked && node.type === 'SHAPE_WITH_TEXT') {- preview.update(node.id, { width: SHAPE_WITH_TEXT_TOOL_SIZE, height: SHAPE_WITH_TEXT_TOOL_SIZE })+ preview.update(node.id, { width: SHAPE_WITH_TEXT_SIZE, height: SHAPE_WITH_TEXT_SIZE })} else if (clicked) {preview.update(node.id, { width: 100, height: 100 })}diff --git a/skills/open-pencil/references/design-authoring.md b/skills/open-pencil/references/design-authoring.mdindex 5d64ae9a1..3cd2f50b4 100644--- a/skills/open-pencil/references/design-authoring.md+++ b/skills/open-pencil/references/design-authoring.md@@ -28,7 +28,7 @@ This reference describes scene creation, not React DOM output. Use the `render`- `Span` styles some characters of a `Text` with `Text`'s own prop names: `size`, `font`, `weight`, `italic`, `color`, `fills`, `lineHeight`, `letterSpacing`, `textDecoration`, the decoration details, and `textCase`. `href` links its characters to a URL without changing how they look. Spans nest; the inner one wins. `Paragraph` writes one paragraph: `list="ordered"` or `list="unordered"` makes it a list item nested at `level` 1–5, and `spacing`, `listSpacing`, and `indent` override the `Text`'s `paragraphSpacing`, `listSpacing`, and `paragraphIndent` for it; `hangingList` on the `Text` hangs list markers outside the text box. A `Text` holds only `Paragraph`s or none; without them, a line break in its text still starts a paragraph.- `Icon` uses an Iconify name, size, and color. Prefer icons to emoji when reliable vector output is needed. Image fills belong on appropriate leaf shapes, not containers whose children must remain visible.- `Sticky` makes a FigJam sticky note whose text is its body: `<Sticky color="yellow" author="Ada">Ship it</Sticky>`. `color` takes a FigJam palette name (`white`, `gray`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, `pink`) or any colour, `author` signs it (`authorVisible={false}` hides the line), `wide` makes it 416 wide instead of 240, `textSize` is `small`, `medium`, `large`, `extraLarge`, or `huge`, `typeface` is `simple`, `bookish`, `technical`, or `scribbled`, and `scale` scales the whole note. A note sizes itself; it takes no `w`, `h`, fills, or layout props.-- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (208 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.+- `Shape` makes a FigJam shape with text whose text is its label: `<Shape kind="diamond" bg="#FFC943">Valid?</Shape>`. `kind` is `square` (default), `ellipse`, `diamond`, `rounded_rectangle`, `parallelogram_right`, `eng_database`, or another FigJam shape, written in lowercase. `w` and `h` are the size it is given (176 by default); it grows past them to fit its label, and never splits a word. `bg`, `stroke`, `strokeWidth`, `rounded` (6 by default), and `rotate` style it as any layer; the label is centred in the shape and takes the same `textSize` and `typeface` as `Sticky`.- `Connector` draws a FigJam connector that follows the layers it joins: `<Connector from="Start" to="Done">Next</Connector>`. `from` and `to` name layers of the same JSX, take a `ref()` a layer is marked with (`const card = ref()`, then `<Frame ref={card}>` and `from={card}`), or give `{ x, y }` points in the connector's parent; `fromSide`/`toSide` (`top`, `right`, `bottom`, `left`) fix the side it attaches by, `line` is `elbowed` (default), `straight`, or `curved`, and `startCap`/`endCap` take the same caps as `strokeCap`: `none`, `round`, `square`, `arrow_lines`, `arrow_equilateral`, `triangle_filled`, `diamond_filled`, or `circle_filled` (it starts with none and ends with `arrow_lines`). Its text is the label; `stroke`, `strokeWidth`, and `dashPattern` style the line. When layers share a name, join them by `ref()`; a name more than one layer has joins the first, with a warning.- Design JSX props are the portable authoring interface. Some CSS-style aliases are supported, but this is not a browser CSS engine; do not assume arbitrary HTML, classes, or styles work.