A typographical logo of Contenido.

Get block type

You can find the block type of the currently focused or selected block. This is list of default block types provided by draft-js. You can find the relevant utility for each one in the documentation.

  • unstyled
  • header-1 to header-6
  • unordered-list-item
  • ordered-list-item
  • blockquote
  • code-block
  • atomic

getBlockType #

To find out what is the type of the selected or focused block use getBlockType utility:

hasBlockTypeOf #

The hasBlockTypeOf utility will check to see if the current block has the type that you've passed to it or not. The returned value will be updated on block changes.

This utility will be useful whenever you have a custom block type and need to update the styles of the toggler button.

Example #

An example of getBlockType usage:



Made with ❤ for a better experience

MIT © 2023 - This site does not track you.