1
0
Эх сурвалжийг харах

fix: wrong bounding coordinates for highlights

This should fix #10400.

After a multiline text selection in PDF, the first rectangle in sel-range is a incorrect "noise", not relevant to the selection range. The underlying cause is not clear to me. Note that it's a universal problem when doing mutliline highlights, even though most of the time it does not have any effect on user experience.

This commit is a working hotfix. And very possibly there would be a better solution after looking into the update mechanism of the variable `sel-state` used here. But I have no enough experience to dive into this.

e-zz 2 жил өмнө
parent
commit
c55c25d3ca

+ 3 - 0
src/main/frontend/extensions/pdf/core.cljs

@@ -647,6 +647,9 @@
                hl-fn                   #(when-let [page-info (pdf-utils/get-page-from-range sel-range)]
                                           (when-let [sel-rects (pdf-utils/get-range-rects<-page-cnt sel-range (:page-el page-info))]
                                             (let [page         (int (:page-number page-info))
+                                                  sel-rects    (if (> (count sel-rects) 1)
+                                                                 (rest sel-rects)
+                                                                 sel-rects)
                                                   ^js bounding (pdf-utils/get-bounding-rect sel-rects)
                                                   vw-pos       {:bounding bounding :rects sel-rects :page page}
                                                   sc-pos       (pdf-utils/vw-to-scaled-pos viewer vw-pos)]