diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-31 20:07:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 20:07:11 -0400 |
commit | 5d7309ed5474a9fb67b9cae1b1176bc10bde6115 (patch) | |
tree | 3dd2f58e8b365298d5a75a3a360899803b67e0b8 /ext/js/display/display.js | |
parent | da612bbdd7c5ac15ed64497666f6415c525c823f (diff) |
Log Anki data (#1579)
* Remove unused modifierPost
* Add _getModifier
* Add _getModifiedData
* Add getModifiedData
* Add getRenderingData
* Update logging to also log anki note data
* Fix dangling comma
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r-- | ext/js/display/display.js | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 7ded1e09..3f56e081 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -757,9 +757,7 @@ class Display extends EventDispatcher { _onDebugLogClick(e) { const link = e.currentTarget; const index = this._getClosestDefinitionIndex(link); - if (index < 0 || index >= this._definitions.length) { return; } - const definition = this._definitions[index]; - console.log(definition); + this._logDefinitionData(index); } _onDocumentElementMouseUp(e) { @@ -1375,6 +1373,7 @@ class Display extends EventDispatcher { } _replaceHistoryStateNoNavigate(state, content) { + console.trace('_replaceHistoryStateNoNavigate', state); const historyChangeIgnorePre = this._historyChangeIgnore; try { this._historyChangeIgnore = true; @@ -1866,4 +1865,32 @@ class Display extends EventDispatcher { const queryPostProcessor = this._queryPostProcessor; return typeof queryPostProcessor === 'function' ? queryPostProcessor(query) : query; } + + async _logDefinitionData(index) { + if (index < 0 || index >= this._definitions.length) { return; } + const definition = this._definitions[index]; + let ankiNoteData; + let ankiNoteDataException; + try { + const context = this._getNoteContext(); + const {general: {resultOutputMode, glossaryLayoutMode, compactTags}} = this._options; + ankiNoteData = await this._ankiNoteBuilder.getRenderingData({ + definition, + mode: 'test', + context, + resultOutputMode, + glossaryLayoutMode, + compactTags, + injectedMedia: null, + marker: 'test' + }); + } catch (e) { + ankiNoteDataException = e; + } + const result = {definition, ankiNoteData}; + if (typeof ankiNoteDataException !== 'undefined') { + result.ankiNoteDataException = ankiNoteDataException; + } + console.log(result); + } } |