|
414 | 414 | } |
415 | 415 | // Messages sent by the reveal.js inside of the current slide preview |
416 | 416 | else if( data && data.namespace === 'reveal' ) { |
| 417 | + const supportedEvents = [ |
| 418 | + 'slidechanged', |
| 419 | + 'fragmentshown', |
| 420 | + 'fragmenthidden', |
| 421 | + 'paused', |
| 422 | + 'resumed', |
| 423 | + 'previewiframe', |
| 424 | + 'previewimage', |
| 425 | + 'previewvideo', |
| 426 | + 'closeoverlay' |
| 427 | + ]; |
| 428 | +
|
417 | 429 | if( /ready/.test( data.eventName ) ) { |
418 | 430 | // Send a message back to notify that the handshake is complete |
419 | 431 | window.opener.postMessage( JSON.stringify({ namespace: 'reveal-notes', type: 'connected'} ), '*' ); |
420 | 432 | } |
421 | | - else if( /slidechanged|fragmentshown|fragmenthidden|paused|resumed/.test( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { |
422 | | -
|
| 433 | + else if( supportedEvents.includes( data.eventName ) && currentState !== JSON.stringify( data.state ) ) { |
423 | 434 | dispatchStateToMainWindow( data.state ); |
424 | | -
|
425 | 435 | } |
426 | 436 | } |
427 | 437 |
|
|
494 | 504 | notes.classList.add( 'hidden' ); |
495 | 505 | } |
496 | 506 |
|
| 507 | + // Don't show lightboxes in the upcoming slide |
| 508 | + const { previewVideo, previewImage, previewIframe, ...upcomingState } = data.state; |
| 509 | +
|
497 | 510 | // Update the note slides |
498 | 511 | currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' ); |
499 | | - upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ data.state ] }), '*' ); |
| 512 | + upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'setState', args: [ upcomingState ] }), '*' ); |
500 | 513 | upcomingSlide.contentWindow.postMessage( JSON.stringify({ method: 'next' }), '*' ); |
501 | 514 |
|
502 | 515 | } |
@@ -941,4 +954,4 @@ ${n}</tr> |
941 | 954 | `}strong(n){return`<strong>${n}</strong>`}em(n){return`<em>${n}</em>`}codespan(n){return`<code>${n}</code>`}br(){return this.options.xhtml?"<br/>":"<br>"}del(n){return`<del>${n}</del>`}link(n,e,t){if(n=j(this.options.sanitize,this.options.baseUrl,n),n===null)return t;let i='<a href="'+n+'"';return e&&(i+=' title="'+e+'"'),i+=">"+t+"</a>",i}image(n,e,t){if(n=j(this.options.sanitize,this.options.baseUrl,n),n===null)return t;let i=`<img src="${n}" alt="${t}"`;return e&&(i+=` title="${e}"`),i+=this.options.xhtml?"/>":">",i}text(n){return n}}class V{strong(n){return n}em(n){return n}codespan(n){return n}del(n){return n}html(n){return n}text(n){return n}link(n,e,t){return""+t}image(n,e,t){return""+t}br(){return""}}class F{constructor(){this.seen={}}serialize(n){return n.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(n,e){let t=n,i=0;if(this.seen.hasOwnProperty(t)){i=this.seen[n];do i++,t=n+"-"+i;while(this.seen.hasOwnProperty(t))}return e||(this.seen[n]=i,this.seen[t]=0),t}slug(n,e={}){const t=this.serialize(n);return this.getNextSafeSlug(t,e.dryrun)}}class L{constructor(n){this.options=n||_,this.options.renderer=this.options.renderer||new D,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new V,this.slugger=new F}static parse(n,e){return new L(e).parse(n)}static parseInline(n,e){return new L(e).parseInline(n)}parse(n,e=!0){let t="",i,s,a,r,u,m,f,d,p,o,x,b,S,w,y,I,A,$,E;const C=n.length;for(i=0;i<C;i++){if(o=n[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[o.type]&&(E=this.options.extensions.renderers[o.type].call({parser:this},o),E!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type))){t+=E||"";continue}switch(o.type){case"space":continue;case"hr":{t+=this.renderer.hr();continue}case"heading":{t+=this.renderer.heading(this.parseInline(o.tokens),o.depth,H(this.parseInline(o.tokens,this.textRenderer)),this.slugger);continue}case"code":{t+=this.renderer.code(o.text,o.lang,o.escaped);continue}case"table":{for(d="",f="",r=o.header.length,s=0;s<r;s++)f+=this.renderer.tablecell(this.parseInline(o.header[s].tokens),{header:!0,align:o.align[s]});for(d+=this.renderer.tablerow(f),p="",r=o.rows.length,s=0;s<r;s++){for(m=o.rows[s],f="",u=m.length,a=0;a<u;a++)f+=this.renderer.tablecell(this.parseInline(m[a].tokens),{header:!1,align:o.align[a]});p+=this.renderer.tablerow(f)}t+=this.renderer.table(d,p);continue}case"blockquote":{p=this.parse(o.tokens),t+=this.renderer.blockquote(p);continue}case"list":{for(x=o.ordered,b=o.start,S=o.loose,r=o.items.length,p="",s=0;s<r;s++)y=o.items[s],I=y.checked,A=y.task,w="",y.task&&($=this.renderer.checkbox(I),S?y.tokens.length>0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=$+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=$+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:$}):w+=$),w+=this.parse(y.tokens,S),p+=this.renderer.listitem(w,A,I);t+=this.renderer.list(p,x,b);continue}case"html":{t+=this.renderer.html(o.text);continue}case"paragraph":{t+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{for(p=o.tokens?this.parseInline(o.tokens):o.text;i+1<C&&n[i+1].type==="text";)o=n[++i],p+=` |
942 | 955 | `+(o.tokens?this.parseInline(o.tokens):o.text);t+=e?this.renderer.paragraph(p):p;continue}default:{const X='Token with "'+o.type+'" type was not found.';if(this.options.silent){console.error(X);return}else throw new Error(X)}}}return t}parseInline(n,e){e=e||this.renderer;let t="",i,s,a;const r=n.length;for(i=0;i<r;i++){if(s=n[i],this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]&&(a=this.options.extensions.renderers[s.type].call({parser:this},s),a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type))){t+=a||"";continue}switch(s.type){case"escape":{t+=e.text(s.text);break}case"html":{t+=e.html(s.text);break}case"link":{t+=e.link(s.href,s.title,this.parseInline(s.tokens,e));break}case"image":{t+=e.image(s.href,s.title,s.text);break}case"strong":{t+=e.strong(this.parseInline(s.tokens,e));break}case"em":{t+=e.em(this.parseInline(s.tokens,e));break}case"codespan":{t+=e.codespan(s.text);break}case"br":{t+=e.br();break}case"del":{t+=e.del(this.parseInline(s.tokens,e));break}case"text":{t+=e.text(s.text);break}default:{const u='Token with "'+s.type+'" type was not found.';if(this.options.silent){console.error(u);return}else throw new Error(u)}}}return t}}class q{constructor(n){this.options=n||_}preprocess(n){return n}postprocess(n){return n}}G(q,"passThroughHooks",new Set(["preprocess","postprocess"]));function mt(l,n,e){return t=>{if(t.message+=` |
943 | 956 | Please report this to https://github.com/markedjs/marked.`,l){const i="<p>An error occurred:</p><pre>"+v(t.message+"",!0)+"</pre>";if(n)return Promise.resolve(i);if(e){e(null,i);return}return i}if(n)return Promise.reject(t);if(e){e(t);return}throw t}}function Y(l,n){return(e,t,i)=>{typeof t=="function"&&(i=t,t=null);const s={...t};t={...g.defaults,...s};const a=mt(t.silent,t.async,i);if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(ht(t),t.hooks&&(t.hooks.options=t),i){const r=t.highlight;let u;try{t.hooks&&(e=t.hooks.preprocess(e)),u=l(e,t)}catch(d){return a(d)}const m=function(d){let p;if(!d)try{t.walkTokens&&g.walkTokens(u,t.walkTokens),p=n(u,t),t.hooks&&(p=t.hooks.postprocess(p))}catch(o){d=o}return t.highlight=r,d?a(d):i(null,p)};if(!r||r.length<3||(delete t.highlight,!u.length))return m();let f=0;g.walkTokens(u,function(d){d.type==="code"&&(f++,setTimeout(()=>{r(d.text,d.lang,function(p,o){if(p)return m(p);o!=null&&o!==d.text&&(d.text=o,d.escaped=!0),f--,f===0&&m()})},0))}),f===0&&m();return}if(t.async)return Promise.resolve(t.hooks?t.hooks.preprocess(e):e).then(r=>l(r,t)).then(r=>t.walkTokens?Promise.all(g.walkTokens(r,t.walkTokens)).then(()=>r):r).then(r=>n(r,t)).then(r=>t.hooks?t.hooks.postprocess(r):r).catch(a);try{t.hooks&&(e=t.hooks.preprocess(e));const r=l(e,t);t.walkTokens&&g.walkTokens(r,t.walkTokens);let u=n(r,t);return t.hooks&&(u=t.hooks.postprocess(u)),u}catch(r){return a(r)}}}function g(l,n,e){return Y(R.lex,L.parse)(l,n,e)}return g.options=g.setOptions=function(l){return g.defaults={...g.defaults,...l},tt(g.defaults),g},g.getDefaults=T,g.defaults=_,g.use=function(...l){const n=g.defaults.extensions||{renderers:{},childTokens:{}};l.forEach(e=>{const t={...e};if(t.async=g.defaults.async||t.async||!1,e.extensions&&(e.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=n.renderers[i.name];s?n.renderers[i.name]=function(...a){let r=i.renderer.apply(this,a);return r===!1&&(r=s.apply(this,a)),r}:n.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");n[i.level]?n[i.level].unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),t.extensions=n),e.renderer){const i=g.defaults.renderer||new D;for(const s in e.renderer){const a=i[s];i[s]=(...r)=>{let u=e.renderer[s].apply(i,r);return u===!1&&(u=a.apply(i,r)),u}}t.renderer=i}if(e.tokenizer){const i=g.defaults.tokenizer||new O;for(const s in e.tokenizer){const a=i[s];i[s]=(...r)=>{let u=e.tokenizer[s].apply(i,r);return u===!1&&(u=a.apply(i,r)),u}}t.tokenizer=i}if(e.hooks){const i=g.defaults.hooks||new q;for(const s in e.hooks){const a=i[s];q.passThroughHooks.has(s)?i[s]=r=>{if(g.defaults.async)return Promise.resolve(e.hooks[s].call(i,r)).then(m=>a.call(i,m));const u=e.hooks[s].call(i,r);return a.call(i,u)}:i[s]=(...r)=>{let u=e.hooks[s].apply(i,r);return u===!1&&(u=a.apply(i,r)),u}}t.hooks=i}if(e.walkTokens){const i=g.defaults.walkTokens;t.walkTokens=function(s){let a=[];return a.push(e.walkTokens.call(this,s)),i&&(a=a.concat(i.call(this,s))),a}}g.setOptions(t)})},g.walkTokens=function(l,n){let e=[];for(const t of l)switch(e=e.concat(n.call(g,t)),t.type){case"table":{for(const i of t.header)e=e.concat(g.walkTokens(i.tokens,n));for(const i of t.rows)for(const s of i)e=e.concat(g.walkTokens(s.tokens,n));break}case"list":{e=e.concat(g.walkTokens(t.items,n));break}default:g.defaults.extensions&&g.defaults.extensions.childTokens&&g.defaults.extensions.childTokens[t.type]?g.defaults.extensions.childTokens[t.type].forEach(function(i){e=e.concat(g.walkTokens(t[i],n))}):t.tokens&&(e=e.concat(g.walkTokens(t.tokens,n)))}return e},g.parseInline=Y(R.lexInline,L.parseInline),g.Parser=L,g.parser=L.parse,g.Renderer=D,g.TextRenderer=V,g.Lexer=R,g.lexer=R.lex,g.Tokenizer=O,g.Slugger=F,g.Hooks=q,g.parse=g,g.options,g.setOptions,g.use,g.walkTokens,g.parseInline,L.parse,R.lex,()=>{let l,n=null,e;function t(){if(n&&!n.closed)n.focus();else{if(n=window.open("about:blank","reveal.js - Notes","width=1100,height=700"),n.marked=g,n.document.write(z),!n){alert("Speaker view popup failed to open. Please make sure popups are allowed and reopen the speaker view.");return}s()}}function i(d){n&&!n.closed?n.focus():(n=d,window.addEventListener("message",m),f())}function s(){const d=e.getConfig().url,p=typeof d=="string"?d:window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search;l=setInterval(function(){n.postMessage(JSON.stringify({namespace:"reveal-notes",type:"connect",state:e.getState(),url:p}),"*")},500),window.addEventListener("message",m)}function a(d,p,o){let x=e[d].apply(e,p);n.postMessage(JSON.stringify({namespace:"reveal-notes",type:"return",result:x,callId:o}),"*")}function r(d){let p=e.getCurrentSlide(),o=p.querySelectorAll("aside.notes"),x=p.querySelector(".current-fragment"),b={namespace:"reveal-notes",type:"state",notes:"",markdown:!1,whitespace:"normal",state:e.getState()};if(p.hasAttribute("data-notes")&&(b.notes=p.getAttribute("data-notes"),b.whitespace="pre-wrap"),x){let S=x.querySelector("aside.notes");S?(b.notes=S.innerHTML,b.markdown=typeof S.getAttribute("data-markdown")=="string",o=null):x.hasAttribute("data-notes")&&(b.notes=x.getAttribute("data-notes"),b.whitespace="pre-wrap",o=null)}o&&o.length&&(o=Array.from(o).filter(S=>S.closest(".fragment")===null),b.notes=o.map(S=>S.innerHTML).join(` |
944 | | -`),b.markdown=o[0]&&typeof o[0].getAttribute("data-markdown")=="string"),n.postMessage(JSON.stringify(b),"*")}function u(d){try{return window.location.origin===d.source.location.origin}catch{return!1}}function m(d){if(u(d))try{let p=JSON.parse(d.data);p&&p.namespace==="reveal-notes"&&p.type==="connected"?(clearInterval(l),f()):p&&p.namespace==="reveal-notes"&&p.type==="call"&&a(p.methodName,p.arguments,p.callId)}catch{}}function f(){e.on("slidechanged",r),e.on("fragmentshown",r),e.on("fragmenthidden",r),e.on("overviewhidden",r),e.on("overviewshown",r),e.on("paused",r),e.on("resumed",r),r()}return{id:"notes",init:function(d){e=d,/receiver/i.test(window.location.search)||(window.location.search.match(/(\?|\&)notes/gi)!==null?t():window.addEventListener("message",p=>{if(!n&&typeof p.data=="string"){let o;try{o=JSON.parse(p.data)}catch{}o&&o.namespace==="reveal-notes"&&o.type==="heartbeat"&&i(p.source)}}),e.addKeyBinding({keyCode:83,key:"S",description:"Speaker notes view"},function(){t()}))},open:t}}}); |
| 957 | +`),b.markdown=o[0]&&typeof o[0].getAttribute("data-markdown")=="string"),n.postMessage(JSON.stringify(b),"*")}function u(d){try{return window.location.origin===d.source.location.origin}catch{return!1}}function m(d){if(u(d))try{let p=JSON.parse(d.data);p&&p.namespace==="reveal-notes"&&p.type==="connected"?(clearInterval(l),f()):p&&p.namespace==="reveal-notes"&&p.type==="call"&&a(p.methodName,p.arguments,p.callId)}catch{}}function f(){e.on("slidechanged",r),e.on("fragmentshown",r),e.on("fragmenthidden",r),e.on("overviewhidden",r),e.on("overviewshown",r),e.on("paused",r),e.on("resumed",r),e.on("previewiframe",r),e.on("previewimage",r),e.on("previewvideo",r),e.on("closeoverlay",r),r()}return{id:"notes",init:function(d){e=d,/receiver/i.test(window.location.search)||(window.location.search.match(/(\?|\&)notes/gi)!==null?t():window.addEventListener("message",p=>{if(!n&&typeof p.data=="string"){let o;try{o=JSON.parse(p.data)}catch{}o&&o.namespace==="reveal-notes"&&o.type==="heartbeat"&&i(p.source)}}),e.addKeyBinding({keyCode:83,key:"S",description:"Speaker notes view"},function(){t()}))},open:t}}}); |
0 commit comments