Preserve source-only extensions on file switch (#27080)

GitOrigin-RevId: 661c70b78a508619e6532b87b0409f546b4d9e82
This commit is contained in:
Rebeka Dekany
2025-07-14 17:54:03 +02:00
committed by Copybot
parent 524402e817
commit 488d0fdf9e
5 changed files with 41 additions and 11 deletions

View File

@@ -40,9 +40,15 @@ describe('Project creation and compilation', function () {
cy.get('.cm-line').should('have.length', 1)
cy.get('.cm-line').type(markdownContent)
cy.findByText('main.tex').click()
cy.get('.cm-content').should('contain.text', '\\maketitle')
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
'\\maketitle'
)
cy.findByText(fileName).click()
cy.get('.cm-content').should('contain.text', markdownContent)
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
markdownContent
)
})
it('can link and display linked image from other project', function () {

View File

@@ -104,7 +104,10 @@ describe('editor', () => {
force: true,
})
cy.get('button').contains('𝜉').click()
cy.get('.cm-content').should('contain.text', '\\xi')
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
'\\xi'
)
cy.log('recompile to force flush and avoid "unsaved changes" prompt')
recompile()

View File

@@ -55,8 +55,15 @@ describe('Project Sharing', function () {
function expectContentReadOnlyAccess() {
cy.url().should('match', /\/project\/[a-fA-F0-9]{24}/)
cy.get('.cm-content').should('contain.text', '\\maketitle')
cy.get('.cm-content').should('have.attr', 'contenteditable', 'false')
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
'\\maketitle'
)
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'have.attr',
'contenteditable',
'false'
)
}
function expectContentWriteAccess() {
@@ -64,13 +71,23 @@ describe('Project Sharing', function () {
cy.url().should('match', /\/project\/[a-fA-F0-9]{24}/)
const recompile = throttledRecompile()
// wait for the editor to finish loading
cy.get('.cm-content').should('contain.text', '\\maketitle')
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
'\\maketitle'
)
// the editor should be writable
cy.get('.cm-content').should('have.attr', 'contenteditable', 'true')
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'have.attr',
'contenteditable',
'true'
)
cy.findByText('\\maketitle').parent().click()
cy.findByText('\\maketitle').parent().type(`\n\\section{{}${section}}`)
// should have written
cy.get('.cm-content').should('contain.text', `\\section{${section}}`)
cy.findByRole('textbox', { name: /Source Editor editing/i }).should(
'contain.text',
`\\section{${section}}`
)
// check PDF
recompile()
cy.get('.pdf-viewer').should('contain.text', projectName)

View File

@@ -161,7 +161,9 @@ describe('SandboxedCompiles', function () {
})
cy.log('navigate to Section A')
cy.get('.cm-content').within(() => cy.findByText('Section A').click())
cy.findByRole('textbox', { name: /Source Editor editing/i }).within(
() => cy.findByText('Section A').click()
)
cy.get('[aria-label="Go to code location in PDF"]').click()
cy.get('@title').then((title: any) => {
waitUntilScrollingFinished('.pdfjs-viewer-inner', title)
@@ -170,7 +172,9 @@ describe('SandboxedCompiles', function () {
})
cy.log('navigate to Section B')
cy.get('.cm-content').within(() => cy.findByText('Section B').click())
cy.findByRole('textbox', { name: /Source Editor editing/i }).within(
() => cy.findByText('Section B').click()
)
cy.get('[aria-label="Go to code location in PDF"]').click()
cy.get('@sectionA').then((title: any) => {
waitUntilScrollingFinished('.pdfjs-viewer-inner', title)

View File

@@ -80,7 +80,7 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
// A built-in extension that enables soft line wrapping.
EditorView.lineWrapping,
sourceOnly(
options.visual,
options.visual.visual,
EditorView.contentAttributes.of({ 'aria-label': 'Source Editor editing' })
),
// A built-in extension that re-indents input if the language defines an indentOnInput field in its language data.