fix: remove draw
element from codebase (#3559)
This commit is contained in:
parent
6bebfe63be
commit
11b8cc2caa
@ -21,6 +21,20 @@ type RestoredAppState = Omit<
|
|||||||
"offsetTop" | "offsetLeft" | "width" | "height"
|
"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 = {
|
export type RestoredDataState = {
|
||||||
elements: ExcalidrawElement[];
|
elements: ExcalidrawElement[];
|
||||||
appState: RestoredAppState;
|
appState: RestoredAppState;
|
||||||
@ -107,7 +121,6 @@ const restoreElement = (
|
|||||||
pressures: element.pressures,
|
pressures: element.pressures,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
case "draw":
|
|
||||||
case "line":
|
case "line":
|
||||||
case "arrow": {
|
case "arrow": {
|
||||||
const {
|
const {
|
||||||
@ -116,7 +129,10 @@ const restoreElement = (
|
|||||||
} = element;
|
} = element;
|
||||||
|
|
||||||
return restoreElementWithProperties(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,
|
startBinding: element.startBinding,
|
||||||
endBinding: element.endBinding,
|
endBinding: element.endBinding,
|
||||||
points:
|
points:
|
||||||
@ -187,6 +203,9 @@ export const restoreAppState = (
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...nextAppState,
|
...nextAppState,
|
||||||
|
elementType: AllowedExcalidrawElementTypes[nextAppState.elementType]
|
||||||
|
? nextAppState.elementType
|
||||||
|
: "selection",
|
||||||
// Migrates from previous version where appState.zoom was a number
|
// Migrates from previous version where appState.zoom was a number
|
||||||
zoom:
|
zoom:
|
||||||
typeof appState.zoom === "number"
|
typeof appState.zoom === "number"
|
||||||
|
@ -180,7 +180,6 @@ const hitTestPointAgainstElement = (args: HitTestArgs): boolean => {
|
|||||||
}
|
}
|
||||||
case "arrow":
|
case "arrow":
|
||||||
case "line":
|
case "line":
|
||||||
case "draw":
|
|
||||||
return hitTestLinear(args);
|
return hitTestLinear(args);
|
||||||
case "selection":
|
case "selection":
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -114,7 +114,7 @@ export type Arrowhead = "arrow" | "bar" | "dot";
|
|||||||
|
|
||||||
export type ExcalidrawLinearElement = _ExcalidrawElementBase &
|
export type ExcalidrawLinearElement = _ExcalidrawElementBase &
|
||||||
Readonly<{
|
Readonly<{
|
||||||
type: "line" | "draw" | "arrow";
|
type: "line" | "arrow";
|
||||||
points: readonly Point[];
|
points: readonly Point[];
|
||||||
lastCommittedPoint: Point | null;
|
lastCommittedPoint: Point | null;
|
||||||
startBinding: PointBinding | null;
|
startBinding: PointBinding | null;
|
||||||
|
@ -142,7 +142,6 @@ const drawElementOnCanvas = (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "arrow":
|
case "arrow":
|
||||||
case "draw":
|
|
||||||
case "line": {
|
case "line": {
|
||||||
context.lineJoin = "round";
|
context.lineJoin = "round";
|
||||||
context.lineCap = "round";
|
context.lineCap = "round";
|
||||||
@ -270,7 +269,6 @@ export const generateRoughOptions = (element: ExcalidrawElement): Options => {
|
|||||||
}
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
case "draw":
|
|
||||||
case "line": {
|
case "line": {
|
||||||
if (isPathALoop(element.points)) {
|
if (isPathALoop(element.points)) {
|
||||||
options.fillStyle = element.fillStyle;
|
options.fillStyle = element.fillStyle;
|
||||||
@ -359,7 +357,6 @@ const generateElementShape = (
|
|||||||
generateRoughOptions(element),
|
generateRoughOptions(element),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "draw":
|
|
||||||
case "line":
|
case "line":
|
||||||
case "arrow": {
|
case "arrow": {
|
||||||
const options = generateRoughOptions(element);
|
const options = generateRoughOptions(element);
|
||||||
@ -589,7 +586,6 @@ export const renderElement = (
|
|||||||
case "rectangle":
|
case "rectangle":
|
||||||
case "diamond":
|
case "diamond":
|
||||||
case "ellipse":
|
case "ellipse":
|
||||||
case "draw":
|
|
||||||
case "line":
|
case "line":
|
||||||
case "arrow":
|
case "arrow":
|
||||||
case "text": {
|
case "text": {
|
||||||
@ -661,7 +657,6 @@ export const renderElementToSvg = (
|
|||||||
svgRoot.appendChild(node);
|
svgRoot.appendChild(node);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "draw":
|
|
||||||
case "line":
|
case "line":
|
||||||
case "arrow": {
|
case "arrow": {
|
||||||
generateElementShape(element, generator);
|
generateElementShape(element, generator);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user