diff options
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);  |