@djsp/utils
Utilities for draft js
Install
npm install --save @djsp/utils
Static Methods
replaceWithAtomicBlock
replaceWithAtomicBlock(
editorState: EditorState,
entityType: string,
data: Object
): EditorState
insertEntityBlock
insertEntityBlock(
editorState: EditorState,
entityType: string,
data: Object
): EditorState
createEntityDecorator
createEntityDecorator(
entityName: string,
component: Function,
props?: Object
): DraftDecorator
insertTextWithEntity
insertTextWithEntity(
contentState: ContentState,
selection: SelectionState,
entityType: string,
text: string,
mutability?: 'IMMUTABLE' | 'MUTABLE' | 'SEGMENTED',
entityData?: Object
): ContentState
createLinkAtSelection
createLinkAtSelection(
editorState: EditorState,
url: string
): EditorState
removeLinkAtSelection
removeLinkAtSelection(editorState: EditorState): EditorState
collapseToEnd
collapseToEnd(editorState: EditorState): EditorState
getCurrentEntityKey
getCurrentEntityKey(editorState: EditorState): ?string
createEntityStrategy
createEntityStrategy(entityType: string): (
contentBlock: ContentBlock,
callback: (start: number, end: number) => void,
contentState: ContentState
) => void
getCurrentEntity
getCurrentEntity(
editorState: EditorState
): ?DraftEntityInstance
getBlockEntityKey
getBlockEntityKey(
contentState: ContentState,
key: string
): ?string
hasEntity
hasEntity(
editorState: EditorState,
entityType: string
): boolean
insertNewLine
insertNewLine(editorState: EditorState): EditorState
License
MIT © juliankrispel