Add a enhanceTextSelection preference

Please note that this is a hack, but I think that it should be OK for now to atleast get the preference landed. Refer to the code comment for further information.

Re: issue 7584 and PR 7586.
This commit is contained in:
Jonas Jenwald 2016-09-07 14:52:52 +02:00
parent ca61ccc533
commit e12c48b73f
3 changed files with 18 additions and 2 deletions

View File

@ -95,6 +95,10 @@
"description": "Whether to prevent the extension from reporting the extension and browser version to the extension developers.",
"default": false
},
"enhanceTextSelection": {
"type": "boolean",
"default": false
},
"renderInteractiveForms": {
"type": "boolean",
"default": false

View File

@ -101,7 +101,6 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22;
var PAGE_NUMBER_LOADING_INDICATOR = 'visiblePageIsLoading';
var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
var ENHANCE_TEXT_SELECTION = false;
function configure(PDFJS) {
PDFJS.imageResourcesPath = './images/';
@ -211,7 +210,7 @@ var PDFViewerApplication = {
renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService,
downloadManager: downloadManager,
enhanceTextSelection: ENHANCE_TEXT_SELECTION,
enhanceTextSelection: false,
});
pdfRenderingQueue.setViewer(this.pdfViewer);
pdfLinkService.setViewer(this.pdfViewer);
@ -323,6 +322,18 @@ var PDFViewerApplication = {
Preferences.get('defaultZoomValue').then(function resolved(value) {
self.preferenceDefaultZoomValue = value;
}),
Preferences.get('enhanceTextSelection').then(function resolved(value) {
// TODO: Move the initialization and fetching of `Preferences` to occur
// before the various viewer components are initialized.
//
// This was attempted in: https://github.com/mozilla/pdf.js/pull/7586,
// but it had to be backed out since it violated implicit assumptions
// about some viewer components being synchronously available.
//
// NOTE: This hack works since the `enhanceTextSelection` option is not
// needed until `PDFViewer.setDocument` has been called.
self.pdfViewer.enhanceTextSelection = value;
}),
Preferences.get('disableTextLayer').then(function resolved(value) {
if (PDFJS.disableTextLayer === true) {
return;

View File

@ -12,5 +12,6 @@
"disableTextLayer": false,
"useOnlyCssZoom": false,
"externalLinkTarget": 0,
"enhanceTextSelection": false,
"renderInteractiveForms": false
}