feat(slides): add sandboxed Reveal.js viewer and editor preview
This commit is contained in:
1 parent
09afb438c9
commit
02fb77f72b
30 files changed
+532
-9
No files matched your search
+12
@@ -58,6 +58,18 @@ try {
|
||||
const layout=await evaluate(`fetch('/_/api/v1/extension/organizer.tasks/dashboard').then(r=>r.json())`);if(layout.widgets[0].id!=='today'||layout.widgets.find(w=>w.id==='tasks').height!==4)throw Error('Pointer layout persistence failed');
|
||||
await evaluate(`document.querySelector('#dashboard-controls button[aria-pressed]').click();scrollTo(0,0)`);
|
||||
}
|
||||
if (ready && process.env.PAGESWIKI_SLIDES_BROWSER === '1') {
|
||||
const evaluate = async expression => (await call('Runtime.evaluate', {expression, returnByValue:true})).result.value;
|
||||
const initialHistory = await evaluate('history.length');
|
||||
await evaluate("document.querySelector('.slides-frame').focus()");
|
||||
const key = async (key, code) => {await call('Input.dispatchKeyEvent',{type:'keyDown',key,code:key,windowsVirtualKeyCode:code});await call('Input.dispatchKeyEvent',{type:'keyUp',key,code:key,windowsVirtualKeyCode:code});};
|
||||
await key('ArrowRight',39);
|
||||
let advanced=false;for(let n=0;n<30;n++){if(await evaluate("document.querySelector('.slides-frame').parentElement.dataset.slideIndex") === '1'){advanced=true;break;}await delay(100);}
|
||||
if(!advanced)throw Error('Slide keyboard navigation failed');
|
||||
await key('ArrowLeft',37);await delay(150);
|
||||
if(await evaluate("document.querySelector('.slides-frame').parentElement.dataset.slideIndex") !== '0')throw Error('Slide previous navigation failed');
|
||||
if(await evaluate('history.length') !== initialHistory)throw Error('Slides polluted browser history');
|
||||
}
|
||||
if (screenshot) {
|
||||
const {data} = await call('Page.captureScreenshot', {format: 'png'});
|
||||
await writeFile(screenshot, Buffer.from(data, 'base64'));
|
||||
|
||||
Reference in new issue
Block a user