Przeglądaj źródła

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

[visual] Pass compilation shortcuts through from table generator

GitOrigin-RevId: b4d222d9898b3e11d786fc9d9b61b7c9b0e92f9b
Thomas 3 lat temu
rodzic
commit
b967b8175e

+ 1 - 1
services/web/frontend/js/features/source-editor/components/table-generator/table.tsx

@@ -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) {

+ 19 - 0
services/web/test/frontend/features/source-editor/components/codemirror-editor-table-generator.spec.tsx

@@ -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')
+    })
   })
 })