mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-11-04 15:11:31 +08:00 
			
		
		
		
	refactor(canvas): access to wrapper
This commit is contained in:
		
							parent
							
								
									5b98277f3c
								
							
						
					
					
						commit
						4bd5644258
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
import "@excalidraw/excalidraw/index.css";
 | 
					import "@excalidraw/excalidraw/index.css";
 | 
				
			||||||
import { Excalidraw, getSceneVersion, exportToSvg } from "@excalidraw/excalidraw";
 | 
					import { Excalidraw, getSceneVersion, exportToSvg } from "@excalidraw/excalidraw";
 | 
				
			||||||
import { createElement, createRef, Fragment, RefObject, render } from "preact/compat";
 | 
					import { createElement, createRef, Fragment, RefObject, render, useEffect, useState } from "preact/compat";
 | 
				
			||||||
import { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, SceneData } from "@excalidraw/excalidraw/types";
 | 
					import { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, SceneData } from "@excalidraw/excalidraw/types";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** -1 indicates that it is fresh. excalidraw scene version is always >0 */
 | 
					/** -1 indicates that it is fresh. excalidraw scene version is always >0 */
 | 
				
			||||||
@ -12,7 +12,7 @@ export default class Canvas {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private currentSceneVersion: number;
 | 
					    private currentSceneVersion: number;
 | 
				
			||||||
    private opts: ExcalidrawProps;
 | 
					    private opts: ExcalidrawProps;
 | 
				
			||||||
    private excalidrawWrapperRef: RefObject<HTMLElement>;
 | 
					    private excalidrawWrapperRef?: RefObject<HTMLElement>;
 | 
				
			||||||
    excalidrawApi!: ExcalidrawImperativeAPI;
 | 
					    excalidrawApi!: ExcalidrawImperativeAPI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(opts: ExcalidrawProps) {
 | 
					    constructor(opts: ExcalidrawProps) {
 | 
				
			||||||
@ -30,14 +30,13 @@ export default class Canvas {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private createCanvasElement(opts: ExcalidrawProps) {
 | 
					    private createCanvasElement(opts: ExcalidrawProps) {
 | 
				
			||||||
        const excalidrawWrapperRef = createRef<HTMLElement>();
 | 
					        this.excalidrawWrapperRef = createRef<HTMLElement>();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return createElement(Fragment, null,
 | 
					        return createElement(Fragment, null,
 | 
				
			||||||
            createElement(
 | 
					            createElement(
 | 
				
			||||||
                "div",
 | 
					                "div",
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    className: "excalidraw-wrapper",
 | 
					                    className: "excalidraw-wrapper",
 | 
				
			||||||
                    ref: excalidrawWrapperRef
 | 
					                    ref: this.excalidrawWrapperRef
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
                createElement(Excalidraw, opts)
 | 
					                createElement(Excalidraw, opts)
 | 
				
			||||||
            ));
 | 
					            ));
 | 
				
			||||||
@ -160,5 +159,3 @@ export default class Canvas {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user