English | 简体中文
NetnrMD Editor
jQuery + Monaco Editor + Marked Parsing + DOMPurify Cleaning + highlight
https://md.netnr.com
Install
<div>
<div id="editor">Loading ...</div>
</div>
<script src="https://code.bdstatic.com/npm/jquery@3.5.0/dist/jquery.min.js"></script>
<script src="https://code.bdstatic.com/npm/monaco-editor@0.20.0/min/vs/loader.js"></script>
<link href="/src/netnrmd.css" rel="stylesheet" />
<script src="/src/netnrmd.bundle.min.js"></script>
<script>
require.config({
paths: { vs: "https://code.bdstatic.com/npm/monaco-editor@0.20.0/min/vs" },
'vs/nls': { availableLanguages: { '*': 'zh-cn' } }
});
require(['vs/editor/editor.main'], function () {
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.clear();
nmd.render();
nmd.hide();
nmd.hide('toolbar');
nmd.show();
nmd.show('toolbar');
nmd.setstore();
nmd.getstore();