@@ -193,18 +193,49 @@ export async function exportSlides({
193193 } )
194194 await page . waitForLoadState ( 'networkidle' )
195195 await page . emulateMedia ( { colorScheme : dark ? 'dark' : 'light' , media : 'screen' } )
196+ // Wait for slides to be loaded
197+ {
198+ const elements = page . locator ( '.slidev-slide-loading' )
199+ const count = await elements . count ( )
200+ for ( let index = 0 ; index < count ; index ++ )
201+ await elements . nth ( index ) . waitFor ( { state : 'detached' } )
202+ }
196203 // Check for "data-waitfor" attribute and wait for given element to be loaded
197- const elements = page . locator ( '[data-waitfor]' )
198- const count = await elements . count ( )
199- for ( let index = 0 ; index < count ; index ++ ) {
200- const element = elements . nth ( index )
201- const attribute = await element . getAttribute ( 'data-waitfor' )
202- if ( attribute )
203- await element . locator ( attribute ) . waitFor ( )
204+ {
205+ const elements = page . locator ( '[data-waitfor]' )
206+ const count = await elements . count ( )
207+ for ( let index = 0 ; index < count ; index ++ ) {
208+ const element = elements . nth ( index )
209+ const attribute = await element . getAttribute ( 'data-waitfor' )
210+ if ( attribute )
211+ await element . locator ( attribute ) . waitFor ( )
212+ }
204213 }
205214 // Wait for frames to load
206- const frames = page . frames ( )
207- await Promise . all ( frames . map ( frame => frame . waitForLoadState ( ) ) )
215+ {
216+ const frames = page . frames ( )
217+ await Promise . all ( frames . map ( frame => frame . waitForLoadState ( ) ) )
218+ }
219+ // Wait for Mermaid graphs to be rendered
220+ {
221+ const container = page . locator ( '#mermaid-rendering-container' )
222+ while ( true ) {
223+ const element = container . locator ( 'div' ) . first ( )
224+ if ( await element . count ( ) === 0 )
225+ break
226+ await element . waitFor ( { state : 'detached' } )
227+ }
228+ await container . evaluate ( node => node . style . display = 'none' )
229+ }
230+ // Hide Monaco aria container
231+ {
232+ const elements = page . locator ( '.monaco-aria-container' )
233+ const count = await elements . count ( )
234+ for ( let index = 0 ; index < count ; index ++ ) {
235+ const element = elements . nth ( index )
236+ await element . evaluate ( node => node . style . display = 'none' )
237+ }
238+ }
208239 }
209240
210241 async function getSlidesIndex ( ) {
0 commit comments