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

how to stop the style i add in replaceText? #3176

Open
chenjiashrimp opened this issue Oct 21, 2022 · 0 comments
Open

how to stop the style i add in replaceText? #3176

chenjiashrimp opened this issue Oct 21, 2022 · 0 comments

Comments

@chenjiashrimp
Copy link

chenjiashrimp commented Oct 21, 2022

`(text: string, anchorOffset: number, focusOffset: number) => {
    const contentState = editorState.getCurrentContent()
    const selection = editorState.getSelection()
    const newSelection = selection.merge({
        anchorOffset: anchorOffset,
        focusOffset: focusOffset
    })
 
    let nextEditorState = EditorState.createEmpty()
    let nextContentState
   
    nextContentState = Modifier.replaceText(contentState, newSelection, text, OrderedSet.of('Blue'))
    nextEditorState = EditorState.push(editorState, nextContentState, 'insert-characters')

    setEditorState(nextEditorState);`

i want to use replaceText to replace partial text with blue font(i define a style called 'Blue').I only want blue text from 'anchorOffset' to 'focusOffset', But when i continue to enter the text, the text is always blue, not black. I do not know how to stop 'Blue' style.

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