facebookarchive / draft-js

A React framework for building text editors.

Home Page:https://draftjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why draftInlineStyleType only can be default type?

chenjiashrimp opened this issue · comments

I defined editorStyleMap and use them
const editorStyleMap = { Choose: { color: '#4880f0' }, Black: { color: '#000000' } }
then I get the array of inlineStyleRanges
const messageBlocks=convertToRaw(editorState.getCurrentContent()).blocks[0].inlineStyleRanges;
i console every item of the array and the result is below,
item's style can be 'Choose' or 'Black'

{offset: 3, length: 3, style: 'Choose'}
{offset: 6, length: 5, style: 'Black'}
{offset: 11, length: 3, style: 'Choose'}
{offset: 14, length: 1, style: 'Black'}

but when i want to use if to judge the type of style
if(item.style==='Choose')

terminal reports an error 'This condition will always return 'false' since the types 'DraftInlineStyleType' and '"Choose"' have no overlap.'
it seems that styleType only can be default type like 'BOLD' and 'ITALIC'.

i don't know why??? if you could help me, i would be grateful:)

i use a strange way to solve that.
use String() to convert style to string type, and it can be 'Choose' or 'Black'