Autosave edits and new pages as local drafts - #9
Merged
Merged
Conversation
The content of the edit form (text, title, commit message) is stored in localStorage on every change and when the page gets hidden, and restored when the edit/new page is loaded again. This prevents losing edits when a (mobile) browser unloads an inactive tab. A note with a "Discard draft" button is shown on restore, including a warning if the page was changed in the meantime. Drafts are removed on save and cancel. wiki.js and the formatting helper are now also loaded for new pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R83ERf8xo5QNNs6vp9v7at
Conflicts: index.php (use isEditorAction(), keep main's form action and CSRF field, add the draft data attributes) and wiki.js (keep the draft handling, which also covers title input and clears the draft on submit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R83ERf8xo5QNNs6vp9v7at
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R83ERf8xo5QNNs6vp9v7at
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Mobile browsers unload tabs that are left inactive, and any text in the edit field that hadn't been saved was lost. With this change, the edit form's content is kept as a draft in the browser's
localStorageand restored when the page is opened again.visibilitychange/pagehide).wiki.jsand the Markdown formatting helper are now also loaded for new pages. Before, only edit pages loaded them, so new pages also get the "unsaved changes" warning when leaving.deandenlocale files.Testing
Checked in headless Chromium against
php -S:🤖 Generated with Claude Code
https://claude.ai/code/session_01R83ERf8xo5QNNs6vp9v7at
Generated by Claude Code