chore(react/type_widget): add missing interface

This commit is contained in:
Elian Doran 2025-09-22 10:50:03 +03:00
parent 206618fd54
commit adea3abff4
No known key found for this signature in database

View File

@ -9,8 +9,7 @@ import "./Canvas.css";
import FNote from "../../entities/fnote"; import FNote from "../../entities/fnote";
import { RefObject } from "preact"; import { RefObject } from "preact";
import server from "../../services/server"; import server from "../../services/server";
import { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types"; import { ExcalidrawElement, NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types";
import { CanvasContent } from "../type_widgets_old/canvas_el";
import { goToLinkExt } from "../../services/link"; import { goToLinkExt } from "../../services/link";
// currently required by excalidraw, in order to allows self-hosting fonts locally. // currently required by excalidraw, in order to allows self-hosting fonts locally.
@ -22,6 +21,12 @@ interface AttachmentMetadata {
attachmentId: string; attachmentId: string;
} }
interface CanvasContent {
elements: ExcalidrawElement[];
files: BinaryFileData[];
appState: Partial<AppState>;
}
export default function Canvas({ note }: TypeWidgetProps) { export default function Canvas({ note }: TypeWidgetProps) {
const apiRef = useRef<ExcalidrawImperativeAPI>(null); const apiRef = useRef<ExcalidrawImperativeAPI>(null);
const isReadOnly = options.is("databaseReadonly"); const isReadOnly = options.is("databaseReadonly");
@ -141,9 +146,8 @@ function usePersistence(note: FNote, apiRef: RefObject<ExcalidrawImperativeAPI>,
const { content, svg } = await getData(api); const { content, svg } = await getData(api);
const attachments = [{ role: "image", title: "canvas-export.svg", mime: "image/svg+xml", content: svg, position: 0 }]; const attachments = [{ role: "image", title: "canvas-export.svg", mime: "image/svg+xml", content: svg, position: 0 }];
// libraryChanged is unset in dataSaved()
if (libraryChanged.current) { if (libraryChanged.current) {
// this.libraryChanged is unset in dataSaved()
// there's no separate method to get library items, so have to abuse this one // there's no separate method to get library items, so have to abuse this one
const libraryItems = await api.updateLibrary({ const libraryItems = await api.updateLibrary({
libraryItems() { libraryItems() {