mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
* fix: remove t and allow name to be nullable * pass name as required prop * remove Unnamed * pass name to excalidrawPlus as well for better type safe * render once we have excalidrawAPI to avoid defaulting * rename `getAppName` -> `getName` (temporary) * stop preventing editing filenames when `props.name` supplied * keep `name` as optional param for export functions * keep `appState.name` on `props.name` state separate * fix lint * assertive first * fix lint * Add TODO --------- Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { ExcalidrawElement } from "../element/types";
|
|
import { AppState, BinaryFiles } from "../types";
|
|
import { exportCanvas, prepareElementsForExport } from ".";
|
|
import { getFileHandleType, isImageFileHandleType } from "./blob";
|
|
|
|
export const resaveAsImageWithScene = async (
|
|
elements: readonly ExcalidrawElement[],
|
|
appState: AppState,
|
|
files: BinaryFiles,
|
|
name: string,
|
|
) => {
|
|
const { exportBackground, viewBackgroundColor, fileHandle } = appState;
|
|
|
|
const fileHandleType = getFileHandleType(fileHandle);
|
|
|
|
if (!fileHandle || !isImageFileHandleType(fileHandleType)) {
|
|
throw new Error(
|
|
"fileHandle should exist and should be of type svg or png when resaving",
|
|
);
|
|
}
|
|
appState = {
|
|
...appState,
|
|
exportEmbedScene: true,
|
|
};
|
|
|
|
const { exportedElements, exportingFrame } = prepareElementsForExport(
|
|
elements,
|
|
appState,
|
|
false,
|
|
);
|
|
|
|
await exportCanvas(fileHandleType, exportedElements, appState, files, {
|
|
exportBackground,
|
|
viewBackgroundColor,
|
|
name,
|
|
fileHandle,
|
|
exportingFrame,
|
|
});
|
|
|
|
return { fileHandle };
|
|
};
|