import OutOfFlow from './OutOfFlow' ; import { validateRuntimeOptions , RuntimeTypes } from '../runtimeOptionChecker' ; import { div } from '../dom' ; import { Book } from '../book' ; import { CSSSelector , PageMaker } from '../types' ; export interface FullBleedPageRuleOptions { selector : CSSSelector ; continue : 'next' | 'same' | 'left' | 'right' ; rotate : 'none' | 'inward' | 'outward' | 'clockwise' | 'counterclockwise' ; } class FullBleedPage extends OutOfFlow { rotate ! : string ; continue ! : string ; constructor ( options ) { options . continue = options . continue ?? 'same' ; options . rotate = options . rotate ?? 'none' ; super ( options ) ; validateRuntimeOptions ( options , { name : 'FullBleedPage' , selector : RuntimeTypes . string , continue : RuntimeTypes . enum ( 'next' , 'same' , 'left' , 'right' ) , rotate : RuntimeTypes . enum ( 'none' , 'inward' , 'outward' , 'clockwise' , 'counterclockwise' ) , } ) ; } createOutOfFlowPages ( elmt , book , makeNewPage ) { if ( elmt . parentNode ) { elmt . parentNode . removeChild ( elmt ) ; } let newPage ; if ( book . currentPage . isEmpty ) { newPage = book . currentPage ; } else { newPage = makeNewPage ( ) ; book . addPage ( newPage ) ; } if ( this . rotate !== 'none' ) { const rotateContainer = div ( `.rotate-container.page-size-rotated.rotate-${ this . rotate }` ) ; rotateContainer . appendChild ( newPage . background ) ; newPage . element . appendChild ( rotateContainer ) ; } newPage . background . appendChild ( elmt ) ; newPage . hasOutOfFlowContent = true ; } } export default FullBleedPage ;