Merge pull request #14764 from overleaf/mj-compile-shortcuts

[visual] Pass compilation shortcuts through from table generator

GitOrigin-RevId: b4d222d9898b3e11d786fc9d9b61b7c9b0e92f9b
This commit is contained in:
Thomas 2023-09-11 15:30:43 +02:00 committed by Copybot
parent 6be63d4f96
commit b967b8175e
2 changed files with 20 additions and 1 deletions

View file

@ -145,7 +145,7 @@ export const Table: FC = () => {
const onKeyDown: KeyboardEventHandler = useCallback(
event => {
const commandKey = isMac ? event.metaKey : event.ctrlKey
if (event.code === 'Enter' && !event.shiftKey) {
if (event.code === 'Enter' && !event.shiftKey && !commandKey) {
event.preventDefault()
event.stopPropagation()
if (!selection) {

View file

@ -109,6 +109,7 @@ describe('<CodeMirrorEditor/> Table editor', function () {
cy.interceptEvents()
cy.interceptSpelling()
cy.interceptMathJax()
cy.interceptCompile('compile', Number.MAX_SAFE_INTEGER)
window.metaAttributesCache.set('ol-preventCompileOnLoad', true)
window.metaAttributesCache.set('ol-splitTestVariants', {
'table-generator': 'enabled',
@ -637,5 +638,23 @@ cell 3 & cell 4 \\\\
cy.get('@cell-3').should('have.class', 'selected')
cy.get('@cell-4').should('have.class', 'selected')
})
it('Allow compilation shortcuts to work', function () {
mountEditor(`
\\begin{tabular}{cc }
cell 1 & cell 2\\\\
cell 3 & cell 4 \\\\
\\end{tabular}`)
cy.get('.table-generator-cell').eq(0).as('cell-1').click()
cy.get('@cell-1').type('{ctrl}{enter}')
cy.wait('@compile')
cy.get('@cell-1').type('foo{ctrl}{enter}')
cy.wait('@compile')
cy.get('@cell-1').type('{esc}')
cy.get('@cell-1').type('{ctrl}{s}')
cy.wait('@compile')
cy.get('@cell-1').type('foo{ctrl}{s}')
cy.wait('@compile')
})
})
})