mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
keep lasso if selected from toolbar
This commit is contained in:
parent
ded26bea97
commit
df988e83f6
5 changed files with 15 additions and 4 deletions
|
@ -532,6 +532,7 @@ export const actionToggleLassoTool = register({
|
||||||
if (appState.activeTool.type !== "lasso") {
|
if (appState.activeTool.type !== "lasso") {
|
||||||
activeTool = updateActiveTool(appState, {
|
activeTool = updateActiveTool(appState, {
|
||||||
type: "lasso",
|
type: "lasso",
|
||||||
|
fromSelection: false,
|
||||||
});
|
});
|
||||||
setCursor(app.interactiveCanvas, CURSOR_TYPE.CROSSHAIR);
|
setCursor(app.interactiveCanvas, CURSOR_TYPE.CROSSHAIR);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -52,6 +52,7 @@ export const getDefaultAppState = (): Omit<
|
||||||
type: "selection",
|
type: "selection",
|
||||||
customType: null,
|
customType: null,
|
||||||
locked: DEFAULT_ELEMENT_PROPS.locked,
|
locked: DEFAULT_ELEMENT_PROPS.locked,
|
||||||
|
fromSelection: false,
|
||||||
lastActiveTool: null,
|
lastActiveTool: null,
|
||||||
},
|
},
|
||||||
penMode: false,
|
penMode: false,
|
||||||
|
|
|
@ -4696,7 +4696,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| { type: "custom"; customType: string }
|
| { type: "custom"; customType: string }
|
||||||
) & { locked?: boolean },
|
) & { locked?: boolean; fromSelection?: boolean },
|
||||||
) => {
|
) => {
|
||||||
if (!this.isToolSupported(tool.type)) {
|
if (!this.isToolSupported(tool.type)) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -8592,7 +8592,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
pointerDownState.lastCoords.x = pointerCoords.x;
|
pointerDownState.lastCoords.x = pointerCoords.x;
|
||||||
pointerDownState.lastCoords.y = pointerCoords.y;
|
pointerDownState.lastCoords.y = pointerCoords.y;
|
||||||
if (event.altKey) {
|
if (event.altKey) {
|
||||||
this.setActiveTool({ type: "lasso" });
|
this.setActiveTool({ type: "lasso", fromSelection: true });
|
||||||
this.lassoTrail.startPath(pointerCoords.x, pointerCoords.y);
|
this.lassoTrail.startPath(pointerCoords.x, pointerCoords.y);
|
||||||
this.setAppState({
|
this.setAppState({
|
||||||
selectionElement: null,
|
selectionElement: null,
|
||||||
|
@ -9684,7 +9684,13 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activeTool.locked && activeTool.type !== "freedraw") {
|
if (
|
||||||
|
!activeTool.locked &&
|
||||||
|
activeTool.type !== "freedraw" &&
|
||||||
|
// if lasso is turned on but from selection => reset to selection
|
||||||
|
activeTool.type === "lasso" &&
|
||||||
|
activeTool.fromSelection
|
||||||
|
) {
|
||||||
resetCursor(this.interactiveCanvas);
|
resetCursor(this.interactiveCanvas);
|
||||||
this.setState({
|
this.setState({
|
||||||
newElement: null,
|
newElement: null,
|
||||||
|
|
|
@ -300,6 +300,8 @@ export interface AppState {
|
||||||
*/
|
*/
|
||||||
lastActiveTool: ActiveTool | null;
|
lastActiveTool: ActiveTool | null;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
|
// indicates if the current tool is temporarily switched on from the selection tool
|
||||||
|
fromSelection: boolean;
|
||||||
} & ActiveTool;
|
} & ActiveTool;
|
||||||
penMode: boolean;
|
penMode: boolean;
|
||||||
penDetected: boolean;
|
penDetected: boolean;
|
||||||
|
|
|
@ -382,7 +382,7 @@ export const updateActiveTool = (
|
||||||
type: ToolType;
|
type: ToolType;
|
||||||
}
|
}
|
||||||
| { type: "custom"; customType: string }
|
| { type: "custom"; customType: string }
|
||||||
) & { locked?: boolean }) & {
|
) & { locked?: boolean; fromSelection?: boolean }) & {
|
||||||
lastActiveToolBeforeEraser?: ActiveTool | null;
|
lastActiveToolBeforeEraser?: ActiveTool | null;
|
||||||
},
|
},
|
||||||
): AppState["activeTool"] => {
|
): AppState["activeTool"] => {
|
||||||
|
@ -404,6 +404,7 @@ export const updateActiveTool = (
|
||||||
type: data.type,
|
type: data.type,
|
||||||
customType: null,
|
customType: null,
|
||||||
locked: data.locked ?? appState.activeTool.locked,
|
locked: data.locked ?? appState.activeTool.locked,
|
||||||
|
fromSelection: data.fromSelection ?? false,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue