@@ -99,54 +99,24 @@ const mapDispatchToProps = dispatch => ({
9999 onSetStageSmall : ( ) => dispatch ( setStageSize ( STAGE_SIZE_MODES . small ) ) ,
100100 onSetStageFull : ( ) => dispatch ( setStageSize ( STAGE_SIZE_MODES . full ) ) ,
101101 onSetStageFullScreen : ( ) => {
102- if ( window . location . pathname === "/" || window . location . pathname . includes ( "/index.html" ) || window . location . pathname === "/build/" ) {
103- if ( document . documentElement . requestFullscreen ) {
104- document . documentElement . requestFullscreen ( ) . then ( ( ) => {
105- dispatch ( setFullScreen ( true ) ) ;
106- } ) . catch ( err => {
107- console . error ( 'Failed to enter fullscreen:' , err ) ;
108- } ) ;
109- } else if ( document . documentElement . webkitRequestFullscreen ) { // Safari
110- document . documentElement . webkitRequestFullscreen ( ) ;
111- dispatch ( setFullScreen ( true ) ) ;
112- } else if ( document . documentElement . mozRequestFullScreen ) { // Firefox
113- document . documentElement . mozRequestFullScreen ( ) ;
114- dispatch ( setFullScreen ( true ) ) ;
115- } else if ( document . documentElement . msRequestFullscreen ) { // IE/Edge
116- document . documentElement . msRequestFullscreen ( ) ;
117- dispatch ( setFullScreen ( true ) ) ;
118- } else {
119- console . warn ( 'Fullscreen API is not supported in this browser.' ) ;
120- }
102+ if ( window . location . pathname === '/' ||
103+ window . location . pathname . includes ( '/index.html' ) ||
104+ window . location . pathname === '/build/' ) {
105+ window . parent . postMessage ( {
106+ type : 'block-compiler-action' ,
107+ action : 'REQUEST_FULLSCREEN'
108+ } , '*' ) ;
109+ dispatch ( setFullScreen ( true ) ) ;
121110 } else {
122111 dispatch ( setFullScreen ( true ) ) ;
123112 }
124113 } ,
125114 onSetStageUnFullScreen : ( ) => {
126- // Check if the document is currently in fullscreen
127- if ( document . fullscreenElement || document . webkitFullscreenElement || document . mozFullScreenElement || document . msFullscreenElement ) {
128- if ( document . exitFullscreen ) {
129- document . exitFullscreen ( ) . then ( ( ) => {
130- dispatch ( setFullScreen ( false ) ) ;
131- } ) . catch ( err => {
132- console . error ( 'Failed to exit fullscreen:' , err ) ;
133- } ) ;
134- } else if ( document . webkitExitFullscreen ) { // Safari
135- document . webkitExitFullscreen ( ) ;
136- dispatch ( setFullScreen ( false ) ) ;
137- } else if ( document . mozCancelFullScreen ) { // Firefox
138- document . mozCancelFullScreen ( ) ;
139- dispatch ( setFullScreen ( false ) ) ;
140- } else if ( document . msExitFullscreen ) { // IE/Edge
141- document . msExitFullscreen ( ) ;
142- dispatch ( setFullScreen ( false ) ) ;
143- } else {
144- console . warn ( 'Fullscreen API is not supported in this browser.' ) ;
145- }
146- } else {
147- // Not in fullscreen, just dispatch the action
148- dispatch ( setFullScreen ( false ) ) ;
149- }
115+ window . parent . postMessage ( {
116+ type : 'block-compiler-action' ,
117+ action : 'CANCEL_FULLSCREEN'
118+ } , '*' ) ;
119+ dispatch ( setFullScreen ( false ) ) ;
150120 } ,
151121 onOpenSettings : ( ) => dispatch ( openSettingsModal ( ) )
152122} ) ;
0 commit comments