Modular state modifiers for Draft.js
npm install draft-js-modifiers[![CircleCI][circleci-image]][circleci-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![npm version][npm-image]][npm-url]
[![License][license-image]][license-url]
Modular state modifiers for Draft.js
``bash
yarn add draft-js-modifiers
npm i draft-js-modifiers
`
`js
import * as Modifiers from 'draft-js-modifiers'
const newEditorState = Modifiers.mergeBlockData(currentEditorState, { foo: 1 })
`
`js
import adjustBlockDepth from 'draft-js-modifiers/adjustBlockDepth'
// Support Tree Shaking for webpack, rollup.js
import { insertText } from 'draft-js-modifiers'
`
`js`
adjustBlockDepth(editorState: EditorState, adjustment: number, maxDepth: number)
`js`
insertAtomicBlock(
editorState: EditorState,
entityType: string,
mutability: 'IMMUTABLE' | 'MUTABLE' | 'SEGMENTED',
data?: { [id: string]: any },
character?: ?string = ' '
)
`js`
insertEmptyBlock(editorState: EditorState, blockType?: DraftBlockType = 'unstyled')
`js`
insertNewBlock(
editorState: EditorState,
blockType?: DraftBlockType = 'unstyled',
text?: string = '',
data?: { [id: string]: any } = {}
)
`js`
insertText(editorState: EditorState, text: string, entity?: ?string = null)
`js`
mergeBlockData(editorState: EditorState, data: { [id: string]: any })
`js`
mergeBlockDataByKey(editorState: EditorState, blockKey: string, data: { [id: string]: any })
`js`
mergeEntityData(editorState: EditorState, entityKey: string, data: { [id: string]: any })
`js`
modifyBlock(editorState: EditorState, blockData: ContentBlock)
`js`
modifyBlockByKey(editorState: EditorState, blockKey: string, blockData: ContentBlock)
`js`
removeBlockStyle(editorState: EditorState)
`js`
removeInlineStyles(editorState: EditorState, inlineStyles: Array
`js`
resetBlock(editorState: EditorState, block: ContentBlock)
`js`
toggleBlockType(editorState: EditorState, blockType: string)
`js`
toggleEntity(editorState: EditorState, entityKey: ?string)
`js`
toggleInlineStyle(editorState: EditorState, inlineStyle: string)
`bash
yarn run add -- moduleName
npm run add -- moduleName
``
[MIT][license-url]
© sugarshin
[circleci-image]: https://circleci.com/gh/sugarshin/draft-js-modifiers/tree/master.svg?style=svg&circle-token=f80707ebb99977ec63649c41cb76202f05aa75e1
[circleci-url]: https://circleci.com/gh/sugarshin/draft-js-modifiers/tree/master
[coveralls-image]: https://coveralls.io/repos/github/sugarshin/draft-js-modifiers/badge.svg?branch=master
[coveralls-url]: https://coveralls.io/github/sugarshin/draft-js-modifiers?branch=master
[npm-image]: https://img.shields.io/npm/v/draft-js-modifiers.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/draft-js-modifiers
[license-image]: https://img.shields.io/:license-mit-blue.svg?style=flat-square
[license-url]: https://sugarshin.mit-license.org/