Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 6de46eb

Browse files
committed
refactor(canvas): access to wrapper
1 parent 5b98277 commit 6de46eb

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

apps/client/src/widgets/type_widgets/canvas_el.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "@excalidraw/excalidraw/index.css";
22
import { Excalidraw, getSceneVersion, exportToSvg } from "@excalidraw/excalidraw";
3-
import { createElement, createRef, Fragment, RefObject, render } from "preact/compat";
3+
import { createElement, createRef, Fragment, RefObject, render, useEffect, useState } from "preact/compat";
44
import { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, SceneData } from "@excalidraw/excalidraw/types";
55

66
/** -1 indicates that it is fresh. excalidraw scene version is always >0 */
@@ -12,7 +12,7 @@ export default class Canvas {
1212

1313
private currentSceneVersion: number;
1414
private opts: ExcalidrawProps;
15-
private excalidrawWrapperRef: RefObject<HTMLElement>;
15+
private excalidrawWrapperRef?: RefObject<HTMLElement>;
1616
excalidrawApi!: ExcalidrawImperativeAPI;
1717

1818
constructor(opts: ExcalidrawProps) {
@@ -30,14 +30,14 @@ export default class Canvas {
3030
}
3131

3232
private createCanvasElement(opts: ExcalidrawProps) {
33-
const excalidrawWrapperRef = createRef<HTMLElement>();
34-
33+
this.excalidrawWrapperRef = createRef<HTMLElement>();
34+
this.buildResizeListener();
3535
return createElement(Fragment, null,
3636
createElement(
3737
"div",
3838
{
3939
className: "excalidraw-wrapper",
40-
ref: excalidrawWrapperRef
40+
ref: this.excalidrawWrapperRef
4141
},
4242
createElement(Excalidraw, opts)
4343
));
@@ -160,5 +160,3 @@ export default class Canvas {
160160
}
161161

162162
}
163-
164-

0 commit comments

Comments
 (0)