refactor: move elementLocked to activeTool.locked (#4983)

* refactor: move elementLocked to activeTool.locked

* fix

* fix snap

* update docs

* Update src/packages/excalidraw/CHANGELOG.md

* revert

* make lastActiveToolBeforeEraser required and nullable

* fix snap
This commit is contained in:
Aakansha Doshi 2022-03-29 17:10:19 +05:30 committed by GitHub
parent 1331cffe93
commit 2fa69ddc32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 199 additions and 113 deletions

View file

@ -235,10 +235,8 @@ export const restoreAppState = (
localAppState: Partial<AppState> | null | undefined,
): RestoredAppState => {
appState = appState || {};
const defaultAppState = getDefaultAppState();
const nextAppState = {} as typeof defaultAppState;
for (const [key, defaultValue] of Object.entries(defaultAppState) as [
keyof typeof defaultAppState,
any,
@ -252,12 +250,11 @@ export const restoreAppState = (
? localValue
: defaultValue;
}
return {
...nextAppState,
activeTool: AllowedExcalidrawActiveTools[nextAppState.activeTool.type]
? nextAppState.activeTool
: { type: "selection" },
: { ...nextAppState.activeTool, type: "selection" },
// Migrates from previous version where appState.zoom was a number
zoom:
typeof appState.zoom === "number"