I’m having an issue with the mupdf.text.getSelected function.
With certain pdfs, if you select text over multiple paragraphs, then you get the following error:
Uncaught (in promise) TypeError: can't access property "left", u[0] is undefined
function http://localhost:5173/lib/chunk-R6FPMO7L.js:188
executeFunction http://localhost:5173/lib/chunk-KUHEKGUW.js:6
handleFunctionCall http://localhost:5173/lib/chunk-KUHEKGUW.js:6
listenMessageEvent http://localhost:5173/lib/chunk-KUHEKGUW.js:6
value http://localhost:5173/lib/chunk-R6FPMO7L.js:188
next http://localhost:5173/lib/chunk-KUHEKGUW.js:6
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
Ze http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
Ze http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
Re http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
Ze http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
Ze http://localhost:5173/lib/chunk-R6FPMO7L.js:32
_next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
next http://localhost:5173/lib/chunk-R6FPMO7L.js:32
l http://localhost:5173/lib/chunk-R6FPMO7L.js:32
invokeTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
onInvokeTask http://localhost:5173/lib/chunk-R6FPMO7L.js:36
invokeTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
runTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
invokeTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
I http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
x http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
U http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
j http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
scheduleTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
scheduleTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
scheduleEventTask http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
l http://localhost:5173/lib/polyfills-SCHOHYNV.js:1
IT</</<[441]</</</</<[54]</</< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
IT</</<[441]</</</</<[54]</< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
IT</</<[441]</</</</<[54]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</</<[32]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</</<[31]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</</<[15]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</</<[10]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
m http://localhost:5173/lib/chunk-R6FPMO7L.js:9
d http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</< http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</</< http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</</< http://localhost:5173/lib/chunk-R6FPMO7L.js:9
IT</</<[441]</< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
IT</</<[441]< http://localhost:5173/lib/chunk-R6FPMO7L.js:10
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT</</<[144]</</< http://localhost:5173/lib/chunk-R6FPMO7L.js:2
IT</</<[144]</< http://localhost:5173/lib/chunk-R6FPMO7L.js:2
IT</</<[144]< http://localhost:5173/lib/chunk-R6FPMO7L.js:2
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT</</<[13]< http://localhost:5173/lib/chunk-R6FPMO7L.js:1
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT</</<[15]< http://localhost:5173/lib/chunk-R6FPMO7L.js:1
i http://localhost:5173/lib/chunk-R6FPMO7L.js:1
t http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT http://localhost:5173/lib/chunk-R6FPMO7L.js:1
IT http://localhost:5173/lib/chunk-R6FPMO7L.js:1
pi http://localhost:5173/lib/chunk-R6FPMO7L.js:1
<anonymous> http://localhost:5173/lib/chunk-R6FPMO7L.js:50
mupdf.js:1:178102
onclick App.jsx:25
AsyncFunctionThrow self-hosted:804
(Async: async)
apply self-hosted:2253
_parse mupdf.js:1
next mupdf.js:1
next mupdf.js:1
_next mupdf.js:1
next mupdf.js:1
No mupdf.js:1
_next mupdf.js:1
next mupdf.js:1
next mupdf.js:1
gi mupdf.js:1
next mupdf.js:1
next mupdf.js:1
next mupdf.js:1
_next mupdf.js:1
next mupdf.js:1
No mupdf.js:1
_next mupdf.js:1
next mupdf.js:1
Vi mupdf.js:1
_next mupdf.js:1
next mupdf.js:1
t4 mupdf.js:1
(Async: EventListener.handleEvent)
o2 mupdf.js:1
zi mupdf.js:1
_trySubscribe mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
subscribe mupdf.js:1
Vi mupdf.js:1
Fi mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
subscribe mupdf.js:1
No mupdf.js:1
Fi mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
subscribe mupdf.js:1
_Ho mupdf.js:1
Fi mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
subscribe mupdf.js:1
No mupdf.js:1
Fi mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
subscribe mupdf.js:1
xo mupdf.js:1
Fi mupdf.js:1
Si mupdf.js:1
gi mupdf.js:1
I can’t really debug it since the code is minified.
Here’s a link to a reproduction repo: GitHub - ricky-c-2001/mupdf-webviewer-react-bug-poc
And here’s a video of it in action: