mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
refactor(canvas): remove unnecessary ref
This commit is contained in:
parent
51d06ec40d
commit
5b4ceb27c5
@ -12,7 +12,6 @@ export default class Canvas {
|
|||||||
|
|
||||||
private currentSceneVersion: number;
|
private currentSceneVersion: number;
|
||||||
private opts: ExcalidrawProps;
|
private opts: ExcalidrawProps;
|
||||||
private excalidrawWrapperRef?: RefObject<HTMLElement>;
|
|
||||||
excalidrawApi!: ExcalidrawImperativeAPI;
|
excalidrawApi!: ExcalidrawImperativeAPI;
|
||||||
|
|
||||||
constructor(opts: ExcalidrawProps) {
|
constructor(opts: ExcalidrawProps) {
|
||||||
@ -30,13 +29,11 @@ export default class Canvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createCanvasElement(opts: ExcalidrawProps) {
|
private createCanvasElement(opts: ExcalidrawProps) {
|
||||||
this.excalidrawWrapperRef = createRef<HTMLElement>();
|
|
||||||
return createElement(Fragment, null,
|
return createElement(Fragment, null,
|
||||||
createElement(
|
createElement(
|
||||||
"div",
|
"div",
|
||||||
{
|
{
|
||||||
className: "excalidraw-wrapper",
|
className: "excalidraw-wrapper",
|
||||||
ref: this.excalidrawWrapperRef
|
|
||||||
},
|
},
|
||||||
createElement(Excalidraw, opts)
|
createElement(Excalidraw, opts)
|
||||||
));
|
));
|
||||||
@ -81,14 +78,6 @@ export default class Canvas {
|
|||||||
|
|
||||||
appState.theme = theme;
|
appState.theme = theme;
|
||||||
|
|
||||||
if (this.excalidrawWrapperRef?.current) {
|
|
||||||
const boundingClientRect = this.excalidrawWrapperRef.current.getBoundingClientRect();
|
|
||||||
appState.width = boundingClientRect.width;
|
|
||||||
appState.height = boundingClientRect.height;
|
|
||||||
appState.offsetLeft = boundingClientRect.left;
|
|
||||||
appState.offsetTop = boundingClientRect.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sceneData: SceneData = {
|
const sceneData: SceneData = {
|
||||||
elements,
|
elements,
|
||||||
appState
|
appState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user