Implement drag-and-drop support in the viewer for local files
This commit is contained in:
parent
db874b6680
commit
8e95506116
18
web/app.js
18
web/app.js
@ -1622,6 +1622,24 @@ function webViewerInitialized() {
|
|||||||
fileInput: evt.target,
|
fileInput: evt.target,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Enable draging-and-dropping a new PDF file onto the viewerContainer.
|
||||||
|
appConfig.mainContainer.addEventListener('dragover', function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
|
evt.dataTransfer.dropEffect = 'move';
|
||||||
|
});
|
||||||
|
appConfig.mainContainer.addEventListener('drop', function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
|
const files = evt.dataTransfer.files;
|
||||||
|
if (!files || files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PDFViewerApplication.eventBus.dispatch('fileinputchange', {
|
||||||
|
fileInput: evt.dataTransfer,
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
||||||
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
||||||
|
Loading…
Reference in New Issue
Block a user