diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-07 19:00:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 19:00:58 -0400 |
commit | fa68a8773605ee0943e1c5e9766fa6bcfb6c6a42 (patch) | |
tree | 3ac714d3b485b1a1b6b349f48a91a67045256f81 /ext/mixed/js/display.js | |
parent | 3df78904cf734da208c6fd1b6ae1cd6612323148 (diff) | |
parent | 29cf8d2f79f23b7723d508085ca242396bbbd5c9 (diff) |
Merge pull request #415 from toasted-nutbread/anki-marker-document-title
Anki marker document title
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r-- | ext/mixed/js/display.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 4a71efe0..2f456c3e 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -752,15 +752,16 @@ class Display { try { this.setSpinnerVisible(true); - const context = {}; + const details = {}; if (this.noteUsesScreenshot(mode)) { const screenshot = await this.getScreenshot(); if (screenshot) { - context.screenshot = screenshot; + details.screenshot = screenshot; } } - const noteId = await apiDefinitionAdd(definition, mode, context, this.getOptionsContext()); + const context = await this._getNoteContext(); + const noteId = await apiDefinitionAdd(definition, mode, context, details, this.getOptionsContext()); if (noteId) { const index = this.definitions.indexOf(definition); const adderButton = this.adderButtonFind(index, mode); @@ -908,12 +909,17 @@ class Display { async getDefinitionsAddable(definitions, modes) { try { - return await apiDefinitionsAddable(definitions, modes, this.getOptionsContext()); + const context = await this._getNoteContext(); + return await apiDefinitionsAddable(definitions, modes, context, this.getOptionsContext()); } catch (e) { return []; } } + async getDocumentTitle() { + return document.title; + } + static indexOf(nodeList, node) { for (let i = 0, ii = nodeList.length; i < ii; ++i) { if (nodeList[i] === node) { @@ -934,6 +940,15 @@ class Display { return (typeof key === 'string' ? (key.length === 1 ? key.toUpperCase() : key) : ''); } + async _getNoteContext() { + const documentTitle = await this.getDocumentTitle(); + return { + document: { + title: documentTitle + } + }; + } + async _getAudioUri(definition, source) { const optionsContext = this.getOptionsContext(); return await apiAudioGetUri(definition, source, optionsContext); |