acrodata / code-editor

📝 CodeMirror 6 wrapper for Angular
https://acrodata.github.io/code-editor/
MIT License
16 stars 1 forks source link

Ability to make the diff editor readonly #2

Closed gerbsen closed 4 weeks ago

gerbsen commented 1 month ago

hey there! the project here is absolutely awesome. I would really like to use it for my project. There is only one little issue. Is there any way to make the DiffEditor readOnly? I looked at the code, but couldn't figure out what to do. :(

nzbin commented 1 month ago

For CodeMirror 6, all features can be implemented with extensions. https://github.com/acrodata/code-editor/issues/1#issuecomment-2172475058

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';

extensions = [
  EditorState.readOnly.of(true),
  // or disable the editor
  // EditorView.editable.of(false)
];
<diff-editor [originalExtensions]="extensions"
             [modifiedExtensions]="extensions" />