An open API service indexing awesome lists of open source software.

https://github.com/komagata/textarea-markdown

Make textarea a markdown editor.
https://github.com/komagata/textarea-markdown

markdown rails textarea

Last synced: 10 months ago
JSON representation

Make textarea a markdown editor.

Awesome Lists containing this project

README

          

# textarea-markdown

[![https://gyazo.com/5759ef553225cfa788adf3596b90e256](https://i.gyazo.com/5759ef553225cfa788adf3596b90e256.gif)](https://gyazo.com/5759ef553225cfa788adf3596b90e256)

Make textarea a markdown editor.

## Usage

```
$ npm install textarea-markdown
```

```html

Editor

Preview



```

```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: '%filename\n',
})
});
```

### Options

#### 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: '~' }]
]
})
```