mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-05 07:08:14 +08:00
refactor(canvas): solve API deprecation
This commit is contained in:
parent
7d3f506efb
commit
f2382e2ef5
@ -8,6 +8,7 @@ import type { ExcalidrawElement, Theme } from "@excalidraw/excalidraw/types/elem
|
|||||||
import type { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, LibraryItem, SceneData } from "@excalidraw/excalidraw/types/types.js";
|
import type { AppState, BinaryFileData, ExcalidrawImperativeAPI, ExcalidrawProps, LibraryItem, SceneData } from "@excalidraw/excalidraw/types/types.js";
|
||||||
import type { JSX } from "react";
|
import type { JSX } from "react";
|
||||||
import type React from "react";
|
import type React from "react";
|
||||||
|
import type { Root } from "react-dom/client";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
||||||
@ -127,6 +128,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
private excalidrawWrapperRef!: React.RefObject<HTMLElement | null>;
|
private excalidrawWrapperRef!: React.RefObject<HTMLElement | null>;
|
||||||
|
|
||||||
private $render!: JQuery<HTMLElement>;
|
private $render!: JQuery<HTMLElement>;
|
||||||
|
private root?: Root;
|
||||||
private reactHandlers!: JQuery<HTMLElement>;
|
private reactHandlers!: JQuery<HTMLElement>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -199,12 +201,11 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
const excalidraw = (await import("@excalidraw/excalidraw"));
|
const excalidraw = (await import("@excalidraw/excalidraw"));
|
||||||
this.excalidrawLib = excalidraw;
|
this.excalidrawLib = excalidraw;
|
||||||
|
|
||||||
const { unmountComponentAtNode } = await import("react-dom");
|
|
||||||
const { createRoot } = await import("react-dom/client");
|
const { createRoot } = await import("react-dom/client");
|
||||||
const React = (await import("react")).default;
|
const React = (await import("react")).default;
|
||||||
unmountComponentAtNode(renderElement);
|
this.root?.unmount();
|
||||||
const root = createRoot(renderElement);
|
this.root = createRoot(renderElement);
|
||||||
root.render(React.createElement(() => this.createExcalidrawReactApp(React, excalidraw.Excalidraw)));
|
this.root.render(React.createElement(() => this.createExcalidrawReactApp(React, excalidraw.Excalidraw)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user