fix(project-editor): route importBootstrap through updateBootstrap for undo+draft persistence

importBootstrap() replaced state.bootstrap directly, bypassing the same
updateBootstrap() pipeline every other edit goes through - so an import
never got a draftStorage.save() (lost on refresh before an explicit Save)
and never became an undo-able history step (Undo silently skipped over it).

Verified live via window.ng.getComponent(): exported the current bootstrap,
mutated branding.brandName, imported it back - draftStorage's localStorage
key changed and contained the new value; clicking Undo correctly reverted
brandName to the pre-import value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-07-17 18:45:53 +04:00
parent 2417a7795b
commit eee6695d7f

View File

@@ -292,10 +292,18 @@ export class ProjectEditorFacade {
return current ? this.ioService.exportBootstrap(current) : ''; return current ? this.ioService.exportBootstrap(current) : '';
} }
/**
* Replaces the whole draft with an imported bootstrap. Routed through
* updateBootstrap() (not a direct state.update) so an import gets the same
* undo-history entry and draftStorage persistence as any other edit -
* otherwise the import "worked" on screen but silently wasn't saved to the
* localStorage draft, and Undo couldn't step back through it.
*/
importBootstrap(raw: string): void { importBootstrap(raw: string): void {
try { try {
const imported = this.normalize(this.ioService.importBootstrap(raw)); const imported = this.normalize(this.ioService.importBootstrap(raw));
this.state.update(current => ({ ...current, bootstrap: imported, importError: null })); this.state.update(current => ({ ...current, importError: null }));
this.updateBootstrap(() => imported);
} catch { } catch {
this.state.update(current => ({ ...current, importError: 'builder.importError' })); this.state.update(current => ({ ...current, importError: 'builder.importError' }));
} }