Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web_src/js/features/comp/ComboMarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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.

Copy link
Member

@silverwind silverwind Jun 2, 2023

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.

Copy link
Contributor

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:

  1. Content in the textarea -> submit the form -> clean the draft -> network fails -> content lost
  2. 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

},
autoDownloadFontAwesome: false,
element: this.textarea,
forceSync: true,
Expand Down