bouncepaw / mycorrhiza

🍄📑 Filesystem and git-based wiki engine for the independent web written in Go and using Mycomarkup as its primary markup language.
https://mycorrhiza.wiki
GNU Affero General Public License v3.0
300 stars 26 forks source link

Hyphae editor fail-proofing (warnings/drafts/autosave) #77

Closed chekoopa closed 2 months ago

chekoopa commented 3 years ago

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:

handlerug commented 3 years ago

Seems pretty easy, I'll tackle that. Thanks for the suggestions!

handlerug commented 3 years ago

First suggestion implemented in 76d77f0. Tell me if it doesn't work.

DanInSpace104 commented 3 years ago

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

bouncepaw commented 3 years ago

@DanInSpace104 One may want to see how the hypha used to look like.

chekoopa commented 3 years ago

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

handlerug commented 3 years ago

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.

handlerug commented 3 years ago

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

Yep, they require Go 1.16 IIRC.

bouncepaw commented 3 years ago

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?

bouncepaw commented 3 years ago

25 also seems quite close to the issue

handlerug commented 3 years ago

25 is merely a blocker here for the actual drafts feature, not a duplicate issue or something.

chekoopa commented 3 years ago

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 commented 3 years ago

@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.

handlerug commented 3 years ago

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...)

bouncepaw commented 2 years ago

Half a year after, this modal window warning about unsaved changes has been causing nothing but irritation. I wonder how is for others

bouncepaw commented 2 months ago

Half a year after, this modal window warning about unsaved changes has been causing nothing but irritation. I wonder how is for others

Three years later, this feature saved me a couple hyphae, so I guess it's fine. I really like working with very old issues!

Regarding the other three features proposed:

Add draft feature for the editor

I'm not a fan. Maybe I'll be convinced later.

Allow saving without jumping back on the hypha page (unnecessary, but adds comfort)

Super cool! Let's have it. And it's easy to implement. Why didn't I understand before?

Add toggleable autosave

uhh dunno


I will open a separate issue for the jumpless saving and close this one, as I don't really want the rest.