You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
4 years ago
|
import { ExcalidrawElement } from "../element/types";
|
||
3 years ago
|
import { AppState, BinaryFiles } from "../types";
|
||
1 year ago
|
import { exportCanvas, prepareElementsForExport } from ".";
|
||
4 years ago
|
import { getFileHandleType, isImageFileHandleType } from "./blob";
|
||
|
|
||
|
export const resaveAsImageWithScene = async (
|
||
|
elements: readonly ExcalidrawElement[],
|
||
|
appState: AppState,
|
||
3 years ago
|
files: BinaryFiles,
|
||
4 years ago
|
) => {
|
||
|
const { exportBackground, viewBackgroundColor, name, 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,
|
||
|
};
|
||
|
|
||
1 year ago
|
const { exportedElements, exportingFrame } = prepareElementsForExport(
|
||
|
elements,
|
||
4 years ago
|
appState,
|
||
1 year ago
|
false,
|
||
4 years ago
|
);
|
||
|
|
||
1 year ago
|
await exportCanvas(fileHandleType, exportedElements, appState, files, {
|
||
|
exportBackground,
|
||
|
viewBackgroundColor,
|
||
|
name,
|
||
|
fileHandle,
|
||
|
exportingFrame,
|
||
|
});
|
||
|
|
||
4 years ago
|
return { fileHandle };
|
||
|
};
|