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 {
|
try {
|
||||||
const data = JSON.parse(contents);
|
const data = JSON.parse(contents);
|
||||||
if (isValidExcalidrawData(data)) {
|
if (isValidExcalidrawData(data)) {
|
||||||
const excaldrawElements = data.elements || [];
|
|
||||||
return {
|
return {
|
||||||
type: MIME_TYPES.excalidraw,
|
type: MIME_TYPES.excalidraw,
|
||||||
data: restore(
|
data: restore(
|
||||||
{
|
{
|
||||||
elements: clearElementsForExport(excaldrawElements),
|
elements: clearElementsForExport(data.elements || []),
|
||||||
appState: {
|
appState: {
|
||||||
theme: localAppState?.theme,
|
theme: localAppState?.theme,
|
||||||
fileHandle: fileHandle || blob.handle || null,
|
fileHandle: fileHandle || blob.handle || null,
|
||||||
...cleanAppStateForExport(data.appState || {}),
|
...cleanAppStateForExport(data.appState || {}),
|
||||||
...(localAppState
|
...(localAppState
|
||||||
? calculateScrollCenter(excaldrawElements, localAppState, null)
|
? calculateScrollCenter(
|
||||||
|
data.elements || [],
|
||||||
|
localAppState,
|
||||||
|
null,
|
||||||
|
)
|
||||||
: {}),
|
: {}),
|
||||||
},
|
},
|
||||||
files: data.files,
|
files: data.files,
|
||||||
|
|
|
@ -83,7 +83,7 @@ const getFontFamilyByName = (fontFamilyName: string): FontFamilyValues => {
|
||||||
return DEFAULT_FONT_FAMILY;
|
return DEFAULT_FONT_FAMILY;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const restoreElementWithProperties = <
|
const restoreElementWithProperties = <
|
||||||
T extends Required<Omit<ExcalidrawElement, "customData">> & {
|
T extends Required<Omit<ExcalidrawElement, "customData">> & {
|
||||||
customData?: ExcalidrawElement["customData"];
|
customData?: ExcalidrawElement["customData"];
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
|
|
|
@ -322,9 +322,8 @@ const ExcalidrawWrapper = () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const sceneElements = data.scene.elements;
|
|
||||||
const fileIds =
|
const fileIds =
|
||||||
sceneElements?.reduce((acc, element) => {
|
data.scene.elements?.reduce((acc, element) => {
|
||||||
if (isInitializedImageElement(element)) {
|
if (isInitializedImageElement(element)) {
|
||||||
return acc.concat(element.fileId);
|
return acc.concat(element.fileId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,10 @@ import { ImportedLibraryData } from "../../../data/types";
|
||||||
import CustomFooter from "./CustomFooter";
|
import CustomFooter from "./CustomFooter";
|
||||||
import MobileFooter from "./MobileFooter";
|
import MobileFooter from "./MobileFooter";
|
||||||
import { KEYS } from "../../../keys";
|
import { KEYS } from "../../../keys";
|
||||||
import { convertToExcalidrawElements } from "../../../data/transform";
|
import {
|
||||||
|
convertToExcalidrawElements,
|
||||||
|
ExcalidrawProgrammaticAPI,
|
||||||
|
} from "../../../data/transform";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
@ -143,8 +146,9 @@ export default function App({ appTitle, useCustom, customArgs }: AppProps) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
initialStatePromiseRef.current.promise.resolve({
|
initialStatePromiseRef.current.promise.resolve({
|
||||||
...initialData,
|
...initialData,
|
||||||
//@ts-ignore
|
elements: convertToExcalidrawElements(
|
||||||
elements: convertToExcalidrawElements(initialData.elements),
|
initialData.elements as ExcalidrawProgrammaticAPI["elements"],
|
||||||
|
),
|
||||||
});
|
});
|
||||||
excalidrawAPI.addFiles(imagesArray);
|
excalidrawAPI.addFiles(imagesArray);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue