-
Notifications
You must be signed in to change notification settings - Fork 12
/
DrawBlock.tsx
32 lines (28 loc) · 957 Bytes
/
DrawBlock.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { ValueProps, canvasProps } from '@renderer/common/types';
import { Tldraw, TldrawApp } from '@tldraw/tldraw';
import React, { useEffect, useState } from 'react';
function DrawBlockContent({ content, blockStateFunction }: ValueProps) {
const [canvasState, setCanvasState] = useState({ shapes: [] });
useEffect(() => {
blockStateFunction(canvasState);
}, [canvasState]);
return (
<div className='draw-applet'>
<Tldraw
autofocus={true}
showMenu={false}
showMultiplayerMenu={false}
showPages={false}
showStyles={false}
showZoom={false}
onMount={(app: TldrawApp) => {
// app.setSetting('showGrid', true);
app.insertContent(content ? (content as canvasProps) : { shapes: [] });
app.zoomToContent();
}}
onPersist={(app: TldrawApp) => setCanvasState(app.getContent())}
/>
</div>
);
}
export default DrawBlockContent;