File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,18 @@ export class Editor {
5959 const yamlContent = await response . text ( ) ;
6060 this . ace . setValue ( yamlContent , - 1 ) ; // -1 moves cursor to the start
6161 console . log ( `Loaded content from: ${ loadUrl } ` ) ;
62- // Optionally clear localStorage if loaded from URL to avoid conflict?
63- // localStorage.removeItem(this.STORAGE_KEY);
62+
63+ // Remove the 'load' parameter from the URL without reloading
64+ const currentUrlParams = new URLSearchParams ( window . location . search ) ;
65+ currentUrlParams . delete ( 'load' ) ;
66+ const newRelativePathQuery = window . location . pathname + ( currentUrlParams . toString ( ) ? '?' + currentUrlParams . toString ( ) : '' ) ;
67+ window . history . replaceState ( { path : newRelativePathQuery } , '' , newRelativePathQuery ) ;
6468 } catch ( error ) {
6569 console . error ( 'Failed to load content from URL:' , loadUrl , error ) ;
70+ // Display error to the user in the output div and editor
71+ const errorMessage = `# Failed to load content from: ${ loadUrl } \n# Error: ${ error . message } ` ;
72+ this . output . innerHTML = `<div class="error">Failed to load content from <a href="${ loadUrl } " target="_blank">${ loadUrl } </a>: ${ error . message } </div>` ;
73+ this . ace . setValue ( errorMessage , - 1 ) ;
6674 }
6775 } else {
6876 // Load initial content from localStorage if no loadUrl
You can’t perform that action at this time.
0 commit comments