2020-01-11 20:34:21 -08:00
|
|
|
import { AppState } from "./types";
|
|
|
|
import { getDateTime } from "./utils";
|
|
|
|
|
|
|
|
const DEFAULT_PROJECT_NAME = `excalidraw-${getDateTime()}`;
|
|
|
|
|
|
|
|
export function getDefaultAppState(): AppState {
|
|
|
|
return {
|
|
|
|
draggingElement: null,
|
|
|
|
resizingElement: null,
|
2020-02-01 15:49:18 +04:00
|
|
|
multiElement: null,
|
2020-01-19 23:32:24 +01:00
|
|
|
editingElement: null,
|
2020-01-11 20:34:21 -08:00
|
|
|
elementType: "selection",
|
2020-01-20 15:52:19 -08:00
|
|
|
elementLocked: false,
|
2020-01-11 20:34:21 -08:00
|
|
|
exportBackground: true,
|
|
|
|
currentItemStrokeColor: "#000000",
|
|
|
|
currentItemBackgroundColor: "transparent",
|
2020-01-25 18:58:57 +01:00
|
|
|
currentItemFillStyle: "hachure",
|
|
|
|
currentItemStrokeWidth: 1,
|
|
|
|
currentItemRoughness: 1,
|
|
|
|
currentItemOpacity: 100,
|
2020-01-11 20:34:21 -08:00
|
|
|
currentItemFont: "20px Virgil",
|
|
|
|
viewBackgroundColor: "#ffffff",
|
|
|
|
scrollX: 0,
|
|
|
|
scrollY: 0,
|
|
|
|
cursorX: 0,
|
|
|
|
cursorY: 0,
|
2020-02-01 16:52:10 +00:00
|
|
|
scrolledOutside: false,
|
2020-01-24 12:04:54 +02:00
|
|
|
name: DEFAULT_PROJECT_NAME,
|
2020-02-03 21:52:21 +04:00
|
|
|
isResizing: false,
|
2020-01-11 20:34:21 -08:00
|
|
|
};
|
|
|
|
}
|
2020-02-01 15:49:18 +04:00
|
|
|
|
2020-02-04 17:39:08 +04:00
|
|
|
export function clearAppStateForLocalStorage(appState: AppState) {
|
|
|
|
const {
|
|
|
|
draggingElement,
|
|
|
|
resizingElement,
|
|
|
|
multiElement,
|
|
|
|
editingElement,
|
|
|
|
isResizing,
|
|
|
|
...exportedState
|
|
|
|
} = appState;
|
|
|
|
return exportedState;
|
|
|
|
}
|
|
|
|
|
2020-02-01 15:49:18 +04:00
|
|
|
export function cleanAppStateForExport(appState: AppState) {
|
|
|
|
return {
|
|
|
|
viewBackgroundColor: appState.viewBackgroundColor,
|
|
|
|
};
|
|
|
|
}
|