How get highlight text in react-codemirror

408 Views Asked by At

I'm using react-codemirror to render input with highlighted one letter. But I can't find how to mark text in CodeMirror component.

I tried

  const refs = useRef(null);
  useEffect(() => {
    if (refs.current?.view) {
       refs.current?.view.markText({
         from: 0, to:1
       });
     }
  }, [refs.current])

 return <CodeMirror
    ref={refs}
    basicSetup = {{
      lineNumbers: false,
    }}
    onChange={(value, viewUpdate) => {
      console.log("value:", value);
    }}
  /

I want achieve: aTest bTest cTest where a b c are red for example

0

There are 0 best solutions below