diff --git a/services/clsi/app/js/DraftModeManager.js b/services/clsi/app/js/DraftModeManager.js index e6f86becf9..a5b26348e6 100644 --- a/services/clsi/app/js/DraftModeManager.js +++ b/services/clsi/app/js/DraftModeManager.js @@ -4,7 +4,9 @@ const logger = require('@overleaf/logger') async function injectDraftMode(filename) { const content = await fsPromises.readFile(filename, { encoding: 'utf8' }) - const modifiedContent = '\\PassOptionsToPackage{draft}{graphicx}' + content + const modifiedContent = + '\\PassOptionsToPackage{draft}{graphicx}\\PassOptionsToPackage{draft}{graphics}' + + content logger.debug( { content: content.slice(0, 1024), // \documentclass is normally v near the top diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_legacy/frog.jpg b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/frog.jpg new file mode 100644 index 0000000000..5b889ef3cf Binary files /dev/null and b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/frog.jpg differ diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_legacy/main.tex b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/main.tex new file mode 100644 index 0000000000..e3c77e18e0 --- /dev/null +++ b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/main.tex @@ -0,0 +1,25 @@ +\documentclass{article} + +\usepackage{graphics} + +\title{Your Paper} +\author{You} + +\begin{document} +\maketitle + +\begin{abstract} +Your abstract. +\end{abstract} + +\section{Introduction} + +This is the start of the document. + +\begin{figure}[ht] +\includegraphics[0,0][100,100]{frog.jpg} +\end{figure} + +This is the end of the document. + +\end{document} diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_legacy/options.json b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/options.json new file mode 100644 index 0000000000..183ed4b628 --- /dev/null +++ b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/options.json @@ -0,0 +1,3 @@ +{ + "draft": true +} \ No newline at end of file diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_legacy/output.pdf b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/output.pdf new file mode 100644 index 0000000000..c85b1282a9 Binary files /dev/null and b/services/clsi/test/acceptance/fixtures/examples/draft_legacy/output.pdf differ diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_mode/frog.jpg b/services/clsi/test/acceptance/fixtures/examples/draft_mode/frog.jpg new file mode 100644 index 0000000000..5b889ef3cf Binary files /dev/null and b/services/clsi/test/acceptance/fixtures/examples/draft_mode/frog.jpg differ diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_mode/main.tex b/services/clsi/test/acceptance/fixtures/examples/draft_mode/main.tex new file mode 100644 index 0000000000..643ed9562c --- /dev/null +++ b/services/clsi/test/acceptance/fixtures/examples/draft_mode/main.tex @@ -0,0 +1,37 @@ +\documentclass{article} +% Language setting +% Replace `english' with e.g. `spanish' to change the document language +\usepackage[english]{babel} + +% Set page size and margins +% Replace `letterpaper' with `a4paper' for UK/EU standard size +\usepackage[letterpaper,top=2cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry} + +% Useful packages +\usepackage{amsmath} +\usepackage{graphicx} +\usepackage[colorlinks=true, allcolors=blue]{hyperref} + +\title{Your Paper} +\author{You} + +\begin{document} +\maketitle + +\begin{abstract} +Your abstract. +\end{abstract} + +\section{Introduction} + +This is the start of the document. + +\begin{figure}[h] + \centering + \includegraphics[width=0.3\textwidth]{frog.jpg} + \caption{\label{fig:frog}This frog was uploaded via the file-tree menu.} +\end{figure} + +This is the end of the document. + +\end{document} diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_mode/options.json b/services/clsi/test/acceptance/fixtures/examples/draft_mode/options.json new file mode 100644 index 0000000000..183ed4b628 --- /dev/null +++ b/services/clsi/test/acceptance/fixtures/examples/draft_mode/options.json @@ -0,0 +1,3 @@ +{ + "draft": true +} \ No newline at end of file diff --git a/services/clsi/test/acceptance/fixtures/examples/draft_mode/output.pdf b/services/clsi/test/acceptance/fixtures/examples/draft_mode/output.pdf new file mode 100644 index 0000000000..182a9c3540 Binary files /dev/null and b/services/clsi/test/acceptance/fixtures/examples/draft_mode/output.pdf differ diff --git a/services/clsi/test/unit/js/DraftModeManagerTests.js b/services/clsi/test/unit/js/DraftModeManagerTests.js index 53848cc224..acaae0f10a 100644 --- a/services/clsi/test/unit/js/DraftModeManagerTests.js +++ b/services/clsi/test/unit/js/DraftModeManagerTests.js @@ -36,7 +36,8 @@ Hello world encoding: 'utf8', }) expect(contents).to.equal( - '\\PassOptionsToPackage{draft}{graphicx}' + this.contents + '\\PassOptionsToPackage{draft}{graphicx}\\PassOptionsToPackage{draft}{graphics}' + + this.contents ) }) }) diff --git a/services/clsi/test/unit/js/snapshots/pdfjs/draft_legacy/XrefTable.json b/services/clsi/test/unit/js/snapshots/pdfjs/draft_legacy/XrefTable.json new file mode 100644 index 0000000000..19cd40c0b3 --- /dev/null +++ b/services/clsi/test/unit/js/snapshots/pdfjs/draft_legacy/XrefTable.json @@ -0,0 +1,182 @@ +{ + "xRefEntries": [ + { + "offset": 0, + "gen": 0, + "free": true + }, + { + "offset": 67338, + "gen": 0, + "uncompressed": true + }, + { + "offset": 67606, + "gen": 0, + "uncompressed": true + }, + { + "offset": 15, + "gen": 0, + "uncompressed": true + }, + { + "offset": 216, + "gen": 0, + "uncompressed": true + }, + { + "offset": 790, + "gen": 0, + "uncompressed": true + }, + { + "offset": 840, + "gen": 0, + "uncompressed": true + }, + { + "offset": 975, + "gen": 0, + "uncompressed": true + }, + { + "offset": 1083, + "gen": 0, + "uncompressed": true + }, + { + "offset": 1578, + "gen": 0, + "uncompressed": true + }, + { + "offset": 9881, + "gen": 0, + "uncompressed": true + }, + { + "offset": 17868, + "gen": 0, + "uncompressed": true + }, + { + "offset": 29906, + "gen": 0, + "uncompressed": true + }, + { + "offset": 38400, + "gen": 0, + "uncompressed": true + }, + { + "offset": 46656, + "gen": 0, + "uncompressed": true + }, + { + "offset": 56198, + "gen": 0, + "uncompressed": true + }, + { + "offset": 65682, + "gen": 0, + "uncompressed": true + }, + { + "offset": 16, + "gen": 0 + }, + { + "offset": 16, + "gen": 1 + }, + { + "offset": 16, + "gen": 2 + }, + { + "offset": 16, + "gen": 3 + }, + { + "offset": 16, + "gen": 4 + }, + { + "offset": 16, + "gen": 5 + }, + { + "offset": 16, + "gen": 6 + }, + { + "offset": 16, + "gen": 7 + }, + { + "offset": 16, + "gen": 8 + }, + { + "offset": 16, + "gen": 9 + }, + { + "offset": 16, + "gen": 10 + }, + { + "offset": 16, + "gen": 11 + }, + { + "offset": 16, + "gen": 12 + }, + { + "offset": 16, + "gen": 13 + }, + { + "offset": 16, + "gen": 14 + }, + { + "offset": 16, + "gen": 15 + }, + { + "offset": 16, + "gen": 16 + }, + { + "offset": 16, + "gen": 17 + }, + { + "offset": 16, + "gen": 18 + }, + { + "offset": 16, + "gen": 19 + }, + { + "offset": 16, + "gen": 20 + }, + { + "offset": 16, + "gen": 21 + }, + { + "offset": 16, + "gen": 22 + } + ], + "startXRefTable": 67606 +} \ No newline at end of file diff --git a/services/clsi/test/unit/js/snapshots/pdfjs/draft_mode/XrefTable.json b/services/clsi/test/unit/js/snapshots/pdfjs/draft_mode/XrefTable.json new file mode 100644 index 0000000000..e3b965fc19 --- /dev/null +++ b/services/clsi/test/unit/js/snapshots/pdfjs/draft_mode/XrefTable.json @@ -0,0 +1,226 @@ +{ + "xRefEntries": [ + { + "offset": 0, + "gen": 0, + "free": true + }, + { + "offset": 69708, + "gen": 0, + "uncompressed": true + }, + { + "offset": 70038, + "gen": 0, + "uncompressed": true + }, + { + "offset": 15, + "gen": 0, + "uncompressed": true + }, + { + "offset": 216, + "gen": 0, + "uncompressed": true + }, + { + "offset": 867, + "gen": 0, + "uncompressed": true + }, + { + "offset": 990, + "gen": 0, + "uncompressed": true + }, + { + "offset": 1143, + "gen": 0, + "uncompressed": true + }, + { + "offset": 1251, + "gen": 0, + "uncompressed": true + }, + { + "offset": 1834, + "gen": 0, + "uncompressed": true + }, + { + "offset": 10137, + "gen": 0, + "uncompressed": true + }, + { + "offset": 18124, + "gen": 0, + "uncompressed": true + }, + { + "offset": 31939, + "gen": 0, + "uncompressed": true + }, + { + "offset": 40433, + "gen": 0, + "uncompressed": true + }, + { + "offset": 48689, + "gen": 0, + "uncompressed": true + }, + { + "offset": 58231, + "gen": 0, + "uncompressed": true + }, + { + "offset": 67715, + "gen": 0, + "uncompressed": true + }, + { + "offset": 16, + "gen": 0 + }, + { + "offset": 16, + "gen": 1 + }, + { + "offset": 16, + "gen": 2 + }, + { + "offset": 16, + "gen": 3 + }, + { + "offset": 16, + "gen": 4 + }, + { + "offset": 16, + "gen": 5 + }, + { + "offset": 16, + "gen": 6 + }, + { + "offset": 16, + "gen": 7 + }, + { + "offset": 16, + "gen": 8 + }, + { + "offset": 16, + "gen": 9 + }, + { + "offset": 16, + "gen": 10 + }, + { + "offset": 16, + "gen": 11 + }, + { + "offset": 16, + "gen": 12 + }, + { + "offset": 16, + "gen": 13 + }, + { + "offset": 16, + "gen": 14 + }, + { + "offset": 16, + "gen": 15 + }, + { + "offset": 16, + "gen": 16 + }, + { + "offset": 16, + "gen": 17 + }, + { + "offset": 16, + "gen": 18 + }, + { + "offset": 16, + "gen": 19 + }, + { + "offset": 16, + "gen": 20 + }, + { + "offset": 16, + "gen": 21 + }, + { + "offset": 16, + "gen": 22 + }, + { + "offset": 16, + "gen": 23 + }, + { + "offset": 16, + "gen": 24 + }, + { + "offset": 16, + "gen": 25 + }, + { + "offset": 16, + "gen": 26 + }, + { + "offset": 16, + "gen": 27 + }, + { + "offset": 16, + "gen": 28 + }, + { + "offset": 16, + "gen": 29 + }, + { + "offset": 16, + "gen": 30 + }, + { + "offset": 16, + "gen": 31 + }, + { + "offset": 16, + "gen": 32 + }, + { + "offset": 16, + "gen": 33 + } + ], + "startXRefTable": 70038 +} \ No newline at end of file