mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-19 23:50:50 +00:00
[cm6] Improve Tab behaviour in read-only mode (#12715)
* Improve Tab behaviour in read-only mode * Remove Tab shortcuts from Markdown configuration GitOrigin-RevId: 9eb804fcf820b37b371b1c351cfbdf7bff1ced89
This commit is contained in:
parent
08ccdb79d3
commit
4bb582bdd8
3 changed files with 3 additions and 13 deletions
|
@ -3,6 +3,9 @@ import { getIndentUnit, indentString, indentUnit } from '@codemirror/language'
|
||||||
import { EditorView } from '@codemirror/view'
|
import { EditorView } from '@codemirror/view'
|
||||||
|
|
||||||
export const indentMore = (view: EditorView) => {
|
export const indentMore = (view: EditorView) => {
|
||||||
|
if (view.state.readOnly) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
view.dispatch(
|
view.dispatch(
|
||||||
view.state.changeByRange(range => {
|
view.state.changeByRange(range => {
|
||||||
const doc = view.state.doc
|
const doc = view.state.doc
|
||||||
|
|
|
@ -43,12 +43,10 @@ export const shortcuts = () => {
|
||||||
const keyBindings: KeyBinding[] = [
|
const keyBindings: KeyBinding[] = [
|
||||||
{
|
{
|
||||||
key: 'Tab',
|
key: 'Tab',
|
||||||
preventDefault: true,
|
|
||||||
run: indentMore,
|
run: indentMore,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Shift-Tab',
|
key: 'Shift-Tab',
|
||||||
preventDefault: true,
|
|
||||||
run: indentLess,
|
run: indentLess,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Prec } from '@codemirror/state'
|
import { Prec } from '@codemirror/state'
|
||||||
import { keymap } from '@codemirror/view'
|
import { keymap } from '@codemirror/view'
|
||||||
import { wrapRanges } from '../../commands/ranges'
|
import { wrapRanges } from '../../commands/ranges'
|
||||||
import { indentLess, indentMore } from '@codemirror/commands'
|
|
||||||
|
|
||||||
export const shortcuts = () => {
|
export const shortcuts = () => {
|
||||||
return Prec.high(
|
return Prec.high(
|
||||||
|
@ -18,16 +17,6 @@ export const shortcuts = () => {
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: wrapRanges('_', '_'),
|
run: wrapRanges('_', '_'),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'Tab',
|
|
||||||
preventDefault: true,
|
|
||||||
run: indentMore,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Shift-Tab',
|
|
||||||
preventDefault: true,
|
|
||||||
run: indentLess,
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue