mycorrhiza
mycorrhiza copied to clipboard
Hyphae editor fail-proofing (warnings/drafts/autosave)
Sometimes I need to write a long hypha, but saving it in the middle and jumping back and forth between the editon and the hypha is tedious sometimes. Also, the editor doesn't warn about unsaved changes, which is a big problem itself.
So, the possible improvements here are:
- [x] Add 'unsaved changes' warning (purely frontend, first priority)
- [ ] Add draft feature for the editor
- purely frontend: local storage usage, which keeps drafted hypha text and invalidates it if the original is different than on editing started. Simple, yet not very reliable and not cross-device.
- backend-based: drafts are stored in user-named Git branches and commited on save. Conflict resolving is optional, diff display is enough for starters. But it seems harsh on disk writes and network (considering Dropbox Paper or Notion-like UX).
- [ ] Allow saving without jumping back on the hypha page (unnecessary, but adds comfort), which unlocks...
- [ ] Add toggleable autosave
Seems pretty easy, I'll tackle that. Thanks for the suggestions!
First suggestion implemented in 76d77f0. Tell me if it doesn't work.
saving it in the middle and jumping back and forth between the editon and the hypha is tedious sometimes.
@chekoopa Why would you need that jumping? if you want to check how hypha will be rendered, you can use Preview button
@DanInSpace104 One may want to see how the hypha used to look like.
First suggestion implemented in [76d77f0]
I'm trying to build it on Nix, but have little problems with embed
and io/fs
libs. Seems that I need to upgrade my Go compiler. brb
saving it in the middle and jumping back and forth between the editon and the hypha is tedious sometimes.
@chekoopa Why would you need that jumping? if you want to check how hypha will be rendered, you can use Preview button
@DanInSpace104 One may want to see how the hypha used to look like.
I think you all missed the point, the idea is to save periodically to prevent losing changes. You would need to click Save, then click Edit... then click Save, Edit... and so on.
First suggestion implemented in [76d77f0]
I'm trying to build it on Nix, but have little problems with
embed
andio/fs
libs. Seems that I need to upgrade my Go compiler. brb
Yep, they require Go 1.16 IIRC.
Add 'unsaved changes' warning (purely frontend, first priority)
Yeah, we need that. Thanks @handlerug for implementing.
Add draft feature for the editor
@chekoopa's git-branch-driven way is not how it should be done, let's not abuse Git, it is already used much more than it should be. We can store drafts in cache/drafts/
directory or something like that instead. It will be easier to do and more reliable.
As of the front-end way, it seems ok. Sure, it is limited to just one device, but who cares[?] But wait, this behaviour is built in browsers already, right?
Allow saving without jumping back on the hypha page (unnecessary, but adds comfort), which unlocks...
Why? What comfort will it bring?
Add toggleable autosave
Why? It makes sense to auto-save drafts, but why auto-save edits?
#25 also seems quite close to the issue
#25 is merely a blocker here for the actual drafts feature, not a duplicate issue or something.
UPD: already done in 9ad9db9, I've missed that commit
First suggestion implemented in [76d77f0]
Looks neat, but it also pops up when you press 'Save'. The fix is simple:
let saveButton = document.querySelector('.edit-form__save');
saveButton.addEventListener('click', function () {
changed = false;
});
let warnBeforeClosing = function (ev) {
if (changed) {
ev.preventDefault();
return ev.returnValue = 'Are you sure you want to exit? You have unsaved changes.';
}
};
@chekoopa's git-branch-driven way is not how it should be done, let's not abuse Git, it is already used much more than it should be. We can store drafts in
cache/drafts/
directory or something like that instead. It will be easier to do and more reliable.
Tee-hee. Yes, that's actually better, that was just the first idea came into my mind.
As of the front-end way, it seems ok. Sure, it is limited to just one device, but who cares[?] But wait, this behaviour is built in browsers already, right?
Checked that, really it is, but it's very implicit IMO. It also ignores external text changes (as you get your 'draft' based on the older version), and also bypasses the new unsaved changes
check (but who cares[?]).
Allow saving without jumping back on the hypha page (unnecessary, but adds comfort), which unlocks...
Why? What comfort will it bring?
Comfort of staying on a single page, keeping pace and flow.
It seems to go against minimalistic form-based organization and add a dependency to perform AJAX requests. However, it can be kept as a script-supported feature by adding the button only in scripted browsers.
Add toggleable autosave
Why? It makes sense to auto-save drafts, but why auto-save edits?
My task list was a first-approach, so your point is fair. I've mentioned this feature to make Myco as comfortable for note-taking as Notion, for example. It would add dynamics and make the editing easier. But with server-based drafts it's better to autosave them, for sure.
I personally don't trust browsers to retain my edits when I navigate away. Browsers also have full control over local storage of the website, and they're free to clear it whenever they feel like so. A server-side auto-saving of drafts would be much more reliable.
As for the two last suggestions, feel free to discuss them. We have a lot to do before we catch up to Notion, though, so it's not like it's going to help us. (also, you could auto-save edits (not drafts) using custom javascripts...)
Half a year after, this modal window warning about unsaved changes has been causing nothing but irritation. I wonder how is for others