Inserts a horizontal rule in the place of the current selection. Returns updated EditorState. Inspired by DraftUtils.addLineBreakRemovingSelection.
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.
OptionalentityKey: 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.
OptionalnewType: stringOptionalnewText: stringOptionalnewData: { [key: string]: unknown }Updates a given atomic block's entity, merging new data with the old one.
Initializes the DraftailEditor for a given field.
Client-side editor-specific equivalent to register_editor_plugin.
optionName defaults to entityTypes for backwards-compatibility with
previous function signature only allowing registering entities.
A tooltip, with arbitrary content.
Inspired by draftjs-utils, with our custom functions.
DraftUtils functions are utility helpers useful in isolation, specific to the Draft.js API, without ties to Draftail's specific behavior or other APIs.