Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(highlight): Ignore empty rects when calculating bounding rect #696

Merged
merged 3 commits into from
Jul 6, 2022

Conversation

karelee7
Copy link
Contributor

@karelee7 karelee7 commented Jul 6, 2022

No description provided.

@karelee7 karelee7 requested a review from a team as a code owner July 6, 2022 19:18
@karelee7 karelee7 requested a review from ConradJChan July 6, 2022 19:18
@@ -10,6 +10,11 @@ export const getBoundingRect = (shapes: Shape[]): Shape => {
const x2 = x + width;
const y2 = y + height;

// Removing extra rects
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karelee7, I think that the textLayerMode option we pass to PDF.js from Preview SDK is supposed to help with this. Is that still working properly in the latest version?

Copy link
Contributor Author

@karelee7 karelee7 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, unfortunately :( In the latest version, I still see the extra rects that have widths of 0 and heights of 0; confirmed that after filtering out these extra rects, the tooltip is positioned correctly..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should follow-up on it and see if we're missing something. Did the option change somehow or get removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm looks like the option's still there and the enum values for TextLayerMode look the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstoffan Yeah..it looks like the text layer is created with the same dimensions as it has in the current version of pdfjs and I can see that the pdf viewer is created with the ENABLE_ENHANCE option..hm...

Copy link
Contributor

@ConradJChan ConradJChan Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we see this "empty rect" behavior in the latest version of pdfjs? If we do, maybe we should open an issue in that repo to bring awareness

Copy link
Contributor Author

@karelee7 karelee7 Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, opened up an issue! I saw someone else on Stack Overflow also had a similar issue with rect values with a fairly recent version of pdfjs, but their question was never resolved aha, hopefully someone gets to the issue on the repo~ Here's a link to the issue on the repo: mozilla/pdf.js#15138

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response received per the pdfjs team for the issue link mentioned above: Please keep in mind that the ENABLE_ENHANCE mode is essentially unmaintained at this point, and no real development has happened for years. Furthermore, in the next major PDF.js release that text-selection mode is also most likely going to be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @karelee7. I'd be curious to know how the regular ENABLE mode performs at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! Sure, I can see if they have any updates about that!

@karelee7 karelee7 requested a review from jstoffan July 6, 2022 19:38
Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add some unit tests?

@@ -10,6 +10,11 @@ export const getBoundingRect = (shapes: Shape[]): Shape => {
const x2 = x + width;
const y2 = y + height;

// Removing extra rects
Copy link
Contributor

@ConradJChan ConradJChan Jul 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we see this "empty rect" behavior in the latest version of pdfjs? If we do, maybe we should open an issue in that repo to bring awareness

src/highlight/highlightUtil.ts Outdated Show resolved Hide resolved
@ConradJChan
Copy link
Contributor

Maybe the commit should be fix(highlight): Ignore empty rects when calculating bounding rect

@karelee7 karelee7 changed the title fix(tooltip): Fix highlight promo tooltip for pdfjs upgrade fix(highlight): Ignore empty rects when calculating bounding rect Jul 6, 2022
@karelee7 karelee7 requested a review from ConradJChan July 6, 2022 23:31
@jstoffan
Copy link
Collaborator

jstoffan commented Jul 6, 2022

@karelee7, nice job. Let's make sure this goes out to production prior to the Preview SDK changes.

@karelee7
Copy link
Contributor Author

karelee7 commented Jul 6, 2022

@jstoffan Thanks for all the help! Yes, I'll get this one in first! ;)

@karelee7 karelee7 merged commit aa28eb4 into box:master Jul 6, 2022
@karelee7 karelee7 deleted the update-highlight-promo-tooltip branch July 6, 2022 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants