Modular state modifiers for Draft.js
yarn add draft-js-modifiers
# or
npm i draft-js-modifiers
import * as Modifiers from 'draft-js-modifiers'
const newEditorState = Modifiers.mergeBlockData(currentEditorState, { foo: 1 })
import adjustBlockDepth from 'draft-js-modifiers/adjustBlockDepth'
// Support Tree Shaking for webpack, rollup.js
import { insertText } from 'draft-js-modifiers'
adjustBlockDepth(editorState: EditorState, adjustment: number, maxDepth: number)
insertAtomicBlock(
editorState: EditorState,
entityType: string,
mutability: 'IMMUTABLE' | 'MUTABLE' | 'SEGMENTED',
data?: { [id: string]: any },
character?: ?string = ' '
)
insertEmptyBlock(editorState: EditorState, blockType?: DraftBlockType = 'unstyled')
insertNewBlock(
editorState: EditorState,
blockType?: DraftBlockType = 'unstyled',
text?: string = '',
data?: { [id: string]: any } = {}
)
insertText(editorState: EditorState, text: string, entity?: ?string = null)
mergeBlockData(editorState: EditorState, data: { [id: string]: any })
mergeBlockDataByKey(editorState: EditorState, blockKey: string, data: { [id: string]: any })
mergeEntityData(editorState: EditorState, entityKey: string, data: { [id: string]: any })
modifyBlock(editorState: EditorState, blockData: ContentBlock)
modifyBlockByKey(editorState: EditorState, blockKey: string, blockData: ContentBlock)
removeBlockStyle(editorState: EditorState)
removeInlineStyles(editorState: EditorState, inlineStyles: Array<string> = [])
resetBlock(editorState: EditorState, block: ContentBlock)
toggleBlockType(editorState: EditorState, blockType: string)
toggleEntity(editorState: EditorState, entityKey: ?string)
toggleInlineStyle(editorState: EditorState, inlineStyle: string)
yarn run add -- moduleName
# or
npm run add -- moduleName
© sugarshin