Skip to content

Commit 0e76f96

Browse files
committed
Update README.md
1 parent 540d901 commit 0e76f96

File tree

1 file changed

+180
-31
lines changed

1 file changed

+180
-31
lines changed

README.md

Lines changed: 180 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,59 +40,208 @@
4040
- 支持 AMD / CMD 模块化加载(支持 [Require.js](https://pandao.github.io/editor.md/examples/use-requirejs.html) & [Sea.js](https://pandao.github.io/editor.md/examples/use-seajs.html)),并且支持[自定义扩展插件](https://pandao.github.io/editor.md/examples/define-plugin.html)
4141
- 兼容主流的浏览器(IE8+)和 [Zepto.js](https://pandao.github.io/editor.md/examples/use-zepto.html),且支持 iPad 等平板设备;
4242

43-
#### Examples
43+
#### Download & install
44+
45+
Download:
4446

45-
[https://pandao.github.io/editor.md/examples/index.html](https://pandao.github.io/editor.md/examples/index.html)
47+
[Github download](https://github.com/pandao/editor.md/archive/master.zip)
4648

47-
#### Download & install
49+
NPM install :
4850

49-
[Github download](https://github.com/pandao/editor.md/archive/master.zip)
51+
```bash
52+
npm install editor.md
53+
```
5054

5155
Bower install :
5256

53-
```shell
57+
```bash
5458
bower install editor.md
5559
```
5660

57-
#### Usages
58-
59-
HTML:
61+
#### Usages
62+
63+
##### Create a Markdown editor
6064

6165
```html
62-
<link rel="stylesheet" href="editormd.min.css" />
63-
<div id="editormd">
66+
<link rel="stylesheet" href="editor.md/css/editormd.min.css" />
67+
<div id="editor">
68+
<!-- Tips: Editor.md can auto append a `<textarea>` tag -->
6469
<textarea style="display:none;">### Hello Editor.md !</textarea>
6570
</div>
66-
```
67-
68-
> Tip: Editor.md can auto append `<textarea>` tag;
69-
70-
javascript:
71-
72-
```html
7371
<script src="jquery.min.js"></script>
74-
<script src="editormd.min.js"></script>
72+
<script src="editor.md/editormd.min.js"></script>
7573
<script type="text/javascript">
7674
$(function() {
77-
var editor = editormd("editormd", {
78-
path : "../lib/" // Autoload modules mode, codemirror, marked... dependents libs path
75+
var editor = editormd("editor", {
76+
// width: "100%",
77+
// height: "100%",
78+
// markdown: "xxxx", // dynamic set Markdown text
79+
path : "editor.md/lib/" // Autoload modules mode, codemirror, marked... dependents libs path
7980
});
80-
81-
/*
82-
// or
83-
var editor = editormd({
84-
id : "editormd",
85-
path : "../lib/"
86-
});
87-
*/
8881
});
8982
</script>
9083
```
9184

92-
Using modular script loader :
85+
If you using modular script loader:
9386

9487
- [Using Require.js](https://github.com/pandao/editor.md/tree/master/examples/use-requirejs.html)
95-
- [Using Sea.js](https://github.com/pandao/editor.md/tree/master/examples/use-seajs.html)
88+
- [Using Sea.js](https://github.com/pandao/editor.md/tree/master/examples/use-seajs.html)
89+
90+
##### Markdown to HTML
91+
92+
```html
93+
<link rel="stylesheet" href="editormd/css/editormd.preview.css" />
94+
<div id="test-markdown-view">
95+
<!-- Server-side output Markdown text -->
96+
<textarea style="display:none;">### Hello world!</textarea>
97+
</div>
98+
<script src="jquery.min.js"></script>
99+
<script src="editormd/editormd.js"></script>
100+
<script src="editormd/lib/marked.min.js"></script>
101+
<script src="editormd/lib/prettify.min.js"></script>
102+
<script type="text/javascript">
103+
$(function() {
104+
var testView = editormd.markdownToHTML("test-markdown-view", {
105+
// markdown : "[TOC]\n### Hello world!\n## Heading 2", // Also, you can dynamic set Markdown text
106+
// htmlDecode : true, // Enable / disable HTML tag encode.
107+
// htmlDecode : "style,script,iframe", // Note: If enabled, you should filter some dangerous HTML tags for website security.
108+
});
109+
});
110+
</script>
111+
```
112+
113+
> See the full example: [http://editor.md.ipandao.com/examples/html-preview-markdown-to-html.html](http://editor.md.ipandao.com/examples/html-preview-markdown-to-html.html)
114+
115+
##### HTML to Markdown?
116+
117+
Sorry, Editor.md not support HTML to Markdown parsing, Maybe In the future.
118+
119+
#### Examples
120+
121+
[https://pandao.github.io/editor.md/examples/index.html](https://pandao.github.io/editor.md/examples/index.html)
122+
123+
#### Options
124+
125+
Editor.md options and default values:
126+
127+
```javascript
128+
{
129+
mode : "gfm", // gfm or markdown
130+
name : "", // Form element name for post
131+
value : "", // value for CodeMirror, if mode not gfm/markdown
132+
theme : "", // Editor.md self themes, before v1.5.0 is CodeMirror theme, default empty
133+
editorTheme : "default", // Editor area, this is CodeMirror theme at v1.5.0
134+
previewTheme : "", // Preview area theme, default empty
135+
markdown : "", // Markdown source code
136+
appendMarkdown : "", // if in init textarea value not empty, append markdown to textarea
137+
width : "100%",
138+
height : "100%",
139+
path : "./lib/", // Dependents module file directory
140+
pluginPath : "", // If this empty, default use settings.path + "../plugins/"
141+
delay : 300, // Delay parse markdown to html, Uint : ms
142+
autoLoadModules : true, // Automatic load dependent module files
143+
watch : true,
144+
placeholder : "Enjoy Markdown! coding now...",
145+
gotoLine : true, // Enable / disable goto a line
146+
codeFold : false,
147+
autoHeight : false,
148+
autoFocus : true, // Enable / disable auto focus editor left input area
149+
autoCloseTags : true,
150+
searchReplace : true, // Enable / disable (CodeMirror) search and replace function
151+
syncScrolling : true, // options: true | false | "single", default true
152+
readOnly : false, // Enable / disable readonly mode
153+
tabSize : 4,
154+
indentUnit : 4,
155+
lineNumbers : true, // Display editor line numbers
156+
lineWrapping : true,
157+
autoCloseBrackets : true,
158+
showTrailingSpace : true,
159+
matchBrackets : true,
160+
indentWithTabs : true,
161+
styleSelectedText : true,
162+
matchWordHighlight : true, // options: true, false, "onselected"
163+
styleActiveLine : true, // Highlight the current line
164+
dialogLockScreen : true,
165+
dialogShowMask : true,
166+
dialogDraggable : true,
167+
dialogMaskBgColor : "#fff",
168+
dialogMaskOpacity : 0.1,
169+
fontSize : "13px",
170+
saveHTMLToTextarea : false, // If enable, Editor will create a <textarea name="{editor-id}-html-code"> tag save HTML code for form post to server-side.
171+
disabledKeyMaps : [],
172+
173+
onload : function() {},
174+
onresize : function() {},
175+
onchange : function() {},
176+
onwatch : null,
177+
onunwatch : null,
178+
onpreviewing : function() {},
179+
onpreviewed : function() {},
180+
onfullscreen : function() {},
181+
onfullscreenExit : function() {},
182+
onscroll : function() {},
183+
onpreviewscroll : function() {},
184+
185+
imageUpload : false, // Enable/disable upload
186+
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
187+
imageUploadURL : "", // Upload url
188+
crossDomainUpload : false, // Enable/disable Cross-domain upload
189+
uploadCallbackURL : "", // Cross-domain upload callback url
190+
191+
toc : true, // Table of contents
192+
tocm : false, // Using [TOCM], auto create ToC dropdown menu
193+
tocTitle : "", // for ToC dropdown menu button
194+
tocDropdown : false, // Enable/disable Table Of Contents dropdown menu
195+
tocContainer : "", // Custom Table Of Contents Container Selector
196+
tocStartLevel : 1, // Said from H1 to create ToC
197+
htmlDecode : false, // Open the HTML tag identification
198+
pageBreak : true, // Enable parse page break [========]
199+
atLink : true, // for @link
200+
emailLink : true, // for email address auto link
201+
taskList : false, // Enable Github Flavored Markdown task lists
202+
emoji : false, // :emoji: , Support Github emoji, Twitter Emoji (Twemoji);
203+
// Support FontAwesome icon emoji :fa-xxx: > Using fontAwesome icon web fonts;
204+
// Support Editor.md logo icon emoji :editormd-logo: :editormd-logo-1x: > 1~8x;
205+
tex : false, // TeX(LaTeX), based on KaTeX
206+
flowChart : false, // flowChart.js only support IE9+
207+
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
208+
previewCodeHighlight : true, // Enable / disable code highlight of editor preview area
209+
210+
toolbar : true, // show or hide toolbar
211+
toolbarAutoFixed : true, // on window scroll auto fixed position
212+
toolbarIcons : "full", // Toolbar icons mode, options: full, simple, mini, See `editormd.toolbarModes` property.
213+
toolbarTitles : {},
214+
toolbarHandlers : {
215+
ucwords : function() {
216+
return editormd.toolbarHandlers.ucwords;
217+
},
218+
lowercase : function() {
219+
return editormd.toolbarHandlers.lowercase;
220+
}
221+
},
222+
toolbarCustomIcons : { // using html tag create toolbar icon, unused default <a> tag.
223+
lowercase : "<a href=\"javascript:;\" title=\"Lowercase\" unselectable=\"on\"><i class=\"fa\" name=\"lowercase\" style=\"font-size:24px;margin-top: -10px;\">a</i></a>",
224+
"ucwords" : "<a href=\"javascript:;\" title=\"ucwords\" unselectable=\"on\"><i class=\"fa\" name=\"ucwords\" style=\"font-size:20px;margin-top: -3px;\">Aa</i></a>"
225+
},
226+
toolbarIconTexts : {},
227+
228+
lang : { // Language data, you can custom your language.
229+
name : "zh-cn",
230+
description : "开源在线Markdown编辑器<br/>Open source online Markdown editor.",
231+
tocTitle : "目录",
232+
toolbar : {
233+
//...
234+
},
235+
button: {
236+
//...
237+
},
238+
dialog : {
239+
//...
240+
}
241+
//...
242+
}
243+
}
244+
```
96245

97246
#### Dependents
98247

@@ -116,4 +265,4 @@ Using modular script loader :
116265

117266
The MIT License.
118267

119-
Copyright (c) 2015 Pandao
268+
Copyright (c) 2015-2019 Pandao

0 commit comments

Comments
 (0)