-
Notifications
You must be signed in to change notification settings - Fork 320
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
Expose the CodeMirror library object, so static methods like defineExtension can be called on it #263
base: master
Are you sure you want to change the base?
Conversation
…tension be called on it
I'm tempted to raise the same argument I did back then: The editor cannot guarantee that the entire unchanged CodeMirror library will be included with it. With this change, you, and others, will assume that it does by using methods from that library. I think the solution offered by @coconutpalm in his comment on PR #76 is better. |
Ok, I've added a commit that does that. Standard codemirror.js is currently 389K (129K on gzip) so I think there's still a case for avoiding 2 instances of the library on a page. Exposing the internal instance seems simple (if folks use it at their own risk). Maybe another option would be an EasyMDE build that doesn't include codemirror. |
I'm asuming 129K is unminified and can be reduced further because the EasyMDE package is only 95.7K. |
Yes, that's |
@@ -2863,4 +2863,6 @@ EasyMDE.prototype.toTextArea = function () { | |||
} | |||
}; | |||
|
|||
EasyMDE.CodeMirror = CodeMirror; |
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.
This isn't needed anymore, right?
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.
Not for your preferred approach, correct. I'd still find it useful to avoid ~66K duplication though.
Hi,
This is a very small change to enable more customization of EasyMDE/CodeMirror, like allowing addons to be used (fixes [#188] then). Otherwise there is no way to run CodeMirror static methods.
It is very similar to [#76] but more cautious (not setting global
window.CodeMirror
).In that pull request it was suggested to just package another copy of CodeMirror, but that doesn't work because running
CodeMirror.defineExtension(...)
would only affect the separate copy and not the one used by EasyMDE.Steps to enable a CodeMirror addon would be:
easymde.min.js
on page as usualEasyMDE.CodeMirror.defineExtension(...)
window.CodeMirror = EasyMDE.CodeMirror
and include the addon .js file