mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
cleanup
This commit is contained in:
parent
7a94ee3191
commit
d994f72c40
5 changed files with 15 additions and 9 deletions
|
@ -134,18 +134,21 @@ export const loadSceneOrLibraryFromBlob = async (
|
|||
try {
|
||||
const data = JSON.parse(contents);
|
||||
if (isValidExcalidrawData(data)) {
|
||||
const excaldrawElements = data.elements || [];
|
||||
return {
|
||||
type: MIME_TYPES.excalidraw,
|
||||
data: restore(
|
||||
{
|
||||
elements: clearElementsForExport(excaldrawElements),
|
||||
elements: clearElementsForExport(data.elements || []),
|
||||
appState: {
|
||||
theme: localAppState?.theme,
|
||||
fileHandle: fileHandle || blob.handle || null,
|
||||
...cleanAppStateForExport(data.appState || {}),
|
||||
...(localAppState
|
||||
? calculateScrollCenter(excaldrawElements, localAppState, null)
|
||||
? calculateScrollCenter(
|
||||
data.elements || [],
|
||||
localAppState,
|
||||
null,
|
||||
)
|
||||
: {}),
|
||||
},
|
||||
files: data.files,
|
||||
|
|
|
@ -83,7 +83,7 @@ const getFontFamilyByName = (fontFamilyName: string): FontFamilyValues => {
|
|||
return DEFAULT_FONT_FAMILY;
|
||||
};
|
||||
|
||||
export const restoreElementWithProperties = <
|
||||
const restoreElementWithProperties = <
|
||||
T extends Required<Omit<ExcalidrawElement, "customData">> & {
|
||||
customData?: ExcalidrawElement["customData"];
|
||||
/** @deprecated */
|
||||
|
|
|
@ -322,9 +322,8 @@ const ExcalidrawWrapper = () => {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
const sceneElements = data.scene.elements;
|
||||
const fileIds =
|
||||
sceneElements?.reduce((acc, element) => {
|
||||
data.scene.elements?.reduce((acc, element) => {
|
||||
if (isInitializedImageElement(element)) {
|
||||
return acc.concat(element.fileId);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,10 @@ import { ImportedLibraryData } from "../../../data/types";
|
|||
import CustomFooter from "./CustomFooter";
|
||||
import MobileFooter from "./MobileFooter";
|
||||
import { KEYS } from "../../../keys";
|
||||
import { convertToExcalidrawElements } from "../../../data/transform";
|
||||
import {
|
||||
convertToExcalidrawElements,
|
||||
ExcalidrawProgrammaticAPI,
|
||||
} from "../../../data/transform";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
@ -143,8 +146,9 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) {
|
|||
//@ts-ignore
|
||||
initialStatePromiseRef.current.promise.resolve({
|
||||
...initialData,
|
||||
//@ts-ignore
|
||||
elements: convertToExcalidrawElements(initialData.elements),
|
||||
elements: convertToExcalidrawElements(
|
||||
initialData.elements as ExcalidrawProgrammaticAPI["elements"],
|
||||
),
|
||||
});
|
||||
excalidrawAPI.addFiles(imagesArray);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue