-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EasyMDE: enable autosave #25026
EasyMDE: enable autosave #25026
Conversation
Related to:
I didn't do so because EasyMDE's autosave doesn't work well with Gitea's form. For example, if you enter some texts in the EasyMDE edtior, click "Comment and close", then you still get the drafts on the new page. And, some comments are submitted by AJAX (eg: inline comment, edit), EasyMDE's autosave doesn't work well with it either. Another reason is there is a plan to deprecate EasyMDE, so there needs a general solution for the native textarea editor. Just share my opinion and knowledge, there is no block from my side if people like the EasyMDE autosave. |
We already have something that preserves unsaved comment text for example on page reload, and I just tested it and it works for both editors, so I don't think we need this. @wxiaoguang do you know which mechanism currently does it currently? We should remove the unsaved warning box if it works reliably. |
Do you mean "preserves unsaved comment text for example on page reload"? IIRC, it's provided by browser's cache, and related to : #22604 |
Yes. Interesting, I didn't expect this to be a browser-native mechanism. |
@@ -190,6 +190,10 @@ class ComboMarkdownEditor { | |||
// EasyMDE's CSS should be loaded via webpack config, otherwise our own styles can not overwrite the default styles. | |||
const {default: EasyMDE} = await import(/* webpackChunkName: "easymde" */'easymde'); | |||
const easyMDEOpt = { | |||
autosave: { | |||
enabled: true, | |||
uniqueId: this.textarea.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! Is this ID unique to the textarea on issue pages as a whole, or does the textarea on each issue page have its own ID? The context on why I am asking is that users may have "drafts" for many issue comments, and if it were the same ID for all issue pages then they would only be able to have one draft.
A followup on @silverwind's comment re: removal of easymde, is we could use https://github.com/github/session-resume to achieve the same behaviour with the new text editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/github/session-resume looks interesting and can likely be used in place of jquery.are-you-sure
for automatic form restoration. This could be used for all forms, not just issue comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually session-resume
doesn't work well either. Think about 2 cases:
- Content in the textarea -> submit the form -> clean the draft -> network fails -> content lost
- Content in the textarea -> submit the form by AJAX -> draft is still in local storage
That's why "AJAX" is before the "LocalStorage Draft" in my summary issue #23290
Enable autosave editor by default. It is annoying that you can lose whole text when you accidentally close a window or you do some miss click.
The easy markdown editor has options for this behavior.
https://github.com/Ionaru/easy-markdown-editor#options-list