@@ -67,6 +67,7 @@ define(function (require, exports, module) {
6767 const StaticServer = Phoenix . browser . isTauri ? NodeStaticServer : BrowserStaticServer ;
6868
6969 const EVENT_EMBEDDED_IFRAME_WHO_AM_I = 'whoAmIframePhoenix' ;
70+ const EVENT_EMBEDDED_IFRAME_FOCUS_EDITOR = 'embeddedIframeFocusEditor' ;
7071
7172 const PREVIEW_TRUSTED_PROJECT_KEY = "preview_trusted" ;
7273 const PREVIEW_PROJECT_README_KEY = "preview_readme" ;
@@ -98,27 +99,15 @@ define(function (require, exports, module) {
9899 } , "*" ) ; // this is not sensitive info, and is only dispatched if requested by the iframe
99100 }
100101 } ) ;
102+ StaticServer . on ( EVENT_EMBEDDED_IFRAME_FOCUS_EDITOR , function ( ) {
103+ const editor = EditorManager . getActiveEditor ( ) ;
104+ editor . focus ( ) ;
105+ } ) ;
101106
102107 function _isLiveHighlightEnabled ( ) {
103108 return CommandManager . get ( Commands . FILE_LIVE_HIGHLIGHT ) . getChecked ( ) ;
104109 }
105110
106- window . addEventListener ( 'blur' , function ( ) {
107- setTimeout ( function ( ) {
108- const editor = EditorManager . getActiveEditor ( ) ;
109- if ( ! _isLiveHighlightEnabled ( ) || ! editor ) {
110- return ;
111- }
112- if ( document . activeElement === document . getElementById ( LIVE_PREVIEW_IFRAME_ID )
113- && ! utils . isHTMLFile ( editor . document . file . fullPath ) ) {
114- // Editor focus is never lost to live preview if live highlights is enabled.
115- // For html files, they have special handling to set focus so that live preview can take inputs in
116- // text fields and text area for user to be able to type in live preview html text areas.
117- editor . focus ( ) ;
118- }
119- } , 100 ) ;
120- } ) ;
121-
122111 function _getTrustProjectPage ( ) {
123112 const trustProjectMessage = StringUtils . format ( Strings . TRUST_PROJECT ,
124113 path . basename ( ProjectManager . getProjectRoot ( ) . fullPath ) ) ;
0 commit comments