feat(tag): delete obj-> tag
This commit is contained in:
@@ -299,6 +299,39 @@ const handleDelete = () => {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cleanupDeletedObjectItems = (
|
||||||
|
imageId: string,
|
||||||
|
pathId?: number,
|
||||||
|
parentGroupId?: number
|
||||||
|
) => {
|
||||||
|
if (!pathId) return
|
||||||
|
|
||||||
|
usePaperStore
|
||||||
|
.getState()
|
||||||
|
.group?.getItems({
|
||||||
|
data: { id: pathId },
|
||||||
|
})
|
||||||
|
.forEach((item) => {
|
||||||
|
item.remove()
|
||||||
|
})
|
||||||
|
|
||||||
|
useObjectStore.getState().updateSelectedPath(imageId, "DELETE", pathId)
|
||||||
|
|
||||||
|
if (!parentGroupId) return
|
||||||
|
|
||||||
|
const groupMap = useRightToolsStore.getState().pathGroupMap.get(imageId)
|
||||||
|
const currentGroupIds = groupMap
|
||||||
|
?.get(parentGroupId)
|
||||||
|
?.filter((id) => id !== pathId)
|
||||||
|
|
||||||
|
if (!currentGroupIds || currentGroupIds.length <= 1) {
|
||||||
|
groupMap?.delete(parentGroupId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
groupMap?.set(parentGroupId, currentGroupIds)
|
||||||
|
}
|
||||||
|
|
||||||
const handleShift = (flag: boolean) => {
|
const handleShift = (flag: boolean) => {
|
||||||
useKeyEventStore.getState().setShift(flag)
|
useKeyEventStore.getState().setShift(flag)
|
||||||
}
|
}
|
||||||
@@ -2556,6 +2589,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
rectPath.data.operationId,
|
rectPath.data.operationId,
|
||||||
rectPath.data.id
|
rectPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
rectPath.data.imageId,
|
||||||
|
rectPath.data.id,
|
||||||
|
rectPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
forceUpdate()
|
forceUpdate()
|
||||||
@@ -2807,6 +2845,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
polygonPath.data.operationId,
|
polygonPath.data.operationId,
|
||||||
polygonPath.data.id
|
polygonPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
polygonPath.data.imageId,
|
||||||
|
polygonPath.data.id,
|
||||||
|
polygonPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2886,6 +2929,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
brushPath.data.operationId,
|
brushPath.data.operationId,
|
||||||
brushPath.data.id
|
brushPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
brushPath.data.imageId,
|
||||||
|
brushPath.data.id,
|
||||||
|
brushPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (brushPath instanceof paper.Path) {
|
} else if (brushPath instanceof paper.Path) {
|
||||||
@@ -2913,6 +2961,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
brushPath.data.operationId,
|
brushPath.data.operationId,
|
||||||
brushPath.data.id
|
brushPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
brushPath.data.imageId,
|
||||||
|
brushPath.data.id,
|
||||||
|
brushPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usePaperSupportStore.getState().removeMaskById(brushPath.data.id)
|
usePaperSupportStore.getState().removeMaskById(brushPath.data.id)
|
||||||
@@ -2923,6 +2976,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
brushPath.data.operationId,
|
brushPath.data.operationId,
|
||||||
brushPath.data.id
|
brushPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
brushPath.data.imageId,
|
||||||
|
brushPath.data.id,
|
||||||
|
brushPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2983,6 +3041,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
pointPath.data.operationId,
|
pointPath.data.operationId,
|
||||||
pointPath.data.id
|
pointPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
pointPath.data.imageId,
|
||||||
|
pointPath.data.id,
|
||||||
|
pointPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usePaperSupportStore.getState().removeMaskById(pointPath.data.id)
|
usePaperSupportStore.getState().removeMaskById(pointPath.data.id)
|
||||||
@@ -2993,6 +3056,11 @@ export const usePaperStore = create<PaperState>((set) => ({
|
|||||||
pointPath.data.operationId,
|
pointPath.data.operationId,
|
||||||
pointPath.data.id
|
pointPath.data.id
|
||||||
)
|
)
|
||||||
|
cleanupDeletedObjectItems(
|
||||||
|
pointPath.data.imageId,
|
||||||
|
pointPath.data.id,
|
||||||
|
pointPath.data.parentGroupId
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user