English | 简体中文
NetnrMD Editor
jQuery + Monaco Editor + Marked Parsing + DOMPurify Cleaning + highlight
https://md.netnr.com
Install
https://www.jsdelivr.com/package/npm/netnrmd
<div>
<div id="editor">Loading ...</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.21.2/min/vs/loader.js"></script>
<link href="src/netnrmd.css" rel="stylesheet" />
<script src="src/netnrmd.js"></script>
<script src="src/netnrmd.extend.js"></script>
<script>
require.config({
paths: {
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.21.2/min/vs"
},
'vs/nls': { availableLanguages: { '*': 'zh-cn' } },
mdrely: [
'https://cdn.jsdelivr.net/npm/marked@1.2.0/lib/marked.min',
'https://cdn.jsdelivr.net/npm/dompurify@2.1.1/dist/purify.min',
'https://cdn.jsdelivr.net/npm/highlight.js@9.18.3/lib/highlight.min',
'vs/editor/editor.main'
]
});
require(require.getConfig().mdrely, function (m, p, h) {
window.marked = m;
window.DOMPurify = p;
window.hljs = h;
window.nmd = new netnrmd('#editor');
});
</script>
Options
var nmd = new netnrmd('#editor', {
viewmodel: 2
fontsize: 16,
height: 300,
defer: 300,
storekey: "key",
autosave: true,
prefixkey: 'Ctrl+',
viewbefore: function () {
console.log(this);
},
input: function () {
console.log(this);
},
cmdcallback: function (cmd) {
console.log(this);
}
});
Function
var nmd = new netnrmd('#editor');
console.log(nmd);
nmd.focus();
nmd.height(200);
nmd.toggleView();
nmd.toggleView(1);
nmd.toggleView(2);
nmd.toggleView(3);
nmd.setmd(md);
nmd.getmd();
nmd.sethtml(html);
nmd.gethtml();
nmd.render();
nmd.hide();
nmd.hide('toolbar');
nmd.show();
nmd.show('toolbar');
nmd.setstore();
nmd.getstore();