mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: move elementLocked to activeTool.locked (#4983)
* refactor: move elementLocked to activeTool.locked * fix * fix snap * update docs * Update src/packages/excalidraw/CHANGELOG.md * revert * make lastActiveToolBeforeEraser required and nullable * fix snap
This commit is contained in:
parent
1331cffe93
commit
2fa69ddc32
14 changed files with 199 additions and 113 deletions
|
@ -62,7 +62,6 @@ export const actionClearCanvas = register({
|
|||
...getDefaultAppState(),
|
||||
files: {},
|
||||
theme: appState.theme,
|
||||
elementLocked: appState.elementLocked,
|
||||
penMode: appState.penMode,
|
||||
penDetected: appState.penDetected,
|
||||
exportBackground: appState.exportBackground,
|
||||
|
@ -72,7 +71,7 @@ export const actionClearCanvas = register({
|
|||
pasteDialog: appState.pasteDialog,
|
||||
activeTool:
|
||||
appState.activeTool.type === "image"
|
||||
? { type: "selection" }
|
||||
? { ...appState.activeTool, type: "selection" }
|
||||
: appState.activeTool,
|
||||
},
|
||||
commitToHistory: true,
|
||||
|
@ -311,12 +310,13 @@ export const actionErase = register({
|
|||
selectedElementIds: {},
|
||||
selectedGroupIds: {},
|
||||
activeTool: {
|
||||
...appState.activeTool,
|
||||
type: isEraserActive(appState)
|
||||
? appState.activeTool.lastActiveToolBeforeEraser ?? "selection"
|
||||
: "eraser",
|
||||
lastActiveToolBeforeEraser:
|
||||
appState.activeTool.type === "eraser" //node throws incorrect type error when using isEraserActive()
|
||||
? undefined
|
||||
? null
|
||||
: appState.activeTool.type,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -134,7 +134,7 @@ export const actionDeleteSelected = register({
|
|||
elements: nextElements,
|
||||
appState: {
|
||||
...nextAppState,
|
||||
activeTool: { type: "selection" },
|
||||
activeTool: { ...appState.activeTool, type: "selection" },
|
||||
multiElement: null,
|
||||
},
|
||||
commitToHistory: isSomeElementSelected(
|
||||
|
|
|
@ -121,13 +121,17 @@ export const actionFinalize = register({
|
|||
);
|
||||
}
|
||||
|
||||
if (!appState.elementLocked && appState.activeTool.type !== "freedraw") {
|
||||
if (
|
||||
!appState.activeTool.locked &&
|
||||
appState.activeTool.type !== "freedraw"
|
||||
) {
|
||||
appState.selectedElementIds[multiPointElement.id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
(!appState.elementLocked && appState.activeTool.type !== "freedraw") ||
|
||||
(!appState.activeTool.locked &&
|
||||
appState.activeTool.type !== "freedraw") ||
|
||||
!multiPointElement
|
||||
) {
|
||||
resetCursor(canvas);
|
||||
|
@ -138,10 +142,11 @@ export const actionFinalize = register({
|
|||
appState: {
|
||||
...appState,
|
||||
activeTool:
|
||||
(appState.elementLocked || appState.activeTool.type === "freedraw") &&
|
||||
(appState.activeTool.locked ||
|
||||
appState.activeTool.type === "freedraw") &&
|
||||
multiPointElement
|
||||
? appState.activeTool
|
||||
: { type: "selection" },
|
||||
: { ...appState.activeTool, type: "selection" },
|
||||
draggingElement: null,
|
||||
multiElement: null,
|
||||
editingElement: null,
|
||||
|
@ -149,7 +154,7 @@ export const actionFinalize = register({
|
|||
suggestedBindings: [],
|
||||
selectedElementIds:
|
||||
multiPointElement &&
|
||||
!appState.elementLocked &&
|
||||
!appState.activeTool.locked &&
|
||||
appState.activeTool.type !== "freedraw"
|
||||
? {
|
||||
...appState.selectedElementIds,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue