From 3423aeeeb66d0695bb9bda1424a0bf7a591f1d61 Mon Sep 17 00:00:00 2001 From: Orion Reed Date: Mon, 25 Mar 2024 00:29:01 -0700 Subject: [PATCH] html is resizeable --- src/ts/physics/PhysicsControls.tsx | 2 +- src/ts/shapes/HTMLShapeUtil.tsx | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ts/physics/PhysicsControls.tsx b/src/ts/physics/PhysicsControls.tsx index 444f4a0..2b7c118 100644 --- a/src/ts/physics/PhysicsControls.tsx +++ b/src/ts/physics/PhysicsControls.tsx @@ -11,7 +11,7 @@ export const SimController = ({ shapes }: { shapes: TLUnknownShape[] }) => { }, []); - const { addShapes } = usePhysicsSimulation(editor, true); + const { addShapes } = usePhysicsSimulation(editor, false); return (<>); }; diff --git a/src/ts/shapes/HTMLShapeUtil.tsx b/src/ts/shapes/HTMLShapeUtil.tsx index 156b261..d89a892 100644 --- a/src/ts/shapes/HTMLShapeUtil.tsx +++ b/src/ts/shapes/HTMLShapeUtil.tsx @@ -1,10 +1,14 @@ -import { Rectangle2d, TLBaseShape } from '@tldraw/tldraw'; +import { Rectangle2d, resizeBox, TLBaseShape, TLOnResizeHandler } from '@tldraw/tldraw'; import { HTMLContainer, ShapeUtil } from 'tldraw' export type HTMLShape = TLBaseShape<'html', { w: number; h: number, html: string }> export class HTMLShapeUtil extends ShapeUtil { static override type = 'html' as const + override canBind = () => true + override canEdit = () => false + override canResize = () => true + override isAspectRatioLocked = () => false getDefaultProps(): HTMLShape['props'] { return { @@ -14,6 +18,10 @@ export class HTMLShapeUtil extends ShapeUtil { } } + override onResize: TLOnResizeHandler = (shape, info) => { + return resizeBox(shape, info) + } + getGeometry(shape: IHTMLShape) { return new Rectangle2d({ width: shape.props.w, @@ -24,6 +32,7 @@ export class HTMLShapeUtil extends ShapeUtil { component(shape: HTMLShape) { return
+ } indicator(shape: HTMLShape) {