mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #13607 from overleaf/ae-formatting-keymaps
[cm6] Use toggleRanges for bold/italic shortcuts in code editor GitOrigin-RevId: 90f7344876e84b984469ca2daccb7bbe71d89aa9
This commit is contained in:
parent
bd770e8a8c
commit
a716a500c5
3 changed files with 4 additions and 20 deletions
|
@ -268,9 +268,7 @@ function moveRange(range: SelectionRange, newFrom: number, newTo: number) {
|
||||||
|
|
||||||
function validateReplacement(expected: string, actual: string) {
|
function validateReplacement(expected: string, actual: string) {
|
||||||
if (expected !== actual) {
|
if (expected !== actual) {
|
||||||
throw new Error(
|
throw new Error('Replacement in toggleRange failed validation.')
|
||||||
`Replacement in toggleRange failed validation. Expected ${expected} got ${actual}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { keymap } from '@codemirror/view'
|
import { keymap } from '@codemirror/view'
|
||||||
import { EditorSelection, Prec } from '@codemirror/state'
|
import { EditorSelection, Prec } from '@codemirror/state'
|
||||||
import { ancestorNodeOfType } from '../../utils/tree-query'
|
import { ancestorNodeOfType } from '../../utils/tree-query'
|
||||||
import { toggleRanges } from '../../commands/ranges'
|
|
||||||
import {
|
import {
|
||||||
getIndentation,
|
getIndentation,
|
||||||
IndentContext,
|
IndentContext,
|
||||||
|
@ -128,18 +127,5 @@ export const visualKeymap = Prec.highest(
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: indentDecrease,
|
run: indentDecrease,
|
||||||
},
|
},
|
||||||
// Override bolding in RT mode
|
|
||||||
{
|
|
||||||
key: 'Ctrl-b',
|
|
||||||
mac: 'Mod-b',
|
|
||||||
preventDefault: true,
|
|
||||||
run: toggleRanges('\\textbf'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Ctrl-i',
|
|
||||||
mac: 'Mod-i',
|
|
||||||
preventDefault: true,
|
|
||||||
run: toggleRanges('\\textit'),
|
|
||||||
},
|
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +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 { toggleRanges } from '../../commands/ranges'
|
||||||
|
|
||||||
export const shortcuts = () => {
|
export const shortcuts = () => {
|
||||||
return Prec.high(
|
return Prec.high(
|
||||||
|
@ -9,13 +9,13 @@ export const shortcuts = () => {
|
||||||
key: 'Ctrl-b',
|
key: 'Ctrl-b',
|
||||||
mac: 'Mod-b',
|
mac: 'Mod-b',
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: wrapRanges('\\textbf{', '}'),
|
run: toggleRanges('\\textbf'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'Ctrl-i',
|
key: 'Ctrl-i',
|
||||||
mac: 'Mod-i',
|
mac: 'Mod-i',
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
run: wrapRanges('\\textit{', '}'),
|
run: toggleRanges('\\textit'),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue