Make textarea a markdown editor.
npm install textarea-markdown
Make textarea a markdown editor.
```
$ npm install textarea-markdown
`htmlEditor
`javascript
import TextareaMarkdown from 'textarea-markdown'let textarea = document.querySelector('textarea');
new TextareaMarkdown(textarea);
`with rails.
`html
``javascript
import TextareaMarkdown from 'textarea-markdown'document.addEventListener('DOMContentLoaded', () => {
const token = document.querySelector("meta[name=\"csrf-token\"]").content;
const textarea = document.querySelector('#editor');
new TextareaMarkdown(textarea, {
endPoint: '/api/image.json',
paramName: 'file',
responseKey: 'url',
csrfToken: token,
placeholder: 'uploading %filename ...',
uploadImageTag: '
\n',
})
});
`$3
#### useUploader
- type: Boolean
- default: true
Enable uploading files on drop when the value is set to true
#### file upload by file selection dialog
Enable uploading files by file selection dialog when using
as in the following code`html
Editor & File input
Preview
``javascript
import TextareaMarkdown from 'textarea-markdown'let textarea = document.querySelector('textarea');
new TextareaMarkdown(textarea);
`#### plugins
- type: Array
- default: []
An array of Markdown-It plugins to apply.
Each plugin can be either:
- a function (plugin)
- or an array like
[plugin, option1, option2, ...]Example
`javascript
import TextareaMarkdown from 'textarea-markdown'
import markdownItEmoji from 'markdown-it-emoji'
import markdownItSub from 'markdown-it-sub'new TextareaMarkdown(textarea, {
plugins: [
markdownItEmoji,
[markdownItSub, { delimiter: '~' }]
]
})
``