NetnrMD编辑器
jQuery + Monaco Editor 编辑器 + Marked 解析 + DOMPurify 清洗 + highlight 代码高亮
https://md.js.org
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>
<link href="https://cdn.jsdelivr.net/npm/netnrmd@2.6.1/src/netnrmd.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/netnrmd@2.6.1/src/netnrmd.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.23.0/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.23.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,
fullscreen: 1,
fontsize: 16,
height: 300,
defer: 500,
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.setmd(md);
nmd.getmd();
nmd.sethtml(html);
nmd.gethtml();
nmd.render();
nmd.focus();
nmd.height(200);
nmd.toggleView();
nmd.toggleView(1);
nmd.toggleView(2);
nmd.toggleView(3);
nmd.hide();
nmd.hide('toolbar');
nmd.show();
nmd.show('toolbar');
nmd.setstore();
nmd.getstore();
netnrmd.render(md)
netnrmd.getSelectText(me)
netnrmd.insertAfterText(me, text)
netnrmd.popup(title, content)