Merge branch 'dev' of https://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into dev
This commit is contained in:
commit
8f36a5a170
16
src/hooks/useObject.js
Normal file
16
src/hooks/useObject.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { useRecoilValue } from 'recoil'
|
||||||
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
|
|
||||||
|
export function useObject() {
|
||||||
|
const canvas = useRecoilValue(canvasState)
|
||||||
|
|
||||||
|
const deleteObject = (obj) => {
|
||||||
|
canvas
|
||||||
|
?.getObjects()
|
||||||
|
.filter((item) => item.parent === obj || item.parentId === obj.id)
|
||||||
|
.forEach((item) => {
|
||||||
|
canvas.remove(item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return { deleteObject }
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user