# Save/autosave feature for the editor available

+ 6 like - 0 dislike
201 views

As a new feature, our editor supports now saving/autosaving of drafts. This feature is only available for logged-in users. There are three occasions, where your text in the editor gets saved:

1. Automatically, whenever you stop writing, 5 seconds after the last key stroke.
2. [EDITED] When you leave the editor and load for instance another page or switch to another post (for instance when you start to write an answer and decide then first to write a comment), you have to push the "Save draft" button on the bottom right of the editor.. If you leave the page, you still get alerted as already known before.
3. Manually, when you push the "Save draft" button on the bottom right of the editor.

For answers and comments, the saved drafts are bound to the parent posts. If you start for instance to write an answer to a question with the ID 12345, get this draft saved, then decide to first answer the question with the ID 54321, you will find the first saved draft when you open again the editor to answer the first question. Asking a question is an exception to this, only one draft for a question gets stored. It reappears always, when you start to ask a question.

Drafts get deleted at the following occasions:

1. When you submit a post, the corresponding draft gets deleted.
2. Automatically, some time (to be defined yet, for instance a week, or a month) after the last update of a draft. This feature is ready, but not yet installed. It shall prevent drafts to trail on the server forever. Please propose a time span that you consider as convenient for you.

If already existing posts get edited, the feature is off, because there might be an ambiguity between the existing post and a draft with the same parent.

For privacy reasons, the saved drafts are only accessible to the logged-in user that saved it, nobody else.

To my knowledge, we are the first site based on the Question2Answer framework, which has a server based save/autosave feature.

edited May 21, 2015

Thanks Polarkernel, this is great !

Now I can draft long posts directly on PO :-)

Thanks, Polarkernel, it is helpful indeed.

Thank you!

saving it for 1 week is enough, I think.

If I remember it correctly @RonMaimon likes sometimes to first put down preliminary notes to work them out to a full answer later. So maybe he has an opinion about how long drafts should get stored too?

Is there any drawback when storing them for rather long time ?

@Dilaton Technically there is no drawback, as I assume most of these drafts will get removed by posting. Therefore, database space will not be a limit.

@Dilaton: I think the draft lifetime should be very long, perhaps infinite, under the condition that the material is protected by a privacy policy, so that it isn't snooped on. The server is only accessible by superadministrators, right? My original concern was that storing the material would violate privacy, but it would be more annoying for a long draft to disappear, once you have a save feature, people start to count on it. I am very happy with this feature, and of course, thanks @polarkernel.

@RonMaimon, I personally agree with a long (up to $\infty$) saving time, in particular since Polarkernel explained that there is no technical drawback to it.

Only @polarkernel can access the server, and as I understand it only the OP is able to ever see his drafts (before they are posted).

Sorry, actually the deletion on posting seems not to work on this server (it works perfectly on my local site). Please just delete the remaining content using CTRL A and  DEL. I am trying to solve this issue as soon as possible.

@RonMaimon Only I can access the database, nobody else. After many tests I decided to use a server based solution, as otherwise, using the html5 feature to store data using the browser, produced a lot of compatibility issues and would not be accessible to users with older browsers or operating systems.

I agree with having it for an infinite period of time. If someone stores something as a draft, they'd expect it to be ready when they come back 2 weeks later. I don't think there are privacy issues with storing it from ever.

The autosave autodeletion issue is a problem on stackexchange, too - they have an autosave feature, but it "doesn't always work", and the moderators there don't know why either (but from my experience I think it gets autodeleted), and thus they don't advertise the feature formally at all.

I had to remove the feature that automatically saved your draft, when you left the editor and loaded for instance another page or switched to another post. The reason is that it is impossible to get a reliable event from CKEDITOR when it looses focus. Like this, for some browsers, the editor sent this event also after submission of a post, so that the submitted post was again saved as draft instead to be deleted from the drafts database table.

So if you like to leave the editor, you have to press the "Save draft" button on the bottom right of the editor to be sure that your draft gets completely saved. If you leave the page, you still get alerted as already known before.

@polarkernel Strange, quora does autosave without any problems.

I think autosave is quite important. The manual save is just a simpler way than copy-pasting in a text editor or something.

@dimension10 We still have autosave, automatically, whenever you stop writing, 10 seconds after the last key stroke. But if the post is not yet completely saved, for instance because somebody is continuously writing an answer and then, immediately (before the 10 seconds), decides to click to "add comment" and to write a comment first, then the last part of his post, since the last autosave, will not been saved. To avoid this, you have to press "Save draft" first, then you are sure that your post has been saved completely. I could also shorten the 10 seconds but I tried to generate not too much traffic to the server.

@polarkernel OK, that's fine with me, at least. 5 seconds would be a more appropriate duration, I think.

@dimension10 I have reduced the time from the last keystroke to the automatic save to 5 seconds.

 Please use answers only to (at least partly) answer questions. To comment, discuss, or ask for clarification, leave a comment instead. To mask links under text, please type your text, highlight it, and click the "link" button. You can then enter your link URL. Please consult the FAQ for as to how to format your post. This is the answer box; if you want to write a comment instead, please use the 'add comment' button. Live preview (may slow down editor)   Preview Your name to display (optional): Email me at this address if my answer is selected or commented on: Privacy: Your email address will only be used for sending these notifications. Anti-spam verification: If you are a human please identify the position of the character covered by the symbol $\varnothing$ in the following word:p$\hbar$ysicsO$\varnothing$erflowThen drag the red bullet below over the corresponding character of our banner. When you drop it there, the bullet changes to green (on slow internet connections after a few seconds). To avoid this verification in future, please log in or register.