go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.64k stars 5.45k forks source link

Replace EasyMDE with textarea #10729

Closed silverwind closed 1 year ago

silverwind commented 4 years ago

SimpleMDE is unmaintained and in my opionion very bloated for what it does. It ships with a full version of CodeMirror (a code editor) embedded which enables markdown syntax highlight in the editor, but I think its a neglible feature that is mostly unnecessary as comments are meant to be viewed in rendered mode primarily.

I suggest we switch to a plain <textarea> like the ones Github and Gogs use. Some buttons to insert pre-generated snippets at the cursor can be provided. Emoji can be supported via :token: to Unicode replacement or directly as Unicode as always. Image-based custom emoji can not render in it, but they may in the rendered view (thought Unicode should be preferred).

jolheiser commented 4 years ago

I personally love this idea, I always end up turning it off immediately.
That being said, I think many users enjoy the WYSIWYG.

If we had a toolbar similar to GH that injected symbols (e.g. bold would wrap your cursor with ****) perhaps that would be a good trade-off?
I'm unsure about removing a feature unless we have a good alternative.

silverwind commented 4 years ago

Yes of course, formatting buttons must be provided for a viable alternative. Also, @mentions and :emoji have to work. I wonder if there is maybe a JS library around that can provide markdown-formatting functionality to a <textarea>, or if we have to code those up ourselves.

I think it may be beneficial to first do the transition to unicode emoji (which means replacing emojify.js with something that emits proper unicode instead of images, except on custom emoji).

bobemoe commented 4 years ago

I did a review of several WYSIWYG markdown editors over in https://github.com/go-gitea/gitea/issues/9619 and found Ace was beginning to look promising as it was also being considered for the code editor.

I'm afraid I didn't find time to continue with it but it may be worth checking out from https://github.com/go-gitea/gitea/issues/9619#issuecomment-578486731 onwards

I would be happy with plain <textarea> too, but also agree some of my colleagues would prefer (basic) WYSIWYG.

silverwind commented 4 years ago

I think WYSIWYG goes against the spirit of Markdown, which is meant to be edited in plaintext.

bobemoe commented 4 years ago

Yeah, you're right. Something simple like this GitHub editor would be perfect.

silverwind commented 4 years ago

Indeed, GH's one is quite nice. It's just a lightweight textarea with a few formatting/snippets buttons. I guess such functionality can be replicated in like 5-10kB of JS.

guillep2k commented 4 years ago

We need to keep in sight that many Gitea end users are not programmers (e.g. someone who reports a bug on an end-user product), so I think WYSIWYG is important as an option.

silverwind commented 4 years ago

I don't think Markdown is hard to learn and with the formatting buttons offered, it should become clear how it works pretty fast. GitHub never offered Markdown WYSIWYG and I think it's just silly if we would do so.

lunny commented 4 years ago

@silverwind We could make that as a user level options. :)

suli3 commented 4 years ago

Most of the un-programmers are familiar with office, what they want to do is copy doc words to the issue and hope that these words could be as shown in the office.

silverwind commented 4 years ago

copy doc words

Markdown only supports a small subset of what is possible in such documents (colors, font face, exact font sizes, underline, background color and many more). Those users would be better off just attaching said document.

silverwind commented 4 years ago

https://github.com/patrickfatrick/marky-marked might be a alternative, it's 12.2kB gzipped. The only thing I don't like is that it relies on FontAwesome, but I guess we replace icons with SVG.

SuperSandro2000 commented 4 years ago

We could make that as a user level options. :)

For me this sounds like feature creep. MD is perfectly fine for a issue board.

lafriks commented 4 years ago

Or this one https://github.com/nhn/tui.editor, I don't know how big this one is tho

mrsdizzie commented 4 years ago

https://github.com/github/markdown-toolbar-element : )

lafriks commented 4 years ago

While for comments I agree that we would need just toolbar but for markdown editor (wiki & markdown files) we need something better :)

silverwind commented 4 years ago

@toast-ui/editor is heavyweight, even more so than simplemde, but I guess for the "full" editor, it might not matter.

https://bundlephobia.com/result?p=@toast-ui/editor@2.2.0 https://bundlephobia.com/result?p=@github/markdown-toolbar-element@1.3.1 https://bundlephobia.com/result?p=marky-marked@5.0.3 https://bundlephobia.com/result?p=simplemde@1.11.2 https://bundlephobia.com/result?p=easymde@2.10.1

igalic commented 4 years ago

does any of these suggested editors not exhibit the same input bugs (on mobile browsers) as SimpleMDE? (https://github.com/go-gitea/gitea/issues/11352)

cuz my understanding (from that other bug at least) is that that's the reason to replace it

lafriks commented 4 years ago

Toast UI editor demo was working just fine for me on android phone

bobemoe commented 4 years ago

The lack of spell checker was my main issue with SimpleMDE (https://github.com/go-gitea/gitea/issues/9619)

lafriks commented 4 years ago

We could also use EasyMDE (fork of SimpleMDE) https://github.com/Ionaru/easy-markdown-editor/ Just checked it does work better on mobile but also has some issues: https://github.com/Ionaru/easy-markdown-editor/issues/77 Also text selection on mobile does not seem to work

silverwind commented 4 years ago

I'm still in favor of a simple textarea (possibly with a live preview) with formatting buttons on top which is just the best in terms of accessibility and compatibilty and GitHub also does exactly that and it seems to work for them.

Toast UI looks to be architured similar to SimpleMDE with CodeMirror under the hood and after opening https://ui.toast.com/tui-editor/ and clicking the "All Extensions" tab, I already see a bug where the preview area is rendered incorrectly in Firefox, so it's rather off-putting.

mrsdizzie commented 4 years ago

I agree with @silverwind -- I have to turn the current editor off completely because it is a bad overall experience (I've heard other devs who do the same). Anything that breaks built in spell check and correction feels like it should be a total non-starter for any text editing and that seems to apply to most of these various 'mde' type projects.

The Github package seems to offer almost everything people are asking for (many built in shortcuts for adding various markdown elements), is accessible by default, doesn't break spell check, and has a clear future of being maintained -- which seems to be an issue for several of the javascript dependencies we've adopted in the past:

https://github.com/github/markdown-toolbar-element

Also fwiw I think the textarea with a preview tab model does count as WYSIWYG generally as you are able to easily see exactly what the final output will look like on each adjustment before publishing.

a1012112796 commented 4 years ago

Hmm, It's meaningfull, But please do something to keep SimpleMDEImagePaste or similar thing which is verry usefull when adding Image, Thanks

igalic commented 4 years ago

I agree with @silverwind -- I have to turn the current editor off completely because it is a bad overall experience

how???

mrsdizzie commented 4 years ago

@igalic

Screen Shot 2020-06-29 at 11 20 37 AM
silverwind commented 4 years ago

Hmm, It's meaningfull, But please do something to keep SimpleMDEImagePaste or similar thing which is verry usefull when adding Image, Thanks

Yes of course, image pasting has to work. It's actually rather simple to do in vanilla JS.

markdown-toolbar-element looks quite nice. It does not ship icons so we can integrate our own.

CL-Jeremy commented 4 years ago

Emoji can be supported via :token: to Unicode replacement or directly as Unicode as always. Image-based custom emoji can not render in it, but they may in the rendered view (thought Unicode should be preferred).

Good to see this already works with emoji.js

I've started some very crude work on porting Twemoji to support older platforms (probably as a non-mainline patchset): https://github.com/CL-Jeremy/gitea/commit/5e843a9a3d6735f6c38376098bed81dc8017202d

Tested on IE 11/Windows 7, Chrome Dev 44/Android 4.2.2, Firefox 38, Firefox 45. They basically look exactly the same as latest Firefox on Windows 7 after https://github.com/go-gitea/gitea/pull/12522 gets merged.

The remaining task is to either intercept the data from API (in index.js) or directly add some sort of cookie-based mechanism in backend like GitLab does, so dynamic content (reactions, markdown) works. The emoji popup is working already as is. For those on Windows and non-standard Linux distros, this could be a fallback in favor of removing static Noto Color Emoji (which is already outdated as of now).

silverwind commented 4 years ago

Are you restoring image-based emoji? I don't think we should ever go back to those and I'd rather like to stay fully unicode-based and drop the one image emoji. This is also where GitHub is heading. In 1.13 we specifically limited the supported browser browser list to not support ancient browsers.

CL-Jeremy commented 4 years ago

Yes I am. If you are talking about emojify.js, those lack a lot of features like skin tones. Twemoji is feature-complete, free (emojify.js used Apple's design), remains up to date and is hosted on a global CDN network without bloating local resources.

I actually visited the commit and read this:

Not included here are image fall back URLS. I don't really think they are necessary for anything new being written in 2020. However, managing the emoji ourselves would allow us to add these as a feature later on if it seems necessary.

I completely understand and respect your decision and concerns. IE is still broken in many regards and I only included some of the fixes in my branch to facilitate testing (like babelizing escape-goat and polyfilling Array.from/Map.values). I'm personally for better compatibility (seeing how other platforms still at least render half-well on older platforms) but without active maintenance (while allowing voluntary patches, as long as they don't add too much burden). I take image fallback as a viable solution since it almost only deals with displaying UI with minimal user interaction, so features could hardly break here. It's also a solution to vendoring static Noto Color Emoji.

silverwind commented 4 years ago

What is Twemoji exactly? Image fallback or unicode font?

CL-Jeremy commented 4 years ago

What is Twemoji exactly? Image fallback or unicode font?

Both. It's like EmojiOne and all those fonts, which are built into various formats, but this one is used in production and yet freely available. It's what Twitter is still using in 2020 (for obvious reasons).

What's special about those is that recent Firefox ships with them (early Firefox ships with EmojiOne) as a built-in TTF file (called Twemoji Mozilla), so Firefox automatically falls back to them (that's why I suggested explicitly adding it to the font stack to prioritize it over DejaVu Sans/Segoe UI Symbol or some Japanese JIS-compatible fonts). So almost all Gecko/Servo browsers have no need for web fonts whatsoever.

It's also made freely available by Twitter as PNG and SVG images with URLs mapped right to their code points, hosted on GitHub via CDN. I'm using those in the above mentioned branch opportunistically with less than 10 lines of code.

silverwind commented 4 years ago

Unicode font is fine with me and this does sound like a better alternative then the heavyweight Noto. Image fallback should not be in the mainline repo thought. I guess one could do a customization to run a replacement script to support really old clients with fallback images, but browsers like IE11 are already in a rather broken state since 1.12 and we dropped support for them in 1.13.

CL-Jeremy commented 4 years ago

It's also possible to fall back at per-glyph basis, so missing glyphs could still be rendered as images. Aesthetically less appealing though.

I guess one could do a customization to run a replacement script to support really old clients with fallback images, but browsers like IE11 are already in a rather broken state since 1.12 and we dropped support for them in 1.13.

I'll investigate that. I haven't found a way to customize in depth and I don't think it's possible without something like DOMObserver which is just too costly to implement.

lafriks commented 4 years ago

Another good alternative imho could be: https://prosemirror.net/examples/markdown/

igalic commented 4 years ago

and it doesn't create word and letter duplication or deletion! wow!

silverwind commented 4 years ago

Not sure it's suitable because our preview must be server-rendered.

corneliusroemer commented 3 years ago

I find it curious that everyone is talking about how they want to be accessible for non-programmers and therefore need WYSIWYG, while currently Gitea uses abandoned SimpleMDE that makes non-programmers abandon Gitea as soon as they try to open an issue on mobile (which is the first point of contact for a lot of people).

I thought the mission of Gitea was "ease of use", including buggy, unmaintained bloat like a broken editor while chasing an unreachable unicorn WYSIWYG Markdown editor does not sound like that at all.

If the issues are mobile only, at least disable SimpleMDE on mobile by default. The current way is bad, yes, there are workarounds but 90% leave before figuring them out.

zeripath commented 3 years ago

We would be very happy to approve a PR which disables the easymde and monaco on mobile.

corneliusroemer commented 3 years ago

@zeripath: @ashimokawa wrote a patch for Codeberg that sets the default to textarea for mobile user agents. It's already in production over there.

I don't know enough about Gitea to adapt it. It shouldn't take more than a minute for someone who knows the Gitea codebase, it's just a few lines.

I copied over the content of the custom header template into the empty template here for Gitea - that's probably not how you want to do it but it would work. See #14017

See here: https://codeberg.org/Codeberg/build-deploy-gitea/commit/840fd48cad0c72933becafbe561addc6cdfb11e2

6543 commented 3 years ago

@silverwind did #13333 close this issue already?

corneliusroemer commented 3 years ago

@6543 I don't think #13333 closes this issue. EasyMDE is still not ideal (e.g. auto correct doesn't work on mobile) and @silverwind was making a proposal to move away from WYSIWYG entirely. #13333 makes this move less pressing but the fundamental points raised are still not resolved.

silverwind commented 3 years ago

No, EasyMDE is just a kludge until we have plain textarea (with buttons ofc).

Reinitialized commented 3 years ago

As a programmer, discovering there is a button on the toolbar to disable the pain to use EasyMDE by attempting to report an issue and searching to find this specific issue is terrible UX. I understand the desire to support use cases such as users filing reports to the developers hosting Gitea instances, but either doing what GitHub does for their comment/code editor or merely a link referencing how to use markdown seems much more appropriate to me. Although I will continue to use Gitea as overall I enjoy the experience with the project, this issue is rather UX breaking, and the jarring experience could lead to loss of potential users.

TLDR: please switch over to textarea. Even as a programmer myself, it was a pain figuring out how to turn it off.

silverwind commented 3 years ago

https://github.com/go-gitea/gitea/pull/15394

BoPeng commented 2 years ago

I share the concerns about easyMDE and was interested in the discussions here. Has anyone checkout krajee-markdown-editor and see if it fits the bill? bootstrape-markdown-editor could also work.

silverwind commented 2 years ago

Both of these have a lot of heavyweight dependencies, I would not consider them.

BoPeng commented 2 years ago

krajee-markdown-editor.min.js is 44k, bootstrape-markdown-editor.js is 16k, and easynde.min.js is 316k so I suppose your complaint was about jquery, bootstrap, fontawsome, codemirror, etc. Let me try krajee-markdown-editor since my project already uses bootstrap 5 and jquery.

silverwind commented 2 years ago

Yes, we can't depend on a framework like bootstrap and jQuery is also on its way out for us.

I think nothing really beats markdown-toolbar-element in terms of size, it's 3kB after gzip.

KiaraGrouwstra commented 1 year ago

fyi there's also ink-mde, based on prosemirror-markdown