You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When "dragover" is called, a dropEffect is set for the drag event, depending on the value of effectAllowed of the event. When e.g. dragging & dropping from the Desktop, then effectAllowed is usually all and everything works. However, from certain sources, the effectAllowed is uninitialized (this happened e.g. with an electron app). The effect is that the drop event is never triggered. If we look at the code in app.js, then we see that in both cases the drop effect is set to move by the pdfjs viewer code. However, setting the drop effect with an unitialized value for effectAllowed somehowblocks the triggering of the subsequent drop event.
Commenting out evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move"; solves this issue. I was able to reproduce this behavior in Firefox and Edge. Maybe this line can just be removed, because, if I am not mistaken, it has no practical value (except in some browsers/operating systems, where the browser shows a different cursor?).
Code in app.js:
// Enable dragging-and-dropping a new PDF file onto the viewerContainer.appConfig.mainContainer.addEventListener("dragover",function(evt){for(constitemofevt.dataTransfer.items){if(item.type==="application/pdf"){evt.dataTransfer.dropEffect=evt.dataTransfer.effectAllowed==="copy" ? "copy" : "move";stopEvent(evt);return;}}});
Web browser and its version
Firefox 138.0.4
Operating system and its version
Ubuntu 22.0.4 / Windows 10
PDF.js version
5.2.133
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
The behavior can be simulated by adding e.dataTransfer.effectAllowed = "uninitialized"; at the beginning of the above cited dragover function. If added, then dragging & dropping from the desktop does not work anymore.
Add e.dataTransfer.effectAllowed = "uninitialized"; to the dragover function.
Open the viewer.html of the the newest pre-built version
Drag a PDF from the desktop into the viewer: it does not open anymore in the viewer (but in some cases, the browser opens the pdf as file://... instead)
What is the expected behavior?
The pdf should be loaded in the pdf js viewer
What went wrong?
drag & dropping the pdf is not possible.
Link to a viewer
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
When "dragover" is called, a
dropEffect
is set for the drag event, depending on the value ofeffectAllowed
of the event. When e.g. dragging & dropping from the Desktop, theneffectAllowed
is usuallyall
and everything works. However, from certain sources, theeffectAllowed
isuninitialized
(this happened e.g. with an electron app). The effect is that the drop event is never triggered. If we look at the code inapp.js
, then we see that in both cases the drop effect is set tomove
by the pdfjs viewer code. However, setting the drop effect with anunitialized
value foreffectAllowed
somehowblocks the triggering of the subsequentdrop
event.Commenting out
evt.dataTransfer.dropEffect = evt.dataTransfer.effectAllowed === "copy" ? "copy" : "move";
solves this issue. I was able to reproduce this behavior in Firefox and Edge. Maybe this line can just be removed, because, if I am not mistaken, it has no practical value (except in some browsers/operating systems, where the browser shows a different cursor?).Code in
app.js
:Web browser and its version
Firefox 138.0.4
Operating system and its version
Ubuntu 22.0.4 / Windows 10
PDF.js version
5.2.133
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
The behavior can be simulated by adding
e.dataTransfer.effectAllowed = "uninitialized";
at the beginning of the above cited dragover function. If added, then dragging & dropping from the desktop does not work anymore.e.dataTransfer.effectAllowed = "uninitialized";
to the dragover function.file://...
instead)What is the expected behavior?
The pdf should be loaded in the pdf js viewer
What went wrong?
drag & dropping the pdf is not possible.
Link to a viewer
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: