-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Switch from SimpleMDE to EasyMDE #13333
Conversation
Signed-off-by: Andrew Thornton <art27@cantab.net>
This could do with a few people testing it to ensure that it actually is doing the right thing and has set up the codemirror properly |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some warning about CodeMirror seen during
Not sure what's the issue but CM is generally rather webpack-unfriendly unfortunately. |
I think it's to do with the load-addon plugin. I'll see if we can move loading that out to the script section. (When I googled the error people said to just ignore it...) |
Signed-off-by: Andrew Thornton <art27@cantab.net>
That seems to do it - but I don't know how to test the mode loading stuff. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Not sure how the initialization goes but I think easymde should trigger the markdown mode load itself and you should see some syntax highlighting when it does. Probably need to vendor codemirror for it to work because codemirrors hates webpack. |
Thought I would not mind if we do away with the syntax highlight (and CM modes) in comment boxes, it's not really something we'll have in the long run anyways. |
So one of the cool things about easymde is that it appears to work on android... It might a be reason to allow users to choose between codemirror and monaco editors. (monaco fails miserably on android.) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
suggest use it in release content editor also. |
The way this PR is written it simple replaces any call to SimpleMDE as EasyMDE |
In another PR please. This is only a replacement. |
Gave it a quick test, seems to work as before. I think we can actually drop the loadmode.js, meta.js and modeURL handling in footer.tmpl because I think those are relics from the past when codemirror was used as code editor. Right now it only does markdown mode so it should never need to load anything else. Also, with this I think we can nuke the codemirror vendored files in |
You can pull in silverwind@fa97212 which nukes the codemirror vendoring, I did not notice any difference in the comment editor without it. |
Let's not do that in this PR - I think we could do that in a week if we don't notice any problems with the EasyMDE replacement - it would be useful to know/ensure that easymde is doing everything it should do first. |
Ok we can clean that up later too. |
Think we need to disable |
Or we just nuke the mode load stuff so we don't even need to do such workarounds. As I understand it, codemirror inside easymde is pretty-much zero-conf and does not need to load modes. |
I'd suggest you apply below and diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl
index c8e9674fb..00a643f66 100644
--- a/templates/base/footer.tmpl
+++ b/templates/base/footer.tmpl
@@ -12,13 +12,8 @@
{{template "base/footer_content" .}}
{{if .RequireSimpleMDE}}
<script src="{{StaticUrlPrefix}}/js/easymde.js?v={{MD5 AppVer}}"></script>
- <script src="{{StaticUrlPrefix}}/vendor/plugins/codemirror/addon/mode/loadmode.js"></script>
- <script src="{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/meta.js"></script>
- <script>
- CodeMirror.modeURL = "{{StaticUrlPrefix}}/vendor/plugins/codemirror/mode/%N/%N.js";
- </script>
{{end}}
<!-- Third-party libraries -->
{{if .RequireU2F}}
diff --git a/web_src/js/easymde.js b/web_src/js/easymde.js
index 39ead02c1..c2f608b55 100644
--- a/web_src/js/easymde.js
+++ b/web_src/js/easymde.js
@@ -1,8 +1,4 @@
import EasyMDE from 'easymde';
-import CodeMirror from 'codemirror/lib/codemirror.js';
-
window.EasyMDE = EasyMDE;
window.SimpleMDE = EasyMDE;
-window.CodeMirror = CodeMirror;
- |
AFAIU we still need the codemirror to be exposed. |
I don't see a purpose in doing that, that exposure was for the code editor to load modes which we've since switched to monaco. Again, I don't think easymde's codemirror needs the ability to load modes. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
the githook editor is still codemirror I think. |
Let's get the easymde in first then sort out the rest of these issues in another PR |
Right, git hook needs to migrate to Monaco, it's interfacing with |
Codecov Report
@@ Coverage Diff @@
## master #13333 +/- ##
=======================================
Coverage 42.18% 42.19%
=======================================
Files 694 694
Lines 76351 76351
=======================================
+ Hits 32210 32215 +5
+ Misses 38861 38859 -2
+ Partials 5280 5277 -3
Continue to review full report at Codecov.
|
Signed-off-by: Andrew Thornton art27@cantab.net