Skip to content

Particular lines readonly #259

@andrebnassis

Description

@andrebnassis

Is there any sample that shows how to set some lines as readonly, so it can't be edited?

I found something related to markText and beforeChange, but I couldn't solve it yet using @uiw/react-codemirror package.

https://stackoverflow.com/questions/17415100/codemirror-particular-lines-readonly

Thanks in advance!

PS: If possible, use the getting started sample as base and set only the first line as readonly:

import CodeMirror from '@uiw/react-codemirror';
import { javascript } from '@codemirror/lang-javascript';

const CodeEditor = () => {
  
  return (
    <CodeMirror
      value="console.log('hello world!');"
      height="200px"
      extensions={[javascript({ jsx: true })]}
      onChange={(value, viewUpdate) => {
        console.log('value:', value);
        console.log(viewUpdate);
      }}
      theme={'dark'}
    />
  );
}

export default CodeEditor;

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