compose-lists
v0.2.0
Published
A list plugin for the Compose editor
Downloads
4
Readme
Compose-lists
A list plugin for the Compose editor.
Usage
Use this plugin like you would any other Compose plugin:
var listPlugin = require('compose-lists'),
Compose = require('compose-editor')
var editor = new Compose('#someElement')
editor.use(listPlugin)
API
All this plugin does is add support for LI
elements. The type
property of a serialized LI
is the type of the parent list (one of ol
or ul
), defaulting to ol
if the LI
has no parent or if the LI
is not the child of an OL
/UL
. To change a paragraph to a list, you might do something like:
var Delta = editor.require('delta'),
View = editor.require('view')
// We’re changing the paragraph at index 0 to an OL > LI
var paragraph = View.paragraphs[0].substr(0)
paragraph.type = 'ol'
View.resolve(new Delta('paragraphUpdate', 0, paragraph))
You might also want to consider using the block formatting plugin to more easily convert paragraphs between block types.
License
MIT.