useShapeFormatPainter.ts 785 B

12345678910111213141516171819202122232425262728
  1. import { storeToRefs } from 'pinia'
  2. import { useMainStore } from '@/store'
  3. import type { PPTShapeElement } from '@/types/slides'
  4. export default () => {
  5. const mainStore = useMainStore()
  6. const { shapeFormatPainter, handleElement } = storeToRefs(mainStore)
  7. const toggleShapeFormatPainter = (keep = false) => {
  8. const _handleElement = handleElement.value as PPTShapeElement
  9. if (shapeFormatPainter.value) mainStore.setShapeFormatPainter(null)
  10. else {
  11. mainStore.setShapeFormatPainter({
  12. keep,
  13. fill: _handleElement.fill,
  14. gradient: _handleElement.gradient,
  15. outline: _handleElement.outline,
  16. opacity: _handleElement.opacity,
  17. shadow: _handleElement.shadow,
  18. })
  19. }
  20. }
  21. return {
  22. toggleShapeFormatPainter,
  23. }
  24. }