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

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

Open

Description

@chenjiashrimp
`(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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions