NetnrMD 编辑器
Ace 编辑器 + Marked 解析 + DOMPurify 清洗 + highlight 代码高亮 + tocbot 目录 + pangu 间隙
https://md.js.org
Usage 使用
https://www.npmjs.com/package/netnrmd
<div class="nr-editor">Loading ...</div>
<link href="/dist/netnrmd.css" rel="stylesheet" />
<script src="/dist/ace.js"></script>
<script src="/dist/netnrmd.js"></script>
<script>
var nmd = netnrmd.init('.nr-editor');
</script>
Options 选项
var nmd = netnrmd.init('.nr-editor', {
theme: 'auto',
ph: '预览区域',
toc: true,
viewmodel: 2,
fullscreen: 0,
fontsize: 16,
height: 300,
defer: 500,
headerIds: function (node, index) { node.id = "toc_" + index },
autosave: true,
storekey: `${location.pathname}_netnrmd_content`,
input: function () {
console.log(this.getmd());
},
cmdcallback: function (cmd) {
console.log(this);
},
resize: function (ch) {
this.height(ch - 20);
}
});
Function 方法
var nmd = netnrmd.init('.nr-editor');
console.log(nmd);
nmd.setmd(md);
nmd.getmd();
nmd.sethtml(html);
nmd.gethtml();
nmd.render();
nmd.focus();
nmd.insert("text");
nmd.height(300);
nmd.toggleView();
nmd.toggleView(1);
nmd.toggleView(2);
nmd.toggleView(3);
nmd.toggleTheme();
nmd.toggleTheme("light");
nmd.toggleTheme("dark");
nmd.toggleTheme("auto");
nmd.hide();
nmd.hide('toolbar');
nmd.show();
nmd.show('toolbar');
nmd.setstore();
nmd.getstore();
nmd.objOptions
nmd.objWrite
nmd.objWrite.getValue()
nmd.save(format, filename)
nmd.addCommand("Ctrl+S", () => { })
netnrmd.render(md)
netnrmd.spacing(text)
netnrmd.popup(title, content)
netnrmd.emoji
netnrmd.hljs
netnrmd.DOMPurify
netnrmd.marked