compose-formatblock
v0.2.0
Published
A block formatting plugin for Compose
Downloads
6
Readme
Compose-formatblock
A block formatting plugin for the Compose editor.
Usage
This plugin is consumed like any other Compose plugin:
var formatBlock = require('compose-formatblock'),
Compose = require('compose-editor')
var editor = new Compose('#someElement')
editor.use(formatBlock)
By default, this plugin adds support for the following elements: H2
, H3
, and PRE
. To support a wider range of elements, pass in an array of (lowercase) tag names as a second parameter to Compose#use
:
editor.use(formatBlock, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
With the above configuration, all types of headings will be supported. Note: passing in a custom list of allowed elements completely replaces the default list. Since pre
was not included in the above example, PRE
elements would not be supported.
API
// This plugin exports its functionality as “format-block”:
var block = editor.require('format-block')
// Check if all selected paragraphs have the given type.
// If none are selected, this is vacuously true.
var areAllH2 = block.status('h2')
// Converts all selected paragraphs to the given type.
// Partially selected paragraphs are also converted.
// If no paragraphs are selected, calling this method does nothing.
block.exec('pre')
License
MIT.