parent
10e9f7acb8
commit
fd00a52856
@ -129,7 +129,8 @@ class Backend {
|
||||
['triggerDatabaseUpdated', {async: false, contentScript: true, handler: this._onApiTriggerDatabaseUpdated.bind(this)}],
|
||||
['testMecab', {async: true, contentScript: true, handler: this._onApiTestMecab.bind(this)}],
|
||||
['textHasJapaneseCharacters', {async: false, contentScript: true, handler: this._onApiTextHasJapaneseCharacters.bind(this)}],
|
||||
['getTermFrequencies', {async: true, contentScript: true, handler: this._onApiGetTermFrequencies.bind(this)}]
|
||||
['getTermFrequencies', {async: true, contentScript: true, handler: this._onApiGetTermFrequencies.bind(this)}],
|
||||
['findAnkiNotes', {async: true, contentScript: true, handler: this._onApiFindAnkiNotes.bind(this)}]
|
||||
]);
|
||||
this._messageHandlersWithProgress = new Map([
|
||||
]);
|
||||
@ -752,6 +753,10 @@ class Backend {
|
||||
return await this._translator.getTermFrequencies(termReadingList, dictionaries);
|
||||
}
|
||||
|
||||
async _onApiFindAnkiNotes({query}) {
|
||||
return await this._anki.findNotes(query);
|
||||
}
|
||||
|
||||
// Command handlers
|
||||
|
||||
async _onCommandOpenSearchPage(params) {
|
||||
|
@ -120,6 +120,18 @@ class AnkiConnect {
|
||||
return await this._invoke('storeMediaFile', {filename: fileName, data: content});
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds notes matching a query.
|
||||
* @param {string} query Searches for notes matching a query.
|
||||
* @returns {number[]} An array of note IDs.
|
||||
* @see https://docs.ankiweb.net/searching.html
|
||||
*/
|
||||
async findNotes(query) {
|
||||
if (!this._enabled) { return []; }
|
||||
await this._checkVersion();
|
||||
return await this._invoke('findNotes', {query});
|
||||
}
|
||||
|
||||
async findNoteIds(notes) {
|
||||
if (!this._enabled) { return []; }
|
||||
await this._checkVersion();
|
||||
|
@ -172,6 +172,10 @@ class API {
|
||||
return this._invoke('getTermFrequencies', {termReadingList, dictionaries});
|
||||
}
|
||||
|
||||
findAnkiNotes(query) {
|
||||
return this._invoke('findAnkiNotes', {query});
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
||||
_createActionPort(timeout=5000) {
|
||||
|
Loading…
Reference in New Issue
Block a user