elementLock.ts 965 B

1234567891011121314151617181920212223242526272829
  1. import { PPTElement } from '@/types/slides'
  2. export const lockElement = (elementList: PPTElement[], handleElement: PPTElement, activeElementIdList: string[]) => {
  3. const copyOfElementList: PPTElement[] = JSON.parse(JSON.stringify(elementList))
  4. for(const element of copyOfElementList) {
  5. if(activeElementIdList.includes(handleElement.elId)) element.isLock = true
  6. }
  7. return copyOfElementList
  8. }
  9. export const unlockElement = (elementList: PPTElement[], handleElement: PPTElement) => {
  10. const copyOfElementList: PPTElement[] = JSON.parse(JSON.stringify(elementList))
  11. if(handleElement.groupId) {
  12. for(const element of copyOfElementList) {
  13. if(element.groupId === handleElement.groupId) element.isLock = false
  14. }
  15. return copyOfElementList
  16. }
  17. for(const element of copyOfElementList) {
  18. if(element.elId === handleElement.elId) {
  19. element.isLock = false
  20. break
  21. }
  22. }
  23. return copyOfElementList
  24. }