Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

why draftInlineStyleType only can be default type? #3173

Closed
chenjiashrimp opened this issue Oct 11, 2022 · 1 comment
Closed

why draftInlineStyleType only can be default type? #3173

chenjiashrimp opened this issue Oct 11, 2022 · 1 comment

Comments

@chenjiashrimp
Copy link

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:)

@chenjiashrimp
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant