11import "./drop-runtime.css" ;
2+ import keycode from 'keycode' ;
23import { startWebRApp , startPyodideApp } from './App' ;
34
45declare global {
56 interface Window {
67 Reveal : any ;
7- RevealDrop ?: any ;
8+ RevealDrop ?: {
9+ id : string ;
10+ dropElement : HTMLDivElement ;
11+ init : ( reveal : any ) => void ;
12+ toggleDrop : ( ) => void ;
13+ isActive : ( ) => boolean ;
14+ } ;
815 }
916}
1017
@@ -27,11 +34,9 @@ type DropConfig = {
2734window . RevealDrop = window . RevealDrop || {
2835 id : 'RevealDrop' ,
2936 dropElement : document . createElement ( 'div' ) ,
30- config : { } ,
31- init : function ( ) {
32- // Configuration
33- const config = window . Reveal . getConfig ( ) . drop as DropConfig ;
34- window . RevealDrop . config = config ;
37+ init : function ( reveal ) {
38+ const revealConfig = reveal . getConfig ( ) ;
39+ const config = revealConfig . drop as DropConfig ;
3540
3641 // Add Drop down panel to DOM
3742 const drop = window . RevealDrop . dropElement ;
@@ -67,15 +72,28 @@ window.RevealDrop = window.RevealDrop || {
6772 }
6873
6974 // Keyboard listeners
75+ reveal . addKeyBinding ( {
76+ keyCode : keycode ( config . shortcut ) ,
77+ key : config . shortcut ,
78+ description : 'Toggle console'
79+ } , ( ) => { } ) ;
80+
7081 document . addEventListener ( "keydown" , ( event ) => {
7182 if ( event . key == config . shortcut && ! event . altKey ) {
7283 window . RevealDrop . toggleDrop ( ) ;
84+ reveal . toggleHelp ( false ) ;
85+ reveal . toggleOverview ( false ) ;
86+ reveal . configure ( { keyboard : ! window . RevealDrop . isActive ( ) } ) ;
7387 event . preventDefault ( ) ;
7488 event . stopPropagation ( ) ;
7589 }
7690 } , { capture : true } ) ;
91+
7792 } ,
7893 toggleDrop ( ) {
7994 window . RevealDrop . dropElement . classList . toggle ( "active" ) ;
95+ } ,
96+ isActive ( ) {
97+ return window . RevealDrop . dropElement . classList . contains ( "active" ) ;
8098 }
8199} ;
0 commit comments