netnrmd
Markdown Combinatorial editor | 组合编辑器
markdown 语法解析基于 remarkable
,编辑与解析分离
调用任意 markdown 解析器都能完美的运行
https://md.netnr.com
Install 安装
<link href="https://lib.baomitu.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="https://lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
<script src="https://lib.baomitu.com/remarkable/1.7.1/remarkable.js"></script>
<link href="netnrmd.css" rel="stylesheet" />
<script src="netnrmd.min.js"></script>
<script src="https://lib.baomitu.com/highlight.js/9.12.0/highlight.min.js"></script>
Usage 使用
var nmd = new netnrmd('#txt');
console.log(nmd);
console.log($('#txt').data('netnrmd'));
Documentation 文档
remarkable demo
Options 选项
var nmd = new netnrmd('#txt', {
viewmodel: 2
height: 300,
defer: 300,
storekey: "key",
autosave: true,
prefixicon: 'fa fa-',
prefixkey: 'Ctrl+',
render: function (md) {
console.log(md)
return md;
},
items: [
{
title: '表情',
icon: 'smile-o',
key: 'E',
cmd: 'emoji'
},
{
title: '粗体',
icon: 'bold',
key: 'B'
}
],
viewbefore: function () {
console.log(this);
this.items.splice(0, 0, {
title: '表情/emoji',
icon: 'smile-o',
key: 'E',
cmd: 'emoji'
});
},
input: function () {
var htm = this.md.render(this.getmd());
htm = emojiParse(htm);
this.sethtml(htm);
return false;
},
cmdcallback: function (cmd) {
if (cmd == "emoji") {
$('#myModalEmoji').modal();
}
}
});
console.log(nmd.md.render('# netnrmd!'));
Function 方法
var nmd = new netnrmd('#txt');
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();
var ops = {
cmd: cmdname,
txt: nmd.obj.textarea[0],
before: '**',
defaultvalue: '加粗',
after: '**'
};
netnrmd.insertxt(ops);
Textarea Extend 文本域拓展
var txtDom = $('#txt')[0];
netnrmd.getCursortPosition(txtDom);
netnrmd.getCursortPosition(txtDom, 3);
netnrmd.getSelectText(txtDom);
netnrmd.setSelectText(txtDom, 1, 3);
netnrmd.insertAfterText(txtDom, "text");
Authors 作者