## Markdown編輯器
內部使用 [editor.md](https://pandao.github.io/editor.md/) 開源編輯器實現。
[TOC]
## 使用方法

~~~
<div id="editormd"><textarea name="content" hidden>初始內容</textarea></div>
<script>
require(['hdjs'], function (hdjs) {
hdjs.markdown("editormd", {
width: '100%',
heigth: 300,
callback:function(editormd){
//編輯器對象
console.log(editormd);
}
});
});
</script>
~~~
第二個參數是選項,可以根據需要自行設置其他選項
## 顯示內容
~~~
<script>
require(['hdjs', 'marked', 'highlight'], function (hdjs, marked) {
marked.setOptions({
renderer: new marked.Renderer(),
highlight: function (code) {
return hljs.highlightAuto(code).value;
},
pedantic: true,
gfm: true,
tables: true,
breaks: false,
sanitize: false,
smartLists: true,
smartypants: false,
xhtml: false
});
$('.markdown').each(function (i, md) {
$(md).html($.trim(marked($(md).find('textarea').val())));
})
hljs.initHighlightingOnLoad();
})
</script>
~~~
如果不能正常解析參考以下代碼(去除行首空白):
~~~
<div class="markdown">
<textarea hidden>{{ preg_replace('@(^\s*)@m','',$hdcms['content']) }}</textarea>
</div>
~~~
第三個參數為內容變量
## 替換內容
~~~
editormd.setSelection({line:0, ch:0}, {line:9999, ch:9999});
editormd.replaceSelection("");
~~~
editormd為編輯器對象,需要在callback中獲得
- 文檔已經遷移到后盾人
- 基礎知識
- 項目介紹
- 安裝配置
- 日期時間
- 日期選擇
- 列表框日期
- 日期區間
- 時間選擇
- moment
- 上傳處理
- 初始配置
- 圖片上傳
- 文件上傳
- 消息通知
- 消息通知
- Bootstrap消息
- izitoast
- SweetAlert
- 模態框
- 表單管理
- 異步請求
- 表單提交
- 表單驗證
- 擴展組件
- GET參數
- 剪貼板
- 表情選擇
- 圖表
- 拾色器
- 二維碼生成
- 光標控制
- 數據驗證
- md5
- 設備檢測
- Loading
- 預覽圖片
- 圖標庫
- COOKIE
- 百度地圖
- 城市選擇
- Vue.js
- jQuery
- axios
- 播放器
- 幻燈片
- 代碼高亮
- 阿里云OSS
- 驗證碼
- 頁面滾動
- lodash
- momentjs
- markdownIt
- 元素頁面固定
- 編輯器
- ueditor
- editor.md
- SimpleMDE
- simditor
- 自定義組件
- 1.0(舊版)
- 基礎知識
- 作者向軍
- 安裝配置
- 查看效果
- 元素樣式
- 日期時間
- 日期選擇
- 日期區間
- 時間選擇
- moment
- 上傳處理
- 圖片上傳
- 文件上傳
- 后臺處理
- 模態消息
- 模態
- notify
- bootstrap
- 表單管理
- 表單提交
- 表單驗證
- 表單樣式
- 擴展組件
- 自定義組件
- get參數
- 剪貼板
- 表情選擇
- 圖表
- 拾色器
- 二維碼生成
- 光標控制
- 數據驗證
- MD5
- loading
- 預覽圖片
- 圖標庫
- COOKIE
- 百度地圖
- 城市選擇
- Vuejs
- jQuery
- 播放器
- 幻燈片
- axios
- 代碼高亮
- 阿里云OSS
- 驗證碼
- 正則表達式
- 工具函數
- 編輯器
- 百度編輯器
- markdown
- simplemde-markdow