CB-5212 adjust readonly behaviour (#3237)

Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
alex
2025-02-06 19:31:17 +08:00
committed by GitHub
co-authored by Evgenia
parent 107436a8c0
commit 408565ee64
@@ -42,7 +42,13 @@ export const ReactCodemirror = observer<IReactCodeMirrorProps, IEditorRef>(
) {
value = value ?? getValue?.();
const currentExtensions = useRef<Map<Compartment, Extension>>(new Map());
const readOnlyFacet = useMemo(() => EditorView.editable.of(!readonly), [readonly]);
const readOnlyFacet = useMemo(() => {
if (readonly) {
return [EditorState.readOnly.of(true), EditorView.editable.of(false), EditorView.contentAttributes.of({ tabIndex: '0' })];
}
return [];
}, [readonly]);
const eventHandlers = useMemo(
() =>
EditorView.domEventHandlers({