Summary
Writers can lose their entire story if they accidentally navigate away, close the tab, or refresh the /create page. For a writing platform, this is critical to prevent.
Implementation
Auto-save to localStorage:
- Save title, content, genre, language, and hasDeadline to localStorage on every keystroke (debounced ~1 second)
- Key:
plotlink_draft_create (or per-user key if wallet connected)
- On page load, restore from localStorage if a draft exists
- Show a small "Draft restored" indicator when content is recovered
Unsaved changes warning:
- Add
beforeunload event listener when content is non-empty
- Browser shows native "Leave site? Changes you made may not be saved" dialog
- Remove listener after successful publish
Clear draft after publish:
- Delete localStorage draft after storyline is successfully created
- Also clear when user explicitly clicks a "Discard draft" button
Same pattern for Chain Plot page:
- Auto-save draft plot content when writing a new chapter
- Key:
plotlink_draft_plot_{storylineId}
- Clear after successful plot submission
Acceptance Criteria
Summary
Writers can lose their entire story if they accidentally navigate away, close the tab, or refresh the /create page. For a writing platform, this is critical to prevent.
Implementation
Auto-save to localStorage:
plotlink_draft_create(or per-user key if wallet connected)Unsaved changes warning:
beforeunloadevent listener when content is non-emptyClear draft after publish:
Same pattern for Chain Plot page:
plotlink_draft_plot_{storylineId}Acceptance Criteria