1 Star 0 Fork 2

可可味 / netnrmd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

English | 简体中文

NetnrMD编辑器

jQuery + Monaco Editor 编辑器 + Marked 解析 + DOMPurify 清洗 + highlight 代码高亮

https://md.netnr.com

变更日志

Install 安装

<div>
    <div id="editor">Loading ...</div>
</div>

<!--jquery-->
<script src="https://code.bdstatic.com/npm/jquery@3.5.0/dist/jquery.min.js"></script>

<!--Monaco Editor 加载器-->
<script src="https://code.bdstatic.com/npm/monaco-editor@0.20.0/min/vs/loader.js"></script>

<!--netnrmd-->
<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 () {
        //初始化 netnrmd
        window.nmd = new netnrmd('#editor');
    });
</script>

Options 选项

var nmd = new netnrmd('#editor', {
	//视图,1输入,2分屏,3预览,默认2
	viewmodel: 2

    //编辑器字体大小
    fontsize: 16,

	//高度
    height: 300,
	//延迟解析(毫秒)
    defer: 300,

	//自动保存键,默认netnrmd_markdown,一个页面有多netnrmd编辑器时需要对应配置
	storekey: "key",
	//默认有变化自动保存
	autosave: true,

	//按键支持
    prefixkey: 'Ctrl+',

    //Before rendering the callback
    //渲染前回调
    viewbefore: function () {
		console.log(this);
    },

    //Markdown editor changes when callback
    //编辑器变动时回调
    input: function () {
        console.log(this);
    },

    //Trigger command callback
	//触发命令回调
    cmdcallback: function (cmd) {
        console.log(this);
    }
});

Function 方法

var nmd = new netnrmd('#editor');
console.log(nmd);

//focus 焦点选中
nmd.focus();

//set height 设置高度
nmd.height(200);

//toggle View 视图切换,默认2、1、3循环
nmd.toggleView();
//输入
nmd.toggleView(1);
//分屏
nmd.toggleView(2);
//预览
nmd.toggleView(3);

//set markdown 赋值
nmd.setmd(md);

//get markdown 取值
nmd.getmd();

//set html 赋值
nmd.sethtml(html);

//get html 取值
nmd.gethtml();

//clear markdown&html 清空
nmd.clear();

//render 渲染
nmd.render();

//hide 隐藏
nmd.hide();
//hide 工具条
nmd.hide('toolbar');

//show 显示
nmd.show();
//show 工具条
nmd.show('toolbar');

//set store 写入本地保存
nmd.setstore();

//get store 获取本地保存
nmd.getstore();
MIT License Copyright (c) 2018 netnr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

NetnrMD编辑器(jQuery + Monaco Editor 编辑器 + Marked 解析 + DOMPurify 清洗 + highlight 代码高亮) 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/cocoa_flavor/netnrmd.git
git@gitee.com:cocoa_flavor/netnrmd.git
cocoa_flavor
netnrmd
netnrmd
master

搜索帮助