Open Bug 1353790 Opened 7 years ago Updated 2 years ago

Add ability to inject synonyms information for the find bar (in-page search)

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(Not tracked)

People

(Reporter: yuki, Unassigned)

Details

(Whiteboard: [design-decision-approved])

      No description provided.
Huh?
Sorry, I posted this bug with no description accidentally...

On the bug 1271537 I proposed APIs to extend the find bar, but I've realized that what I actually need is just something mechanism to do "search with synonyms". So I propose different API to solve my problem with addons.


Before I propose a new API, I try to describe why it is required.

Currently, the find bar does in-page search incrementally from user's input. However, this is very unuseful in CJK (Chinese, Japanese, and Korean), because most local webpages are written in the local language and they can't be found from alphabetic input. For example, to find a term "日本語" from the current page, we Japanese people must do these steps:

1) Install any IME (input method editor) like "Google Japanese Input".
   ( https://tools.google.com/dlpage/japaneseinput/eula.html )
2) Type "nihongo" into the find bar. (No search result here!)
3) Convert it to "日本語" with IME. IMEs provide such a feature based on their own built-in dictionary.
4) Fix the conversion result. Then Firefox finds the term "日本語" from the current page.

However, if the author of the page decided to use synonyms "ニホンゴ" or "にほんご", they won't be found. Then I have to do the steps 2), 3) and 4) for each possible synonym.


Thus, I want to do following with my addon:

1) Start to listen "find bar" events (it is discussed in the bug 1332144).
2) A new find event is fired. For example, the user types "nihongo".
3) My addon handles the event, and generates a list of synonyms like "['nihongo','にほんご','ニホンゴ','日本語']", from the given input and its own built-in dictonary.
4) Inject the synonyms information to the find bar. THIS IS THE API I'm GOING TO PROPOSE.
5) Firefox's find bar finds all given synonyms from the current page, and highlights them.

My existing addon XUL/Migemo https://addons.mozilla.org/en-US/firefox/addon/xulmigemo/ does them in different method, overriding Findbar.jsm functions. In other words, this API is required to migrate the addon from XUL to WebExtensions.


This is a rough sketch based on the API plan at https://bugzilla.mozilla.org/show_bug.cgi?id=1332144#c27 :

browser.find.onFindSearch.addListener((details) => {
  var input = details.input;
  var synonyms = MyAddonModule.generateSynonyms(input);
  details.synonyms = synonyms; // or something way to give synonyms information
  browser.find.update(details); // or something way to do find with synonyms
});
Summary: synonyms → Add ability to inject synonyms information for the find bar (in-page search)
Ah, that sounds like a quite useful feature. It might require some nontrivial platform work to support, though.

CCing Mike de Boer, who seems to have done most of the interesting typeahead find work lately.
Whiteboard: [design-decision-needed]
Hi Piro, this has been added to the agenda for the June 20 WebExtension APIs triage. Would you be able to join us on IRC? 

Wiki: https://wiki.mozilla.org/Add-ons/Contribute/Triage#Next_Meeting

Agenda: https://docs.google.com/document/d/1s2j85VfYKTDftppFU-K7pgRs6sEuMTHVXqf3RL5iYvs/edit#heading=h.du5ihvu5p6ro
OK, I'll join to the IRC channel while the meeting.
Priority: -- → P5
Whiteboard: [design-decision-needed] → [design-decision-approved]
Product: Toolkit → WebExtensions
Bulk move of bugs per https://bugzilla.mozilla.org/show_bug.cgi?id=1483958
Component: Untriaged → General
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.