@@ -140,22 +140,23 @@ export default class PIOHome {
140140 const iframeId =
141141 'pioHomeIFrame-' +
142142 crypto . createHash ( 'sha1' ) . update ( crypto . randomBytes ( 512 ) ) . digest ( 'hex' ) ;
143+ const iframeScript = `
144+ <script>
145+ for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
146+ document.addEventListener(command, (e) => {
147+ document.getElementById('${ iframeId } ').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
148+ });
149+ }
150+ window.addEventListener('message', (e) => {
151+ if (e.data.command === 'kbd-event') {
152+ window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
153+ }
154+ });
155+ </script>
156+ ` ;
143157 return `<!DOCTYPE html>
144158 <html lang="en">
145- <head>
146- <script>
147- for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
148- document.addEventListener(command, (e) => {
149- document.getElementById('${ iframeId } ').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
150- });
151- }
152- window.addEventListener('message', (e) => {
153- if (e.data.command === 'kbd-event' && ${ IS_OSX } ) {
154- window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
155- }
156- });
157- </script>
158- </head>
159+ <head>${ IS_OSX ? iframeScript : '' } </head>
159160 <body style="margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: ${
160161 theme === 'light' ? '#FFF' : '#1E1E1E'
161162 } ">
0 commit comments