Many new options during instantiation

pull/9/head
Wes Cossick 9 years ago
parent 9999fd93c1
commit 4ae1aa3874

@ -46,14 +46,24 @@ simplemde.codemirror.getValue();
## Configuration ## Configuration
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page. - **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
- **status**: If set false, hide the status bar. Defaults to true. - **status**: If set `false`, hide the status bar. Defaults to `true`.
- **toolbar**: If set false, hide the toolbar. Defaults to true. - **toolbar**: If set `false`, hide the toolbar. Defaults to `true`.
- **autofocus**: If set `true`, autofocuses the editor. Defaults to `false`.
- **lineWrapping**: If set `false`, disable line wrapping. Defaults to `true`.
- **lineNumbers**: If set `true`, shows line numbers. Defaults to `false`.
- **indentWithTabs**: If set `false`, indent using spaces instead of tabs. Defaults to `true`.
- **tabSize**: If set, customize the tab size. Defaults to `'2'`.
``` ```
new SimpleMDE({ new SimpleMDE({
element: document.getElementById("MyID"), element: document.getElementById("MyID"),
status: false, status: false,
toolbar: false, toolbar: false,
autofocus: true,
lineWrapping: false,
lineNumbers: true,
indentWithTabs: false,
tabSize: '4',
}); });
``` ```

@ -448,8 +448,8 @@ function SimpleMDE(options) {
options.toolbar = []; options.toolbar = [];
else else
options.toolbar = options.toolbar || SimpleMDE.toolbar; options.toolbar = options.toolbar || SimpleMDE.toolbar;
// you can customize toolbar with object // you can customize toolbar with object
// [{name: 'bold', shortcut: 'Ctrl-B', className: 'icon-bold'}] // [{name: 'bold', shortcut: 'Ctrl-B', className: 'icon-bold'}]
if (!options.hasOwnProperty('status')) { if (!options.hasOwnProperty('status')) {
options.status = ['lines', 'words', 'cursor']; options.status = ['lines', 'words', 'cursor'];
@ -512,12 +512,12 @@ SimpleMDE.prototype.render = function(el) {
this.codemirror = CodeMirror.fromTextArea(el, { this.codemirror = CodeMirror.fromTextArea(el, {
mode: 'markdown', mode: 'markdown',
theme: 'paper', theme: 'paper',
tabSize: '2', tabSize: (options.tabSize != undefined) ? options.tabSize : '2',
indentWithTabs: true, indentWithTabs: (options.indentWithTabs === false) ? false : true,
lineNumbers: false, lineNumbers: (options.lineNumbers === true) ? true : false,
autofocus: false, autofocus: (options.autofocus === true) ? true : false,
extraKeys: keyMaps, extraKeys: keyMaps,
lineWrapping: true lineWrapping: (options.lineWrapping === false) ? false : true
}); });
if (options.toolbar !== false) { if (options.toolbar !== false) {

Loading…
Cancel
Save