mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
chore(canvas): missing API endpoint
This commit is contained in:
parent
3e0f420eec
commit
5ad3d7d077
@ -3,6 +3,7 @@ import utils from "../../services/utils.js";
|
||||
import server from "../../services/server.js";
|
||||
import type FNote from "../../entities/fnote.js";
|
||||
import options from "../../services/options.js";
|
||||
import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
||||
@ -184,7 +185,11 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
||||
(window.process.env as any).PREACT = false;
|
||||
|
||||
const renderCanvas = (await import("./canvas_el.js")).default;
|
||||
renderCanvas(renderElement);
|
||||
renderCanvas(renderElement, {
|
||||
excalidrawAPI: (api: ExcalidrawImperativeAPI) => {
|
||||
this.excalidrawApi = api;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,12 +1,13 @@
|
||||
import "@excalidraw/excalidraw/index.css";
|
||||
import { Excalidraw } from "@excalidraw/excalidraw";
|
||||
import { createElement, createRef, Fragment, render } from "preact/compat";
|
||||
import { ExcalidrawProps } from "@excalidraw/excalidraw/types";
|
||||
|
||||
export default function renderCanvas(targetEl: HTMLElement) {
|
||||
render(createCanvasElement(), targetEl);
|
||||
export default function renderCanvas(targetEl: HTMLElement, opts: ExcalidrawProps) {
|
||||
render(createCanvasElement(opts), targetEl);
|
||||
}
|
||||
|
||||
function createCanvasElement() {
|
||||
function createCanvasElement(opts: ExcalidrawProps) {
|
||||
const excalidrawWrapperRef = createRef<HTMLElement>();
|
||||
|
||||
return createElement(Fragment, null,
|
||||
@ -16,8 +17,6 @@ function createCanvasElement() {
|
||||
className: "excalidraw-wrapper",
|
||||
ref: excalidrawWrapperRef
|
||||
},
|
||||
createElement(Excalidraw, {
|
||||
|
||||
})
|
||||
createElement(Excalidraw, opts)
|
||||
));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user