fix: remove embeddable from generic elements (#6853)

This commit is contained in:
David Luzar 2023-08-04 15:16:55 +02:00 committed by GitHub
parent bb985eba3a
commit 083bcf802c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 39 additions and 16 deletions

View file

@ -5395,7 +5395,7 @@ class App extends React.Component<AppProps, AppState> {
width: embedLink.aspectRatio.w,
height: embedLink.aspectRatio.h,
link,
validated: undefined,
validated: null,
});
this.scene.replaceAllElements([
@ -5583,7 +5583,7 @@ class App extends React.Component<AppProps, AppState> {
}
private createGenericElementOnPointerDown = (
elementType: ExcalidrawGenericElement["type"],
elementType: ExcalidrawGenericElement["type"] | "embeddable",
pointerDownState: PointerDownState,
): void => {
const [gridX, gridY] = getGridPoint(
@ -5597,8 +5597,7 @@ class App extends React.Component<AppProps, AppState> {
y: gridY,
});
const element = newElement({
type: elementType,
const baseElementAttributes = {
x: gridX,
y: gridY,
strokeColor: this.state.currentItemStrokeColor,
@ -5611,8 +5610,21 @@ class App extends React.Component<AppProps, AppState> {
roundness: this.getCurrentItemRoundness(elementType),
locked: false,
frameId: topLayerFrame ? topLayerFrame.id : null,
...(elementType === "embeddable" ? { validated: false } : {}),
});
} as const;
let element;
if (elementType === "embeddable") {
element = newEmbeddableElement({
type: "embeddable",
validated: null,
...baseElementAttributes,
});
} else {
element = newElement({
type: elementType,
...baseElementAttributes,
});
}
if (element.type === "selection") {
this.setState({