feat: add snippet deletion functionality and enhance UI for snippet management

This commit is contained in:
2025-01-19 14:23:55 +02:00
parent 86058767a1
commit fe9e554cec
4 changed files with 74 additions and 3 deletions

View File

@@ -149,4 +149,22 @@ export class SnippetManager {
this.readOnlyMode = hasChanges && !this.isDraftVersion;
this.editorManager.updateReadOnlyState(this.readOnlyMode);
}
deleteSnippet(id) {
if (confirm('Are you sure you want to delete this snippet?')) {
this.snippets = this.snippets.filter(s => s.id !== id);
this.storageManager.saveSnippets(this.snippets);
if (this.currentSnippetId === id) {
this.currentSnippetId = null;
if (this.snippets.length > 0) {
this.loadSnippet(this.snippets[0].id);
} else {
this.editorManager.setValue('');
}
}
this.uiManager.renderSnippetList(this.snippets, this.currentSnippetId);
}
}
}