mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-08 19:50:47 +00:00
support old and new pdf viewers depending on feature switch
This commit is contained in:
parent
3fd8bfb221
commit
25bebe1104
5 changed files with 39 additions and 25 deletions
|
@ -112,13 +112,20 @@ block content
|
|||
|
||||
- locals.suppressDefaultJs = true
|
||||
|
||||
- var pdfPath = 'libs/pdf.worker.js'
|
||||
- if (user.featureSwitches && user.featureSwitches.pdfng) { pdfPath = 'libs/pdfjs-1.0.712/pdf.worker.js'; }
|
||||
- // user.featureSwitches = {} // override
|
||||
- var usePdfNG = user.featureSwitches && user.featureSwitches.pdfng;
|
||||
- var pdfPath = 'libs/pdf.worker.js';
|
||||
- if (usePdfNG) { pdfPath = 'libs/pdfjs-1.0.712/pdf.worker.js'; }
|
||||
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
||||
- var pdfJsWorkerPath = jsPath+pdfPath+'?fingerprint='+fingerprintedPath
|
||||
script(type='text/javascript').
|
||||
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
||||
|
||||
// when using pdfng we need a different pdfjs version
|
||||
if usePdfNG
|
||||
script(type='text/javascript').
|
||||
window.requirejs.paths['libs/pdf'] = 'libs/pdfjs-1.0.712/pdf'
|
||||
|
||||
script(
|
||||
data-main=jsPath+"ide.js",
|
||||
baseurl=jsPath,
|
||||
|
|
|
@ -58,26 +58,32 @@ div.full-size.pdf(ng-controller="PdfController")
|
|||
i.split-screen
|
||||
|
||||
.pdf-viewer(ng-show="pdf.url && pdf.view == 'pdf' && !pdf.failure && !pdf.timeout && !pdf.error")
|
||||
div(
|
||||
pdfjs
|
||||
ng-if="settings.pdfViewer == 'pdfjs' && !(user.featureSwitches && user.featureSwitches.pdfng)"
|
||||
pdf-src="pdf.url"
|
||||
key="{{ project_id }}"
|
||||
resize-on="layout:main:resize,layout:pdf:resize"
|
||||
highlights="pdf.highlights"
|
||||
position="pdf.position"
|
||||
dbl-click-callback="syncToCode"
|
||||
)
|
||||
div(
|
||||
pdfng
|
||||
ng-if="settings.pdfViewer == 'pdfjs' && user.featureSwitches && user.featureSwitches.pdfng"
|
||||
pdf-src="pdf.url"
|
||||
key="{{ project_id }}"
|
||||
resize-on="layout:main:resize,layout:pdf:resize"
|
||||
highlights="pdf.highlights"
|
||||
position="pdf.position"
|
||||
dbl-click-callback="syncToCode"
|
||||
)
|
||||
- // user.featureSwitches = {} // override
|
||||
- var usePdfNG = user.featureSwitches && user.featureSwitches.pdfng;
|
||||
- console.log('USER FEATURE SWITCHES', user.featureSwitches, usePdfNG);
|
||||
if !usePdfNG
|
||||
div(
|
||||
pdfjs
|
||||
ng-if="settings.pdfViewer == 'pdfjs'"
|
||||
pdf-src="pdf.url"
|
||||
key="{{ project_id }}"
|
||||
resize-on="layout:main:resize,layout:pdf:resize"
|
||||
highlights="pdf.highlights"
|
||||
position="pdf.position"
|
||||
dbl-click-callback="syncToCode"
|
||||
)
|
||||
else
|
||||
div(
|
||||
pdfng
|
||||
ng-if="settings.pdfViewer == 'pdfjs'"
|
||||
pdf-src="pdf.url"
|
||||
key="{{ project_id }}"
|
||||
resize-on="layout:main:resize,layout:pdf:resize"
|
||||
highlights="pdf.highlights"
|
||||
position="pdf.position"
|
||||
dbl-click-callback="syncToCode"
|
||||
)
|
||||
|
||||
iframe(
|
||||
ng-src="{{ pdf.url }}"
|
||||
ng-if="settings.pdfViewer == 'native'"
|
||||
|
|
|
@ -6,7 +6,7 @@ define [
|
|||
"ide/online-users/OnlineUsersManager"
|
||||
"ide/track-changes/TrackChangesManager"
|
||||
"ide/permissions/PermissionsManager"
|
||||
"ide/pdfng/PdfManager"
|
||||
"ide/pdf/PdfManager"
|
||||
"ide/binary-files/BinaryFilesManager"
|
||||
"ide/settings/index"
|
||||
"ide/share/index"
|
||||
|
@ -106,4 +106,4 @@ define [
|
|||
else
|
||||
$scope.darkTheme = false
|
||||
|
||||
angular.bootstrap(document.body, ["SharelatexApp"])
|
||||
angular.bootstrap(document.body, ["SharelatexApp"])
|
||||
|
|
|
@ -2,6 +2,7 @@ define [
|
|||
"ide/pdf/controllers/PdfController"
|
||||
"ide/pdf/controllers/PdfViewToggleController"
|
||||
"ide/pdf/directives/pdfJs"
|
||||
"ide/pdfng/directives/pdfJs" # alternative incremental viewer
|
||||
], () ->
|
||||
class PdfManager
|
||||
constructor: (@ide, @$scope) ->
|
||||
|
|
|
@ -5,7 +5,7 @@ define [
|
|||
"ide/pdfng/directives/pdfHighlights"
|
||||
"ide/pdfng/directives/pdfRenderer"
|
||||
"ide/pdfng/directives/pdfPage"
|
||||
"libs/pdfjs-1.0.712/pdf"
|
||||
"libs/pdf" # needs pdfjs-1.0.712, override the path in require.js to get it
|
||||
], (
|
||||
App
|
||||
pdfTextLayer
|
||||
|
|
Loading…
Add table
Reference in a new issue