|
@@ -1,10 +1,8 @@
|
1
|
1
|
import type { Action } from 'state/constants'
|
2
|
|
-import type { TLPointerInfo } from '@tldraw/core'
|
3
|
|
-import { getPagePoint } from 'state/helpers'
|
4
|
2
|
import { getShapeUtils } from 'shapes'
|
5
|
3
|
import { mutables } from 'state/mutables'
|
6
|
4
|
|
7
|
|
-export const eraseShapesAtPoint: Action = (data, payload: TLPointerInfo) => {
|
|
5
|
+export const eraseShapesAtPoint: Action = (data) => {
|
8
|
6
|
const { currentPoint } = mutables
|
9
|
7
|
|
10
|
8
|
Object.values(data.page.shapes).forEach((shape) => {
|
|
@@ -12,4 +10,17 @@ export const eraseShapesAtPoint: Action = (data, payload: TLPointerInfo) => {
|
12
|
10
|
delete data.page.shapes[shape.id]
|
13
|
11
|
}
|
14
|
12
|
})
|
|
13
|
+
|
|
14
|
+ const { shapes } = data.page
|
|
15
|
+ const { selectedIds, hoveredId } = data.pageState
|
|
16
|
+
|
|
17
|
+ // Filter out any deleted shapes
|
|
18
|
+ data.pageState.selectedIds = selectedIds.filter((id) => {
|
|
19
|
+ return shapes[id] !== undefined
|
|
20
|
+ })
|
|
21
|
+
|
|
22
|
+ // Remove hovered id if it's been deleted
|
|
23
|
+ if (hoveredId && !shapes[hoveredId]) {
|
|
24
|
+ data.pageState.hoveredId = undefined
|
|
25
|
+ }
|
15
|
26
|
}
|