From 356a262114a92477481707a331d7120051c52575 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 4 Sep 2025 16:58:15 +0200 Subject: [PATCH] update tldraw functions for update --- src/propagators/ScopedPropagators.ts | 12 ++++++++---- src/routes/Inbox.tsx | 8 ++++---- src/shapes/PromptShapeUtil.tsx | 2 +- src/ui/overrides.tsx | 12 ++++++++---- src/utils/searchUtils.ts | 4 +++- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/propagators/ScopedPropagators.ts b/src/propagators/ScopedPropagators.ts index abf862e..03cccde 100644 --- a/src/propagators/ScopedPropagators.ts +++ b/src/propagators/ScopedPropagators.ts @@ -77,16 +77,20 @@ const unpackShape = (shape: any) => { const cast = (prop: any, constructor: (value: any) => any) => { return prop !== undefined ? constructor(prop) : undefined; }; + + // Only add text property for shapes that support it (like text shapes) + const shapeProps = { ...props } + if (type === 'text' && props.text !== undefined) { + shapeProps.text = cast(props.text, String) + } + return { id, type, x: Number(x), y: Number(y), rotation: Number(rotation), - props: { - ...props, - text: cast(props.text, String), - }, + props: shapeProps, meta: m, } } diff --git a/src/routes/Inbox.tsx b/src/routes/Inbox.tsx index f7dd197..38336f9 100644 --- a/src/routes/Inbox.tsx +++ b/src/routes/Inbox.tsx @@ -41,12 +41,12 @@ export function Inbox() { props: { w: shapeWidth, h: shapeHeight, - text: messageText, - align: "start", - verticalAlign: "start", - } as any, + fill: "solid", + color: "white", + }, meta: { id: messageId, + text: messageText, // Store text in meta instead of props }, } let found = false diff --git a/src/shapes/PromptShapeUtil.tsx b/src/shapes/PromptShapeUtil.tsx index ee28083..8018ac8 100644 --- a/src/shapes/PromptShapeUtil.tsx +++ b/src/shapes/PromptShapeUtil.tsx @@ -182,7 +182,7 @@ export class PromptShape extends BaseBoxShapeUtil { if (isShapeOfType(sourceShape, "geo")) { processedPrompt = processedPrompt.replace( pattern, - (sourceShape.props as any).text, + (sourceShape.meta as any)?.text || "", ) } } diff --git a/src/ui/overrides.tsx b/src/ui/overrides.tsx index 0c730c5..ba8d4ed 100644 --- a/src/ui/overrides.tsx +++ b/src/ui/overrides.tsx @@ -355,7 +355,7 @@ export const overrides: TLUiOverrides = { const sourceShape = editor.getShape(edge.from) const sourceText = sourceShape && sourceShape.type === "geo" - ? ((sourceShape as TLGeoShape).props as any).text + ? (sourceShape.meta as any)?.text || "" : "" @@ -366,13 +366,17 @@ export const overrides: TLUiOverrides = { try { llm(prompt, (partialResponse: string) => { + const targetShape = editor.getShape(edge.to) as TLGeoShape editor.updateShape({ id: edge.to, type: "geo", props: { - ...(editor.getShape(edge.to) as TLGeoShape).props, - text: partialResponse, - } as any, + ...targetShape.props, + }, + meta: { + ...targetShape.meta, + text: partialResponse, // Store text in meta instead of props + }, }) }) diff --git a/src/utils/searchUtils.ts b/src/utils/searchUtils.ts index b20acbd..b872319 100644 --- a/src/utils/searchUtils.ts +++ b/src/utils/searchUtils.ts @@ -17,7 +17,9 @@ export const searchText = (editor: Editor) => { (shape.props as any).value, (shape.props as any).url, (shape.props as any).description, - (shape.props as any).content, + (shape.props as any).content, + // For geo shapes, also check meta.text + shape.type === 'geo' ? (shape.meta as any)?.text : undefined, ] const termLower = searchTerm.toLowerCase()