Handles Shift + Enter keypress removing selection and inserting a line break. https://github.com/jpuri/draftjs-utils/blob/112bbe449cc9156522fcf2b40f2910a071b795c2/js/block.js#L133
Applies an inline style on a given range, based on a Markdown shortcut, removing the Markdown markers. Supports adding styles on existing styles, and entities.
Creates a selection on a given entity in the currently selected block. Returns the current selection if no entity key is provided, or if the entity could not be found.
Optional
entityKey: stringGet an entity decorator strategy based on the given entity type. This strategy will find all entities of the given type.
Returns the first selected block.
Returns the entity applicable to whole of current selection. An entity can not span multiple blocks. https://github.com/jpuri/draftjs-utils/blob/e81c0ae19c3b0fdef7e0c1b70d924398956be126/js/inline.js#L75
Handles pressing delete within an atomic block. This can happen when selection is placed on an image. Ideally this should be handled by the built-in RichUtils, but it's not. See https://github.com/wagtail/wagtail/issues/4370.
Handles hard newlines. https://github.com/jpuri/draftjs-utils/blob/e81c0ae19c3b0fdef7e0c1b70d924398956be126/js/keyPress.js#L17
Handles three scenarios:
Inserts new unstyled block. Initially inspired from https://github.com/jpuri/draftjs-utils/blob/e81c0ae19c3b0fdef7e0c1b70d924398956be126/js/block.js#L153, but changed so that the split + block type reset amounts to only one change in the undo stack.
Removes the block at the given key.
Removes a block-level entity, turning the block into an empty paragraph, and placing the selection on it.
Changes a block type to be newType
, setting its new text.
Also removes the required characters from the characterList,
and resets block data.
Optional
newType: stringOptional
newText: stringOptional
newData: { [key: string]: unknown }Updates a given atomic block's entity, merging new data with the old one.
Inserts a horizontal rule in the place of the current selection. Returns updated EditorState. Inspired by DraftUtils.addLineBreakRemovingSelection.