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

FindMultiple matchesColor #2650

Open
victorDECLAU opened this issue Nov 14, 2024 · 2 comments
Open

FindMultiple matchesColor #2650

victorDECLAU opened this issue Nov 14, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve. waiting for the user's answer

Comments

@victorDECLAU
Copy link

victorDECLAU commented Nov 14, 2024

Is your feature request related to a problem? Please describe.
Hello Stephan,

I built a feature some time ago relating on the matchesColor of the findMultiple() or find()method results.

I am currently using version 17.4.10 which still contains the structure of FindResultMatchesCount like below :

FindResultMatchesCount {
  current?: number;
  total?: number;
  matches?: Array<any>;
  matchesLength?: Array<any>;
  matchesColor?: Array<any>;
}

I have the feeling that every version above looses the matchesColor attribute, to look like this :

FindResultMatchesCount {
  current: number;
  total: number;
  matches: Array<any>;
  matchesLength: Array<any>;
  caseSensitive: boolean;
  entireWord: boolean;
  findPrevious: boolean;
  highlightAll: boolean;
  matchDiacritics: boolean;
  query: string;
  type: 'findagain' | 'highlightallchange' | 'casesensitivitychange' | 'entirewordchange' | 'diacriticmatchingchange' | 'find';
}

Describe the solution you'd like
My feature aims to get hit counts for every word inserted into the findMultiple() method. With only the matches and matchesLength, i am not able to calculate those counters, because of the case "two worlds with same length".

My question would be : "how impossible is it to reintroduce the matchesColorsattribute ?"

Describe alternatives you've considered
I think my better option would be to make another instance of the pdfViewer, and to use it only to run successive find() method on each searchText word I have to count. But i'm not satisfied with this method because of perfomance that I expect to be poor. (but didn't tried at the moment).

If it really is the end of the glorious matchesColors, I'd be happy to ear from you on how you would approach this situation with you advanced knowledge of the librairy.

Additional context
I am currently migrating from angular 16 to angular 18, that's why I want to upgrade ngx-extended-pdf-viewer versions.
In my use case, I often run findMultiple on 10+ to 20 words.
This multiple search is triggered on view opening, so the response time has to be as minimal as possible.

Don't hesitate to reach me if there is not enough information in this description,
Best regards,

@stephanrauh stephanrauh self-assigned this Nov 14, 2024
@stephanrauh stephanrauh added the enhancement New feature or request label Nov 14, 2024
@stephanrauh
Copy link
Owner

You're right, I had to abandon my cute little additions because I was lost in merge hell. I suspect the pdf.js team have stopped working on the find controller, so maybe it'd be a good time to re-introduce the feature, but at the moment, I shy away from the risk.

However, now there are two find controllers. The secondary find controller is exclusively available for the API, so you could use it for counting words. There's no need to open a second instance of ngx-extended-pdf-viewer.

Another option is to implement your own custom find controller. I've documented this idea here: https://pdfviewer.net/extended-pdf-viewer/custom-find. The idea is to start (e.g. derive) from the original find controller and modify it to match your needs.

I believe re-introducing the matchesColor feature to the find controller should be straight-forward. That doesn't render the words in different colors, but you say you're interested in counting, so that's probably not a big deal. Rendering colorful search results requires modifying the TextHighlighter class, and at the moment, that's not customizable (yet).

Can I talk you into implementing a custom find controller, sending it to me, and asking me to add it to the library again?

Best regards,
Stephan

@stephanrauh stephanrauh added waiting for the user's answer I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve. labels Nov 14, 2024
@victorDECLAU
Copy link
Author

Hello Stephan,

Well thank you for you answer.
I will try to implement the custom controller as suggested and will send it to you as soon as i find some time in my road map. (I think i will take up to 2-3 weeks).

In the meantime, I will force the install of the 17.4.0 version with angular 17 and 18, as it seems to provoque no damage to the application :)

Best regards,
Victor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve. waiting for the user's answer
Projects
None yet
Development

No branches or pull requests

2 participants