From 4fda800e8b0f19e13fc85a640653b1c2512baf19 Mon Sep 17 00:00:00 2001 From: Jeff Emmett <46964190+Jeff-Emmett@users.noreply.github.com> Date: Sat, 7 Dec 2024 23:00:30 -0500 Subject: [PATCH] cleanup --- src/shapes/HTMLShapeUtil.tsx | 90 ------------------------------------ 1 file changed, 90 deletions(-) delete mode 100644 src/shapes/HTMLShapeUtil.tsx diff --git a/src/shapes/HTMLShapeUtil.tsx b/src/shapes/HTMLShapeUtil.tsx deleted file mode 100644 index 8f83274..0000000 --- a/src/shapes/HTMLShapeUtil.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { - TLBaseShape, - TLResizeHandle, - BaseBoxShapeUtil, - //TLShapeUtilFlag, - resizeBox, - VecModel, - Box, - TLResizeMode, - Rectangle2d, -} from "tldraw" - -export interface HTMLShape - extends TLBaseShape<"html", { w: number; h: number; html: string }> { - props: { - w: number - h: number - html: string - } -} - -export class HTMLShapeUtil extends BaseBoxShapeUtil { - static override type = "html" as const - override canBind = () => true - override canEdit = () => false - override canResize = () => true - override isAspectRatioLocked = () => false - - getDefaultProps(): HTMLShape["props"] { - return { - w: 100, - h: 100, - html: "
", - } - } - - override onBeforeUpdate = (prev: HTMLShape, next: HTMLShape): void => { - if (prev.x !== next.x || prev.y !== next.y) { - this.editor.bringToFront([next.id]) - } - } - - 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() - if (element) { - const isOverflowing = - element.scrollWidth > width || element.scrollHeight > height - if (isOverflowing) { - element.parentElement?.classList.add("overflowing") - } else { - element.parentElement?.classList.remove("overflowing") - } - } - return resizeBox(shape, info) - } - - getGeometry(shape: HTMLShape) { - return new Rectangle2d({ - width: shape.props.w, - height: shape.props.h, - isFilled: true, - }) - } - - override component(shape: HTMLShape): JSX.Element { - return ( -
- ) - } - - override indicator(shape: HTMLShape): JSX.Element { - return - } -}