update tldraw functions

This commit is contained in:
Jeff Emmett 2025-09-04 15:30:57 +02:00
parent 8385e30d25
commit 808b37425a
8 changed files with 48 additions and 48 deletions

View File

@ -223,7 +223,7 @@ export class Drawing extends StateNode {
size: "xl",
text: gesture.name,
color: score_color,
},
} as any,
}
if (SHOW_LABELS) {
this.editor.createShape(labelShape)

View File

@ -44,7 +44,7 @@ export function Inbox() {
text: messageText,
align: "start",
verticalAlign: "start",
},
} as any,
meta: {
id: messageId,
},

View File

@ -182,7 +182,7 @@ export class PromptShape extends BaseBoxShapeUtil<IPrompt> {
if (isShapeOfType<TLGeoShape>(sourceShape, "geo")) {
processedPrompt = processedPrompt.replace(
pattern,
sourceShape.props.text,
(sourceShape.props as any).text,
)
}
}

View File

@ -37,7 +37,7 @@ export function CustomContextMenu(props: TLUiContextMenuProps) {
const editor = useEditor()
const helpers = useDefaultHelpers()
const tools = overrides.tools?.(editor, {}, helpers) ?? {}
const customActions = getCustomActions(editor)
const customActions = getCustomActions(editor) as any
const [selectedShapes, setSelectedShapes] = useState<TLShape[]>([])
const [selectedIds, setSelectedIds] = useState<string[]>([])

View File

@ -34,7 +34,7 @@ export function CustomMainMenu() {
};
const exportJSON = (editor: Editor) => {
const exportName = `props-${Math.round(+new Date() / 1000).toString().slice(5)}`
exportAs(Array.from(editor.getCurrentPageShapeIds()), 'json', exportName)
exportAs(Array.from(editor.getCurrentPageShapeIds()), 'json' as any, exportName)
};
return (

View File

@ -355,7 +355,7 @@ export const overrides: TLUiOverrides = {
const sourceShape = editor.getShape(edge.from)
const sourceText =
sourceShape && sourceShape.type === "geo"
? (sourceShape as TLGeoShape).props.text
? ((sourceShape as TLGeoShape).props as any).text
: ""
@ -372,7 +372,7 @@ export const overrides: TLUiOverrides = {
props: {
...(editor.getShape(edge.to) as TLGeoShape).props,
text: partialResponse,
},
} as any,
})
})

View File

@ -16,7 +16,7 @@ export const multiplayerAssetStore: TLAssetStore = {
throw new Error(`Failed to upload asset: ${response.statusText}`)
}
return url
return { src: url }
},
resolve(asset) {

View File

@ -200,48 +200,48 @@ const router = AutoRouter<IRequest, [env: Environment, ctx: ExecutionContext]>({
})
})
// Automerge routes - these will be used when we switch to Automerge sync
.get("/automerge/connect/:roomId", (request, env) => {
// Check if this is a WebSocket upgrade request
const upgradeHeader = request.headers.get("Upgrade")
if (upgradeHeader === "websocket") {
const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
return room.fetch(request.url, {
headers: request.headers,
body: request.body,
method: request.method,
})
}
// Handle regular GET requests
const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
return room.fetch(request.url, {
headers: request.headers,
body: request.body,
method: request.method,
})
})
// Automerge routes - disabled for now
// .get("/automerge/connect/:roomId", (request, env) => {
// // Check if this is a WebSocket upgrade request
// const upgradeHeader = request.headers.get("Upgrade")
// if (upgradeHeader === "websocket") {
// const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
// const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
// return room.fetch(request.url, {
// headers: request.headers,
// body: request.body,
// method: request.method,
// })
// }
//
// // Handle regular GET requests
// const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
// const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
// return room.fetch(request.url, {
// headers: request.headers,
// body: request.body,
// method: request.method,
// })
// })
.get("/automerge/room/:roomId", (request, env) => {
const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
return room.fetch(request.url, {
headers: request.headers,
body: request.body,
method: request.method,
})
})
// .get("/automerge/room/:roomId", (request, env) => {
// const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
// const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
// return room.fetch(request.url, {
// headers: request.headers,
// body: request.body,
// method: request.method,
// })
// })
.post("/automerge/room/:roomId", async (request, env) => {
const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
return room.fetch(request.url, {
method: "POST",
body: request.body,
})
})
// .post("/automerge/room/:roomId", async (request, env) => {
// const id = env.AUTOMERGE_DURABLE_OBJECT.idFromName(request.params.roomId)
// const room = env.AUTOMERGE_DURABLE_OBJECT.get(id)
// return room.fetch(request.url, {
// method: "POST",
// body: request.body,
// })
// })
.post("/daily/rooms", async (req) => {
const apiKey = req.headers.get('Authorization')?.split('Bearer ')[1]