Giter Site home page Giter Site logo

mdeditor's Introduction

简易Markdownd编辑器

##使用

预览MDEditor

  • 添加 MDEditor.min.css 样式
  • 添加 MDEditor.min.js 并不是 lib/MDEditor.js
  • 添加编辑器初始节点
  • 如果预加载长篇markdown文本必须嵌套 <textarea> 标签
<link rel="stylesheet" type="text/css" href="../themes/default/css/MDEditor.min.css">
<script type="text/javascript" src="../build/MDEditor.min.js"></script>
<div id="mdeditor">
<textarea># 这里放markdown初始值
- id: 节点id
- minheight: 初始化编辑器高度
- maxheight: 编辑器随着输入内容增多而变高,这个值是它的最大值
- value: 默认编辑器中显示markdown内容
</textarea>
</div>
<script type="text/javascript">
var mde = new MDEditor({
    id:"#mdeditor",
    minheight:300,
    maxheight:600,
    value:"#多多少少的"
}).load().input(function(evn,opts){
    console.log("evn:",evn)
    console.log("opts:",opts)
})
</script>

MDEditor初始化

  • id: 节点id
  • minheight: 初始化编辑器高度
  • maxheight: 编辑器随着输入内容增多而变高,这个值是它的最大值
  • value: 默认编辑器中显示markdown内容

load

加载编辑器

mde.load()  

preview

默认展示预览界面

mde.preview()  

input

输入事件,在编辑器里面输入内容就会执行input方法

mde.input(function(evn,opts){
    console.log("evn:",evn)
    console.log("opts:",opts)
})  

getMD

获取markdown的字符串

mde.getMD()  //=>返回markdown字符串

setMD

设置markdown的字符串

mde.setMD(val)  

getHTML

获取生成的HTML

mde.getMD()  //=>返回HTML字符串

setHTML

设置预览的HTML

mde.setHTML(val)  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.