import { DeckOperations , ExcalidrawElement , PrintableArea , } from "@excalideck/deck" ; import { last } from "lodash" ; import ExcalideckEditorState from "./entities/ExcalideckEditorState" ; import View from "./entities/View" ; import SlideUtils from "./utils/SlideUtils" ; const ExcalideckEditorStateOperations = { activateView ( excalideckEditorState , view ) { return { ... excalideckEditorState , activeView : view } ; } , updatePrintableArea ( excalideckEditorState , printableArea ) { return { ... excalideckEditorState , deck : DeckOperations . updatePrintableArea ( excalideckEditorState . deck , printableArea ) , } ; } , updateCommonExcalidrawElements ( excalideckEditorState , commonExcalidrawElements ) { return { ... excalideckEditorState , deck : DeckOperations . updateCommonExcalidrawElements ( excalideckEditorState . deck , commonExcalidrawElements ) , } ; } , addEmptySlide ( excalideckEditorState ) { const newDeck = DeckOperations . addEmptySlide ( excalideckEditorState . deck ) ; const addedSlide = last ( newDeck . slides ) ! ; return { ... excalideckEditorState , deck : newDeck , selectedSlideId : addedSlide . id , } ; } , moveSlide ( excalideckEditorState , fromIndex , toIndex ) { return { ... excalideckEditorState , deck : DeckOperations . moveSlide ( excalideckEditorState . deck , fromIndex , toIndex ) , } ; } , deleteSlide ( excalideckEditorState , slideId ) { const newDeck = DeckOperations . deleteSlide ( excalideckEditorState . deck , excalideckEditorState . selectedSlideId ) ; const newSelectedSlideId = slideId === excalideckEditorState . selectedSlideId ? SlideUtils . getAdjacentSlideId ( excalideckEditorState . deck . slides , excalideckEditorState . selectedSlideId ) ?? newDeck . slides [ 0 ] ! . id : excalideckEditorState . selectedSlideId ; return { ... excalideckEditorState , deck : newDeck , selectedSlideId : newSelectedSlideId , } ; } , updateSlideShouldRender ( excalideckEditorState , slideId , shouldRender ) { return { ... excalideckEditorState , deck : DeckOperations . updateSlideShouldRender ( excalideckEditorState . deck , slideId , shouldRender ) , } ; } , updateSlideShouldRenderWithCommonExcalidrawElements ( excalideckEditorState , slideId , shouldRenderWithCommonExcalidrawElements ) { return { ... excalideckEditorState , deck : DeckOperations . updateSlideShouldRenderWithCommonExcalidrawElements ( excalideckEditorState . deck , slideId , shouldRenderWithCommonExcalidrawElements ) , } ; } , updateSlideExcalidrawElements ( excalideckEditorState , slideId , excalidrawElements ) { return { ... excalideckEditorState , deck : DeckOperations . updateSlideExcalidrawElements ( excalideckEditorState . deck , slideId , excalidrawElements ) , } ; } , selectSlide ( excalideckEditorState , slideId ) { return { ... excalideckEditorState , selectedSlideId : slideId , } ; } , } ; export default ExcalideckEditorStateOperations ;