From 5f77d4f927c7b3ed4e82b06e2c2d9cda54f791de Mon Sep 17 00:00:00 2001 From: Jeff Emmett <46964190+Jeff-Emmett@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:13:29 +0700 Subject: [PATCH] fix vercel --- ...om copy.ts => copy useLocalStorageRoom.ts} | 0 src/utils/HTMLShapeUtil.tsx | 43 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) rename src/hooks/{useLocalStorageRoom copy.ts => copy useLocalStorageRoom.ts} (100%) diff --git a/src/hooks/useLocalStorageRoom copy.ts b/src/hooks/copy useLocalStorageRoom.ts similarity index 100% rename from src/hooks/useLocalStorageRoom copy.ts rename to src/hooks/copy useLocalStorageRoom.ts diff --git a/src/utils/HTMLShapeUtil.tsx b/src/utils/HTMLShapeUtil.tsx index c5c560e..1dad10d 100644 --- a/src/utils/HTMLShapeUtil.tsx +++ b/src/utils/HTMLShapeUtil.tsx @@ -1,9 +1,24 @@ -import { Rectangle2d, resizeBox, TLBaseShape, TLOnBeforeUpdateHandler, TLOnResizeHandler } from 'tldraw'; -import { ShapeUtil } from 'tldraw' +import { + TLBaseShape, + TLResizeHandle, + BaseBoxShapeUtil, + //TLShapeUtilFlag, + resizeBox, + VecModel, + Box, + TLResizeMode, + Rectangle2d, +} from 'tldraw' -export type HTMLShape = TLBaseShape<'html', { w: number; h: number, html: string }> +export interface HTMLShape extends TLBaseShape<'html', { w: number; h: number, html: string }> { + props: { + w: number + h: number + html: string + } +} -export class HTMLShapeUtil extends ShapeUtil { +export class HTMLShapeUtil extends BaseBoxShapeUtil { static override type = 'html' as const override canBind = () => true override canEdit = () => false @@ -18,13 +33,24 @@ export class HTMLShapeUtil extends ShapeUtil { } } - override onTranslate: TLOnBeforeUpdateHandler = (prev, next) => { + override onBeforeUpdate = (prev: HTMLShape, next: HTMLShape): void => { if (prev.x !== next.x || prev.y !== next.y) { this.editor.bringToFront([next.id]); } } - override onResize: TLOnResizeHandler = (shape: HTMLShape, info) => { + override onResize = ( + shape: HTMLShape, + info: { + handle: TLResizeHandle; + mode: TLResizeMode; + initialBounds: Box; + initialShape: HTMLShape; + newPoint: VecModel; + scaleX: number; + scaleY: number; + } + ) => { const element = document.getElementById(shape.id); if (!element || !element.parentElement) return resizeBox(shape, info); const { width, height } = element.parentElement.getBoundingClientRect(); @@ -47,12 +73,11 @@ export class HTMLShapeUtil extends ShapeUtil { }) } - component(shape: HTMLShape) { + override component(shape: HTMLShape): JSX.Element { return
- } - indicator(shape: HTMLShape) { + override indicator(shape: HTMLShape): JSX.Element { return } } \ No newline at end of file