feat: url state management

This commit is contained in:
2025-10-15 17:47:21 +03:00
parent 173d8eb2b8
commit 5776f7e910
6 changed files with 228 additions and 18 deletions

View File

@@ -460,7 +460,7 @@ function attachSnippetEventListeners() {
}
// Select and load a snippet into the editor
function selectSnippet(snippetId) {
function selectSnippet(snippetId, updateURL = true) {
const snippet = SnippetStorage.getSnippet(snippetId);
if (!snippet) return;
@@ -500,6 +500,11 @@ function selectSnippet(snippetId) {
// Store currently selected snippet ID globally
window.currentSnippetId = snippetId;
// Update URL state (URLState.update will add 'snippet-' prefix)
if (updateURL) {
URLState.update({ view: 'snippets', snippetId: snippetId, datasetId: null });
}
}
// Auto-save functionality