refactor: improve typing & check (#5415)
This commit is contained in:
parent
ba16416c75
commit
792f238d16
@ -128,12 +128,15 @@ const duplicateElements = (
|
|||||||
{
|
{
|
||||||
...appState,
|
...appState,
|
||||||
selectedGroupIds: {},
|
selectedGroupIds: {},
|
||||||
selectedElementIds: newElements.reduce((acc, element) => {
|
selectedElementIds: newElements.reduce(
|
||||||
if (!isBoundToContainer(element)) {
|
(acc: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
acc[element.id] = true;
|
if (!isBoundToContainer(element)) {
|
||||||
}
|
acc[element.id] = true;
|
||||||
return acc;
|
}
|
||||||
}, {} as any),
|
return acc;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
getNonDeletedElements(finalElements),
|
getNonDeletedElements(finalElements),
|
||||||
),
|
),
|
||||||
|
@ -2,6 +2,7 @@ import { KEYS } from "../keys";
|
|||||||
import { register } from "./register";
|
import { register } from "./register";
|
||||||
import { selectGroupsForSelectedElements } from "../groups";
|
import { selectGroupsForSelectedElements } from "../groups";
|
||||||
import { getNonDeletedElements, isTextElement } from "../element";
|
import { getNonDeletedElements, isTextElement } from "../element";
|
||||||
|
import { ExcalidrawElement } from "../element/types";
|
||||||
|
|
||||||
export const actionSelectAll = register({
|
export const actionSelectAll = register({
|
||||||
name: "selectAll",
|
name: "selectAll",
|
||||||
@ -15,16 +16,19 @@ export const actionSelectAll = register({
|
|||||||
{
|
{
|
||||||
...appState,
|
...appState,
|
||||||
editingGroupId: null,
|
editingGroupId: null,
|
||||||
selectedElementIds: elements.reduce((map, element) => {
|
selectedElementIds: elements.reduce(
|
||||||
if (
|
(map: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
!element.isDeleted &&
|
if (
|
||||||
!(isTextElement(element) && element.containerId) &&
|
!element.isDeleted &&
|
||||||
element.locked === false
|
!(isTextElement(element) && element.containerId) &&
|
||||||
) {
|
!element.locked
|
||||||
map[element.id] = true;
|
) {
|
||||||
}
|
map[element.id] = true;
|
||||||
return map;
|
}
|
||||||
}, {} as any),
|
return map;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
getNonDeletedElements(elements),
|
getNonDeletedElements(elements),
|
||||||
),
|
),
|
||||||
|
@ -1540,12 +1540,15 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
this.state.isLibraryOpen && this.device.canDeviceFitSidebar
|
this.state.isLibraryOpen && this.device.canDeviceFitSidebar
|
||||||
? this.state.isLibraryMenuDocked
|
? this.state.isLibraryMenuDocked
|
||||||
: false,
|
: false,
|
||||||
selectedElementIds: newElements.reduce((map, element) => {
|
selectedElementIds: newElements.reduce(
|
||||||
if (!isBoundToContainer(element)) {
|
(acc: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
map[element.id] = true;
|
if (!isBoundToContainer(element)) {
|
||||||
}
|
acc[element.id] = true;
|
||||||
return map;
|
}
|
||||||
}, {} as any),
|
return acc;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
),
|
||||||
selectedGroupIds: {},
|
selectedGroupIds: {},
|
||||||
},
|
},
|
||||||
this.scene.getNonDeletedElements(),
|
this.scene.getNonDeletedElements(),
|
||||||
@ -4307,10 +4310,13 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
...prevState,
|
...prevState,
|
||||||
selectedElementIds: {
|
selectedElementIds: {
|
||||||
...prevState.selectedElementIds,
|
...prevState.selectedElementIds,
|
||||||
...elementsWithinSelection.reduce((map, element) => {
|
...elementsWithinSelection.reduce(
|
||||||
map[element.id] = true;
|
(acc: Record<ExcalidrawElement["id"], true>, element) => {
|
||||||
return map;
|
acc[element.id] = true;
|
||||||
}, {} as any),
|
return acc;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
),
|
||||||
...(pointerDownState.hit.element
|
...(pointerDownState.hit.element
|
||||||
? {
|
? {
|
||||||
// if using ctrl/cmd, select the hitElement only if we
|
// if using ctrl/cmd, select the hitElement only if we
|
||||||
|
Loading…
x
Reference in New Issue
Block a user