Przeglądaj źródła

Merge pull request #19247 from overleaf/mj-figure-snippet

[web] Default to half line width in figure snippet

GitOrigin-RevId: 477ab7fec21a040a5974d807dde3604882c38c82
Mathias Jakobsen 2 lat temu
rodzic
commit
c1ad4d237b

+ 1 - 1
services/web/frontend/js/features/source-editor/languages/latex/completions/data/environments.ts

@@ -37,7 +37,7 @@ export const environments = new Map([
     'figure',
     'figure',
     `\\begin{figure}
     `\\begin{figure}
 \t\\centering
 \t\\centering
-\t\\includegraphics{$1}
+\t\\includegraphics[width=0.5\\linewidth]{$1}
 \t\\caption{\${2:Caption}}
 \t\\caption{\${2:Caption}}
 \t\\label{\${3:fig:enter-label}}
 \t\\label{\${3:fig:enter-label}}
 \\end{figure}`,
 \\end{figure}`,

+ 4 - 4
services/web/test/frontend/features/source-editor/components/codemirror-editor-visual.spec.tsx

@@ -249,8 +249,8 @@ describe('<CodeMirrorEditor/> in Visual mode', function () {
       cy.get('@third-line').type('path/to/image')
       cy.get('@third-line').type('path/to/image')
 
 
       cy.get('@third-line').should(
       cy.get('@third-line').should(
-        'have.text',
-        '    \\includegraphics{path/to/image}'
+        'contain.text',
+        '    \\includegraphics[width=0.5\\linewidth]{path/to/image}'
       )
       )
 
 
       // move the cursor out of the figure
       // move the cursor out of the figure
@@ -258,8 +258,8 @@ describe('<CodeMirrorEditor/> in Visual mode', function () {
 
 
       // Should be removed from dom when line is hidden
       // Should be removed from dom when line is hidden
       cy.get('.cm-content').should(
       cy.get('.cm-content').should(
-        'not.contain',
-        '\\includegraphics{path/to/image}'
+        'not.contain.text',
+        '\\includegraphics[width=0.5\\linewidth]{path/to/image}'
       )
       )
 
 
       cy.get('img.ol-cm-graphics').should('have.attr', 'src', 'path/to/image')
       cy.get('img.ol-cm-graphics').should('have.attr', 'src', 'path/to/image')