Skip to content

Commit

Permalink
fix: #130 do not open mobile keyboard when the editor is readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 12, 2022
1 parent 861f36d commit 1c669fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/components/modes/textmode/TextMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
let validationErrors: ValidationError[] = []
const linterCompartment = new Compartment()
const editableCompartment = new Compartment() // needed to prevent a mobile keyboard from opening when readonly
const readOnlyCompartment = new Compartment()
const indentUnitCompartment = new Compartment()
const tabSizeCompartment = new Compartment()
Expand Down Expand Up @@ -468,6 +469,7 @@
top: true
}),
readOnlyCompartment.of(EditorState.readOnly.of(readOnly)),
editableCompartment.of(EditorView.editable.of(!readOnly)),
tabSizeCompartment.of(EditorState.tabSize.of(tabSize)),
indentUnitCompartment.of(createIndentUnit(indentation)),
EditorView.lineWrapping
Expand Down Expand Up @@ -661,7 +663,10 @@
debug('updateReadOnly', readOnly)
codeMirrorView.dispatch({
effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(readOnly))
effects: [
readOnlyCompartment.reconfigure(EditorState.readOnly.of(readOnly)),
editableCompartment.reconfigure(EditorView.editable.of(!readOnly))
]
})
}
}
Expand Down

0 comments on commit 1c669fa

Please sign in to comment.