fix: remove draw element from codebase (#3559)

This commit is contained in:
David Luzar 2021-05-10 11:01:10 +02:00 committed by GitHub
parent 6bebfe63be
commit 11b8cc2caa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View file

@ -21,6 +21,20 @@ type RestoredAppState = Omit<
"offsetTop" | "offsetLeft" | "width" | "height"
>;
export const AllowedExcalidrawElementTypes: Record<
ExcalidrawElement["type"],
true
> = {
selection: true,
text: true,
rectangle: true,
diamond: true,
ellipse: true,
line: true,
arrow: true,
freedraw: true,
};
export type RestoredDataState = {
elements: ExcalidrawElement[];
appState: RestoredAppState;
@ -107,7 +121,6 @@ const restoreElement = (
pressures: element.pressures,
});
}
case "draw":
case "line":
case "arrow": {
const {
@ -116,7 +129,10 @@ const restoreElement = (
} = element;
return restoreElementWithProperties(element, {
type: element.type === "draw" ? "line" : element.type,
type:
(element.type as ExcalidrawElement["type"] | "draw") === "draw"
? "line"
: element.type,
startBinding: element.startBinding,
endBinding: element.endBinding,
points:
@ -187,6 +203,9 @@ export const restoreAppState = (
return {
...nextAppState,
elementType: AllowedExcalidrawElementTypes[nextAppState.elementType]
? nextAppState.elementType
: "selection",
// Migrates from previous version where appState.zoom was a number
zoom:
typeof appState.zoom === "number"