@@ -180,17 +180,7 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
180180 this . _npmStatus = this . _getDomElement ( 'npmStatus' ) ;
181181 this . _getNpm = this . _getDomElement ( 'getNpm' ) ;
182182 let loadAllImports = window . location . search . includes ( "loadAllImports" ) ;
183- this . _npmInput . onkeydown = async ( e ) => {
184- if ( e . key == 'Enter' ) {
185- let res = await this . _npmPackageLoader . loadNpmPackage ( this . _npmInput . value , serviceContainer , this . _paletteTree , loadAllImports , state => this . _npmStatus . innerText = state ) ;
186- if ( res . html ) {
187- let element = this . _dock . getElementInSlot ( this . _dockManager . activeDocument . elementContent ) ;
188- element . content = res . html + element . content ;
189- }
190- this . _npmInput . value = '' ;
191- }
192- } ;
193- this . _getNpm . onclick = async ( e ) => {
183+ const loadPkg = async ( e ) => {
194184 const pkgName = this . _npmInput . value ;
195185 if ( pkgName . startsWith ( 'http://' ) || pkgName . startsWith ( 'https://' ) ) {
196186 const observedCustomElementsRegistry = new ObservedCustomElementsRegistry ( ) ;
@@ -199,7 +189,12 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
199189 }
200190 catch ( error ) {
201191 console . error ( "Error loading url with import, trying with script tag." , error ) ;
202- await LazyLoader . LoadJavascript ( pkgName ) ;
192+ try {
193+ await LazyLoader . LoadJavascript ( pkgName ) ;
194+ }
195+ catch ( error ) {
196+ console . error ( "Error loading url with script tag." , error ) ;
197+ }
203198 }
204199 await sleep ( 500 ) ;
205200 const newElements = observedCustomElementsRegistry . getNewElements ( ) ;
@@ -222,6 +217,8 @@ export class AppShell extends BaseCustomWebComponentConstructorAppend {
222217 }
223218 this . _npmInput . value = '' ;
224219 } ;
220+ this . _npmInput . onkeydown = loadPkg ;
221+ this . _getNpm . onclick = loadPkg ;
225222 let code = "" ;
226223 let style = "" ;
227224 let s = window . location . search ;
0 commit comments