[api-minor] Add support, in PDFFindController, for mixing phrase/word searches (issue 7442)

*Please note:* This patch only extends the `PDFFindController` implementation itself to support this functionality, however it's *purposely* not exposed in the default viewer.

This replaces the previous `phraseSearch`-parameter, and a `query`-string will now always be interpreted as a phrase-search.
To enable searching for individual words, the `query`-parameter must instead consist of an Array of strings. This way it's now also possible to combine phrase/word searches, with a `query`-parameter looking something like `["Lorem ipsum", "foo", "bar"]` which will search for the phrase "Lorem ipsum" *and* the words "foo" respectively "bar".
This commit is contained in:
Jonas Jenwald 2023-04-02 18:40:35 +02:00
parent 4d8a60b435
commit 0e19c3a120
6 changed files with 95 additions and 48 deletions

View file

@ -350,10 +350,12 @@ class PDFLinkService {
if (hash.includes("=")) {
const params = parseQueryString(hash);
if (params.has("search")) {
const query = params.get("search").replaceAll('"', ""),
phrase = params.get("phrase") === "true";
this.eventBus.dispatch("findfromurlhash", {
source: this,
query: params.get("search").replaceAll('"', ""),
phraseSearch: params.get("phrase") === "true",
query: phrase ? query : query.match(/\S+/g),
});
}
// borrowing syntax from "Parameters for Opening PDF Files"