mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 21:23:45 -05:00
Merge pull request #12631 from overleaf/ae-readonly-focus
[cm6] Prevent the editor being focused when read-only GitOrigin-RevId: 7de9f2df2421b57b3315d59d640f7c8b46caf178
This commit is contained in:
parent
c2292a8567
commit
59b3b9b933
1 changed files with 13 additions and 2 deletions
|
@ -1,13 +1,24 @@
|
||||||
import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
|
import { Compartment, EditorState, TransactionSpec } from '@codemirror/state'
|
||||||
|
import { EditorView } from '@codemirror/view'
|
||||||
|
|
||||||
const readOnlyConf = new Compartment()
|
const readOnlyConf = new Compartment()
|
||||||
|
|
||||||
export const editable = () => {
|
export const editable = () => {
|
||||||
return [readOnlyConf.of(EditorState.readOnly.of(true))]
|
return [
|
||||||
|
readOnlyConf.of([
|
||||||
|
EditorState.readOnly.of(true),
|
||||||
|
EditorView.editable.of(false),
|
||||||
|
]),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setEditable = (value = true): TransactionSpec => {
|
export const setEditable = (value = true): TransactionSpec => {
|
||||||
return {
|
return {
|
||||||
effects: [readOnlyConf.reconfigure(EditorState.readOnly.of(!value))],
|
effects: [
|
||||||
|
readOnlyConf.reconfigure([
|
||||||
|
EditorState.readOnly.of(!value),
|
||||||
|
EditorView.editable.of(value),
|
||||||
|
]),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue