logorifma
v1.1.0
Published
Simple markdown editor for textareas
Downloads
14
Maintainers
Readme
logorifma
Simple markdown editor for textareas, without a UI.
Install
$ npm i logorifma
Usage
import logorifma from 'logorifma';
const textarea = document.querySelector('textarea');
const editor = new logorifma(textarea);
editor.insert('Hello world!');
editor.range([0, 5]);
editor.format('bold');
assert(textarea.value == '**Hello** world!');
editor.unformat('bold');
editor.format('italic');
assert(textarea.value == '_Hello_ world!');
For an example with a UI, see the example
folder.
All default formats are exposed, and can easily be modified to fit your application (e.g. adding a UI for browsing images).
You can also use custom formats directly:
editor.format({ prefix: '#{', suffix: '}' });
assert(textarea.value == '#{Hello world!}');
For example formats, check out the source code.
License
MIT