mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
add default selection tool
This commit is contained in:
@ -458,6 +458,7 @@ import type {
|
|||||||
GenerateDiagramToCode,
|
GenerateDiagramToCode,
|
||||||
NullableGridSize,
|
NullableGridSize,
|
||||||
Offsets,
|
Offsets,
|
||||||
|
ActiveTool,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { RoughCanvas } from "roughjs/bin/canvas";
|
import type { RoughCanvas } from "roughjs/bin/canvas";
|
||||||
import type { Action, ActionResult } from "../actions/types";
|
import type { Action, ActionResult } from "../actions/types";
|
||||||
@ -650,9 +651,14 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
>();
|
>();
|
||||||
onRemoveEventListenersEmitter = new Emitter<[]>();
|
onRemoveEventListenersEmitter = new Emitter<[]>();
|
||||||
|
|
||||||
|
defaultSelectionTool: "selection" | "lasso" = "selection";
|
||||||
|
|
||||||
constructor(props: AppProps) {
|
constructor(props: AppProps) {
|
||||||
super(props);
|
super(props);
|
||||||
const defaultAppState = getDefaultAppState();
|
const defaultAppState = getDefaultAppState();
|
||||||
|
this.defaultSelectionTool = this.isMobileOrTablet()
|
||||||
|
? ("lasso" as const)
|
||||||
|
: ("selection" as const);
|
||||||
const {
|
const {
|
||||||
excalidrawAPI,
|
excalidrawAPI,
|
||||||
viewModeEnabled = false,
|
viewModeEnabled = false,
|
||||||
@ -2338,6 +2344,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const scene = restore(initialData, null, null, { repairBindings: true });
|
const scene = restore(initialData, null, null, { repairBindings: true });
|
||||||
|
const activeTool = scene.appState.activeTool;
|
||||||
scene.appState = {
|
scene.appState = {
|
||||||
...scene.appState,
|
...scene.appState,
|
||||||
theme: this.props.theme || scene.appState.theme,
|
theme: this.props.theme || scene.appState.theme,
|
||||||
@ -2347,8 +2354,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
// with a library install link, which should auto-open the library)
|
// with a library install link, which should auto-open the library)
|
||||||
openSidebar: scene.appState?.openSidebar || this.state.openSidebar,
|
openSidebar: scene.appState?.openSidebar || this.state.openSidebar,
|
||||||
activeTool:
|
activeTool:
|
||||||
scene.appState.activeTool.type === "image"
|
activeTool.type === "image" ||
|
||||||
? { ...scene.appState.activeTool, type: "selection" }
|
activeTool.type === "lasso" ||
|
||||||
|
activeTool.type === "selection"
|
||||||
|
? {
|
||||||
|
...activeTool,
|
||||||
|
type: this.defaultSelectionTool,
|
||||||
|
}
|
||||||
: scene.appState.activeTool,
|
: scene.appState.activeTool,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
toast: this.state.toast,
|
toast: this.state.toast,
|
||||||
|
@ -733,6 +733,8 @@ export type AppClassProperties = {
|
|||||||
|
|
||||||
onPointerUpEmitter: App["onPointerUpEmitter"];
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
||||||
updateEditorAtom: App["updateEditorAtom"];
|
updateEditorAtom: App["updateEditorAtom"];
|
||||||
|
|
||||||
|
defaultSelectionTool: "selection" | "lasso";
|
||||||
};
|
};
|
||||||
|
|
||||||
export type PointerDownState = Readonly<{
|
export type PointerDownState = Readonly<{
|
||||||
|
Reference in New Issue
Block a user