mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +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 server from "../../services/server.js";
|
||||||
import type FNote from "../../entities/fnote.js";
|
import type FNote from "../../entities/fnote.js";
|
||||||
import options from "../../services/options.js";
|
import options from "../../services/options.js";
|
||||||
|
import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="canvas-widget note-detail-canvas note-detail-printable note-detail">
|
<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;
|
(window.process.env as any).PREACT = false;
|
||||||
|
|
||||||
const renderCanvas = (await import("./canvas_el.js")).default;
|
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/excalidraw/index.css";
|
||||||
import { Excalidraw } from "@excalidraw/excalidraw";
|
import { Excalidraw } from "@excalidraw/excalidraw";
|
||||||
import { createElement, createRef, Fragment, render } from "preact/compat";
|
import { createElement, createRef, Fragment, render } from "preact/compat";
|
||||||
|
import { ExcalidrawProps } from "@excalidraw/excalidraw/types";
|
||||||
|
|
||||||
export default function renderCanvas(targetEl: HTMLElement) {
|
export default function renderCanvas(targetEl: HTMLElement, opts: ExcalidrawProps) {
|
||||||
render(createCanvasElement(), targetEl);
|
render(createCanvasElement(opts), targetEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCanvasElement() {
|
function createCanvasElement(opts: ExcalidrawProps) {
|
||||||
const excalidrawWrapperRef = createRef<HTMLElement>();
|
const excalidrawWrapperRef = createRef<HTMLElement>();
|
||||||
|
|
||||||
return createElement(Fragment, null,
|
return createElement(Fragment, null,
|
||||||
@ -16,8 +17,6 @@ function createCanvasElement() {
|
|||||||
className: "excalidraw-wrapper",
|
className: "excalidraw-wrapper",
|
||||||
ref: excalidrawWrapperRef
|
ref: excalidrawWrapperRef
|
||||||
},
|
},
|
||||||
createElement(Excalidraw, {
|
createElement(Excalidraw, opts)
|
||||||
|
|
||||||
})
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user