项目作者: jimmycodesocial

项目描述 :
Useful goodies for DraftJS
高级语言: JavaScript
项目地址: git://github.com/jimmycodesocial/draft-js-toolbox.git
创建时间: 2018-06-10T01:40:52Z
项目社区:https://github.com/jimmycodesocial/draft-js-toolbox

开源协议:MIT License

下载


DraftJs Toolbox

Useful goodies for DraftJS.

Installation

  1. npm install @jimmycode/draft-js-toolbox

Usage

This library contains two sets of functions:

  1. Utilities: that determine certain conditions on the editor’s state.
  2. Modifiers: which perform transformations on the editor’s state.

Utils

  1. import { getCurrentBlock, isCurrentBlockType, isBlockWithEntityType } from '@jimmycode/draft-js-toolbox';
Function Params Description
getCurrentBlock editorState Returns the current block selected.
isCurrentBlockType editorState, blockType Checks the current block’s type.
isBlockWithEntityType editorState, block, entityType Checks if the current block is an atomic block with an specific entity type.

Modifiers

  1. import { addBlock, addAtomicBlock, removeBlock } from '@jimmycode/draft-js-toolbox';
Function Params Description
addBlock editorState, entityType, data Changes the current block’s type and replace its data.
addAtomicBlock editorState, entityType, data Inserts an atomic block and creates an Entity with custom data.
removeBlock editorState, blockKey Removes a block given its key.