mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: double image dialog shown on insert (#7152)
This commit is contained in:
parent
44d9d5fcac
commit
aaf73c8ff3
4 changed files with 26 additions and 50 deletions
|
@ -1188,7 +1188,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||
>
|
||||
<LayerUI
|
||||
canvas={this.canvas}
|
||||
interactiveCanvas={this.interactiveCanvas}
|
||||
appState={this.state}
|
||||
files={this.files}
|
||||
setAppState={this.setAppState}
|
||||
|
@ -1205,7 +1204,6 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.state.zenModeEnabled
|
||||
}
|
||||
UIOptions={this.props.UIOptions}
|
||||
onImageAction={this.onImageAction}
|
||||
onExportImage={this.onExportImage}
|
||||
renderWelcomeScreen={
|
||||
!this.state.isLoading &&
|
||||
|
@ -3135,9 +3133,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
setActiveTool = (
|
||||
tool:
|
||||
| {
|
||||
type: ToolType;
|
||||
}
|
||||
| (
|
||||
| { type: Exclude<ToolType, "image"> }
|
||||
| {
|
||||
type: Extract<ToolType, "image">;
|
||||
insertOnCanvasDirectly?: boolean;
|
||||
}
|
||||
)
|
||||
| { type: "custom"; customType: string },
|
||||
) => {
|
||||
const nextActiveTool = updateActiveTool(this.state, tool);
|
||||
|
@ -3153,7 +3155,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||
this.setState({ suggestedBindings: [] });
|
||||
}
|
||||
if (nextActiveTool.type === "image") {
|
||||
this.onImageAction();
|
||||
this.onImageAction({
|
||||
insertOnCanvasDirectly:
|
||||
(tool.type === "image" && tool.insertOnCanvasDirectly) ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
this.setState((prevState) => {
|
||||
|
@ -7353,9 +7358,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||
}
|
||||
};
|
||||
|
||||
private onImageAction = async (
|
||||
{ insertOnCanvasDirectly } = { insertOnCanvasDirectly: false },
|
||||
) => {
|
||||
private onImageAction = async ({
|
||||
insertOnCanvasDirectly,
|
||||
}: {
|
||||
insertOnCanvasDirectly: boolean;
|
||||
}) => {
|
||||
try {
|
||||
const clientX = this.state.width / 2 + this.state.offsetLeft;
|
||||
const clientY = this.state.height / 2 + this.state.offsetTop;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue