Split easymde in multipackages or several files : `easymde` and `easymde-core` ?
See original GitHub issueIf we split easymde in several files, we will allow developpers to cutomize Codemirror with addon of their choice, like Search/Replace or modify require('codemirror/mode/markdown/markdown.js');
.
We can split easymde:
- in several packages with lerna ;
- or keep one package and split the main file to several file.
I propose to split easymde in two, the core and the default config (which load the core).
several files
require('easymde/core.js`) // if we want only get core of easymde (without default button and we will be able to use our own `codemirror/mode/markdown/markdown.js`)
require('easymde`) // if we want load default settings
multipackages
You can organize a project/repository codebases into multi-package with Lerna which is a package manager.
easymde-core
: will be thecomponents
/addons
with all specific functions of easymde ;easymde
: Aturnkey solution
which requireeasymde-core
,codemirror
, codemirror addons, etc…
easymde should become:
easymde module (click to open)
var CodeMirror = require('codemirror');
require('codemirror/addon/edit/continuelist.js');
require('./codemirror/tablist');
require('codemirror/addon/display/fullscreen.js');
require('codemirror/mode/markdown/markdown.js');
require('codemirror/addon/mode/overlay.js');
require('codemirror/addon/display/placeholder.js');
require('codemirror/addon/selection/mark-selection.js');
require('codemirror/addon/search/searchcursor.js');
require('codemirror/mode/gfm/gfm.js');
require('codemirror/mode/xml/xml.js');
var CodeMirrorSpellChecker = require('codemirror-spell-checker');
var marked = require('marked');
const EasyMDE = require('easymde-core')(CodeMirror);
CodeMirrorSpellChecker({
codeMirrorInstance: CodeMirror,
});
EasyMDE.prototype.markdown = function (text) {
if (marked) {
// Initialize
var markedOptions;
if (this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions) {
markedOptions = this.options.renderingConfig.markedOptions;
} else {
markedOptions = {};
}
// Update options
if (this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) {
markedOptions.breaks = false;
} else {
markedOptions.breaks = true;
}
if (this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true) {
/* Get HLJS from config or window */
var hljs = this.options.renderingConfig.hljs || window.hljs;
/* Check if HLJS loaded */
if (hljs) {
markedOptions.highlight = function (code) {
return hljs.highlightAuto(code).value;
};
}
}
// Set options
marked.setOptions(markedOptions);
// Convert the markdown to HTML
var htmlText = marked(text);
// Sanitize HTML
if (this.options.renderingConfig && typeof this.options.renderingConfig.sanitizerFunction === 'function') {
htmlText = this.options.renderingConfig.sanitizerFunction.call(this, htmlText);
}
// Edit the HTML anchors to add 'target="_blank"' by default.
htmlText = addAnchorTargetBlank(htmlText);
return htmlText;
}
};
# end of the file
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Ionaru/easy-markdown-editor: EasyMDE - GitHub
EasyMDE : A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving ...
Read more >easymde - npm
A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.
Read more >EasyMDE Demo
A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell ...
Read more >EasyMDE markdown editor not adding event listeners on ...
I've tried adding a script with src pointing to easymde.min.js file after new elements are created, but it's not working.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m going to close this is favour of https://github.com/Ionaru/easy-markdown-editor/issues/262, ESModules support splitting the editor into multiple files and lazy-loading them when needed.
While working on a big rewrite of the editor with all the fancy modern browser features and with an eye on modularity I’ve come up with this:
In my opinion this is the way forward instead of making separate Lerna packages.
We may be able to look at how https://github.com/microsoft/roosterjs implemented something similar.