瀏覽代碼

feat: expose app instance on `excalidrawAPI`

dwelle 3 年之前
父節點
當前提交
a834a4fda0
共有 2 個文件被更改,包括 2 次插入0 次删除
  1. 1 0
      src/components/App.tsx
  2. 1 0
      src/types.ts

+ 1 - 0
src/components/App.tsx

@@ -332,6 +332,7 @@ class App extends React.Component<AppProps, AppState> {
         importLibrary: this.importLibraryFromUrl,
         setToastMessage: this.setToastMessage,
         id: this.id,
+        app: this,
       } as const;
       if (typeof excalidrawRef === "function") {
         excalidrawRef(api);

+ 1 - 0
src/types.ts

@@ -378,4 +378,5 @@ export type ExcalidrawImperativeAPI = {
   readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>;
   ready: true;
   id: string;
+  app: InstanceType<typeof App>;
 };