Search code examples
javascriptdraftjs

Is there any way to get the style under cusor in draft.js?


enter image description here

As you can see, the cursor is within bold characters, so the next character would be bold too. The editor noticed it and activated the bold button on the toolbar.

How can I check the style under cursor in draft.js, just like the above one?


Solution

  • I just found out that I could check the style using a one-liner. It works whether there's a selection or not.

    editorState.getCurrentInlineStyle().has(style);