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) {
|
||||
if (expected !== actual) {
|
||||
throw new Error(
|
||||
`Replacement in toggleRange failed validation. Expected ${expected} got ${actual}`
|
||||
)
|
||||
throw new Error('Replacement in toggleRange failed validation.')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { keymap } from '@codemirror/view'
|
||||
import { EditorSelection, Prec } from '@codemirror/state'
|
||||
import { ancestorNodeOfType } from '../../utils/tree-query'
|
||||
import { toggleRanges } from '../../commands/ranges'
|
||||
import {
|
||||
getIndentation,
|
||||
IndentContext,
|
||||
|
@ -128,18 +127,5 @@ export const visualKeymap = Prec.highest(
|
|||
preventDefault: true,
|
||||
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 { keymap } from '@codemirror/view'
|
||||
import { wrapRanges } from '../../commands/ranges'
|
||||
import { toggleRanges } from '../../commands/ranges'
|
||||
|
||||
export const shortcuts = () => {
|
||||
return Prec.high(
|
||||
|
@ -9,13 +9,13 @@ export const shortcuts = () => {
|
|||
key: 'Ctrl-b',
|
||||
mac: 'Mod-b',
|
||||
preventDefault: true,
|
||||
run: wrapRanges('\\textbf{', '}'),
|
||||
run: toggleRanges('\\textbf'),
|
||||
},
|
||||
{
|
||||
key: 'Ctrl-i',
|
||||
mac: 'Mod-i',
|
||||
preventDefault: true,
|
||||
run: wrapRanges('\\textit{', '}'),
|
||||
run: toggleRanges('\\textit'),
|
||||
},
|
||||
])
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue