When a user is editing a page, but Liquipedia goes down, or their Internet goes down, or some similar issue, the edit is lost on submission. This can be problematic if the edit was very large.
I think the simplest solution would be to store the contents of the last edit in localStorage on submission, and then have a button on the toolbar that can restore the last edit.
I've been testing a Greasemonkey script that does this on the client side, but this only works for Firefox (and maybe Manifest v2-compatible Chromium, like Brave + Violentmonkey?) due to Manifest v3 changes. However, I think there's no reason why this can't be done with hooks within our CodeMirror extension. My script is also inferior because I can't easily get the contents of the textarea outside of the CodeMirror scope, and I couldn't figure out how to set the contents of the textarea (so it loads to the clipboard).
Conceptually, this is just:
- On submit, save edit to localStorage
- Add button to toolbar to restore from localStorage
- Test this by disconnecting your Internet (i.e. edit a page, disconnect, submit, reconnect, verify contents can be restored)
One thing my script doesn't do is handle multiple wikis (e.g. it's just one localStorage key across all of Liquipedia). Maybe there should be one key per wiki?