Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hsiaoming Yang
Steven Skoczen, @skoczen
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The `Editor` Class accepts an option as the parameter. The supported options are

* element (DOM)

The element of the textarea. The default value is the first `<textarea>`.
The DOM element of the textarea, or a string selector. The default value is the first `<textarea>`.

* tools (array or false)

Expand All @@ -99,7 +99,7 @@ Example:
```JavaScript
new Editor({
element: '#editor',
tools: false
toolbar: false
})
```

Expand Down
10 changes: 8 additions & 2 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ function Editor(options) {
options = options || {};

if (options.element) {
this.element = options.element;
if (typeof(options.element) == "string") {
this.element = document.querySelector(options.element);
} else {
this.element = options.element;
}
}

options.toolbar = options.toolbar || Editor.toolbar;
// you can customize toolbar with object
// [{name: 'bold', shortcut: 'Ctrl-B', className: 'icon-bold'}]
if (!options.hasOwnProperty('toolbar')) {
options.toolbar = Editor.toolbar;
}

if (!options.hasOwnProperty('status')) {
options.status = ['lines', 'words', 'cursor'];
Expand Down