-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
First of all, thanks for this library!
I just had a small hiccup using createEditorReadonly along with
import { search, searchKeymap } from "@codemirror/search";
createExtension(() => [search(), keymap.of(searchKeymap)]);Where the search would not show up in my "read-only" views.
The docs for state.EditorState^readOnly call out
Not to be confused with EditorView.editable, which controls whether the editor's DOM is set to be editable (and thus focusable).
So, for me, the fix was to replace my use of createEditorReadonly with codemirror's EditorState.readOnly which allows focus and allows command-F to bring up the search panel.
createExtension(() => props.readonly ? EditorState.readOnly.of(true) : undefined);I'm kind of thinking that createEditorReadonly should be deprecated and users should be encouraged to do the following instead?
createExtension(() => props.readonly ? EditorState.editable.of(false) : undefined);( Unless there's some edge case in the behavior I'm not aware of that createEditorReadonly is solving. )
TL;DR
createEditorReadonlysets editable=false, which is confusing/mislabled because "read only" and "not editable" are two different concepts for codemirror.createEditorReadonlyseems to be an unnecessary entrypoint into the library, replaceable with a note in the documentation.
Metadata
Metadata
Assignees
Labels
No labels