Draft js get plain text1/9/2024 The function will handle newline event in editor gracefully, it will insert \n for soft-new lines and remove selected text if any. Entity can not span multiple Blocks, method will check only first selected Block. The function will return the range of given Entity in currently selected Block. The function will return the Entity of current selection. The function will return map of block types Block Type -> HTML Tag. The function will return map of block data of current block. The function will add block level meta-data. The function will return only those styles that are applicable to whole selection. The function will return inline style applicable to current selection. The function will clear all content from the Editor. The function will add a new unstyled Block and copy current selection to it. The function will replace currently selected text with a \n. ![]() The function will return plain text of current selection. The function will reset the type of selected Blocks to unstyled. It will return undefined if not all selected Blocks have same type. ![]() The function will return the type of currently selected Blocks. The data type of returned objects is ContentBlock. The function will return all the Blocks of the editor. The data type of returned object is ContentBlock. The function will return block just before the selected block(s). The function will return first of currently selected Blocks, this is more useful when we expect user to select only one Block. ![]() The function will return an Immutable List of currently selected Blocks. The key is key of Block and value is ContentBlock. The function will return an Immutable OrderedMap of currently selected Blocks. Many of the functions described use ImmutableJS. I am open-sourcing them so that others can also leverage. I wrote a couple of utility functions for myself which I can re-use across my projects. DraftJS is very nice library for creating editors. I have been using DraftJS in few of my projects. An collection of useful utility functions for DraftJS.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |