From 315dc425e489dc96c2f2d4e13b500105d724ec52 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 7 Jul 2021 20:00:30 -0400 Subject: [PATCH] Anki card selected text (#1809) * Add support for injecting the text selection into Anki cards * Add selection-text * Upgrade to add {selection-text} * Update descriptions * Update test data --- README.md | 2 + ...nki-field-templates-upgrade-v13.handlebars | 4 + .../default-anki-field-templates.handlebars | 4 + ext/js/data/anki-note-builder.js | 11 ++- ext/js/data/options-util.js | 1 + ext/js/pages/settings/anki-controller.js | 2 + .../template-renderer-media-provider.js | 1 + ext/settings.html | 4 + test/data/anki-note-builder-test-results.json | 81 +++++++++++++++++++ test/test-anki-note-builder.js | 2 + test/test-options-util.js | 2 + 11 files changed, 113 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 12c76eff..de6d248d 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ Flashcard fields can be configured with the following steps: `{reading}` | Kana reading for the term (empty for terms where the expression is the reading). `{screenshot}` | Screenshot of the web page taken at the time the term was added. `{search-query}` | The full search query shown on the search page. + `{selection-text}` | The selected text on the search page or popup. `{sentence}` | Sentence, quote, or phrase that the term appears in from the source content. `{tags}` | Grammar and usage tags providing information about the term (unavailable in *grouped* mode). `{url}` | Address of the web page in which the term appeared in. @@ -199,6 +200,7 @@ Flashcard fields can be configured with the following steps: `{onyomi}` | Onyomi (Chinese reading) for the kanji expressed as hiragana. `{screenshot}` | Screenshot of the web page taken at the time the kanji was added. `{search-query}` | The full search query shown on the search page. + `{selection-text}` | The selected text on the search page or popup. `{sentence}` | Sentence, quote, or phrase that the character appears in from the source content. `{stroke-count}` | Number of strokes that the kanji character has. `{url}` | Address of the web page in which the kanji appeared in. diff --git a/ext/data/templates/anki-field-templates-upgrade-v13.handlebars b/ext/data/templates/anki-field-templates-upgrade-v13.handlebars index ebf9069e..78820b95 100644 --- a/ext/data/templates/anki-field-templates-upgrade-v13.handlebars +++ b/ext/data/templates/anki-field-templates-upgrade-v13.handlebars @@ -1,3 +1,7 @@ +{{#*inline "selection-text"}} + {{~#if (hasMedia "selectionText")}}{{#getMedia "selectionText" format="text"}}{{/getMedia}}{{/if~}} +{{/inline}} + {{<<<<<<<}} {{#each glossary}}{{#multiLine}}{{.}}{{/multiLine}}{{/each}} {{=======}} diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 62da796d..c9ee2833 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -378,4 +378,8 @@ {{~#multiLine}}{{context.fullQuery}}{{/multiLine~}} {{/inline}} +{{#*inline "selection-text"}} + {{~#if (hasMedia "selectionText")}}{{#getMedia "selectionText" format="text"}}{{/getMedia}}{{/if~}} +{{/inline}} + {{~> (lookup . "marker") ~}} diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index 65740254..23dd648b 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -283,6 +283,7 @@ class AnkiNoteBuilder { let injectScreenshot = false; let injectClipboardImage = false; let injectClipboardText = false; + let injectSelectionText = false; const dictionaryMediaDetails = []; for (const requirement of requirements) { const {type} = requirement; @@ -291,6 +292,7 @@ class AnkiNoteBuilder { case 'screenshot': injectScreenshot = true; break; case 'clipboardImage': injectClipboardImage = true; break; case 'clipboardText': injectClipboardText = true; break; + case 'selectionText': injectSelectionText = true; break; case 'dictionaryMedia': { const {dictionary, path} = requirement; @@ -323,7 +325,8 @@ class AnkiNoteBuilder { } // Inject media - const {audioFileName, screenshotFileName, clipboardImageFileName, clipboardText, dictionaryMedia: dictionaryMediaArray, errors} = await yomichan.api.injectAnkiNoteMedia( + const selectionText = injectSelectionText ? this._getSelectionText() : null; + const injectedMedia = await yomichan.api.injectAnkiNoteMedia( timestamp, dictionaryEntryDetails, audioDetails, @@ -331,6 +334,7 @@ class AnkiNoteBuilder { clipboardDetails, dictionaryMediaDetails ); + const {audioFileName, screenshotFileName, clipboardImageFileName, clipboardText, dictionaryMedia: dictionaryMediaArray, errors} = injectedMedia; // Format results const dictionaryMedia = {}; @@ -348,8 +352,13 @@ class AnkiNoteBuilder { screenshot: (typeof screenshotFileName === 'string' ? {fileName: screenshotFileName} : null), clipboardImage: (typeof clipboardImageFileName === 'string' ? {fileName: clipboardImageFileName} : null), clipboardText: (typeof clipboardText === 'string' ? {text: clipboardText} : null), + selectionText: (typeof selectionText === 'string' ? {text: selectionText} : null), dictionaryMedia }; return {media, errors}; } + + _getSelectionText() { + return document.getSelection().toString(); + } } diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index baa727d2..3d36fc2e 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -854,6 +854,7 @@ class OptionsUtil { // Version 13 changes: // Handlebars templates updated to use formatGlossary. // Handlebars templates updated to use new media format. + // Added {selection-text} field marker. await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v13.handlebars'); return options; } diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 28bb21a3..b98de1b6 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -102,6 +102,7 @@ class AnkiController { 'reading', 'screenshot', 'search-query', + 'selection-text', 'sentence', 'tags', 'url' @@ -121,6 +122,7 @@ class AnkiController { 'onyomi', 'screenshot', 'search-query', + 'selection-text', 'sentence', 'stroke-count', 'tags', diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/template-renderer-media-provider.js index db4a6d18..4fd40c67 100644 --- a/ext/js/templates/template-renderer-media-provider.js +++ b/ext/js/templates/template-renderer-media-provider.js @@ -78,6 +78,7 @@ class TemplateRendererMediaProvider { case 'screenshot': return this._getSimpleMediaData(media, 'screenshot'); case 'clipboardImage': return this._getSimpleMediaData(media, 'clipboardImage'); case 'clipboardText': return this._getSimpleMediaData(media, 'clipboardText'); + case 'selectionText': return this._getSimpleMediaData(media, 'selectionText'); case 'dictionaryMedia': return this._getDictionaryMedia(media, args[1], namedArgs); default: return null; } diff --git a/ext/settings.html b/ext/settings.html index d8d31039..49bcd722 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -2858,6 +2858,10 @@ {search-query} The full search query shown on the search page. + + {selection-text} + The selected text on the search page or popup. + {sentence} Sentence, quote, or phrase that the term or kanji appears in from the source content. diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 7a895dcb..a8a7b08a 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -16,6 +16,7 @@ "onyomi": "ダ, ダアス", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", @@ -40,6 +41,7 @@ "onyomi": "", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix込cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", @@ -78,6 +80,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -106,6 +109,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -139,6 +143,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "tags": "vt", "url": "url:" @@ -167,6 +172,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "tags": "vt", "url": "url:" @@ -195,6 +201,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "tags": "vt", "url": "url:" @@ -223,6 +230,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "tags": "vt", "url": "url:" @@ -251,6 +259,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -279,6 +288,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -312,6 +322,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -340,6 +351,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -368,6 +380,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -396,6 +409,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -424,6 +438,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -452,6 +467,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -480,6 +496,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -508,6 +525,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -536,6 +554,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -564,6 +583,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -597,6 +617,7 @@ "reading": "がぞう", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix画像cloze-suffix", "tags": "n", "url": "url:" @@ -630,6 +651,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixだcloze-suffix", "tags": "n", "url": "url:" @@ -663,6 +685,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixダースcloze-suffix", "tags": "abbr, n", "url": "url:" @@ -696,6 +719,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうつcloze-suffix", "tags": "vt", "url": "url:" @@ -724,6 +748,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうつcloze-suffix", "tags": "vt", "url": "url:" @@ -757,6 +782,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶつcloze-suffix", "tags": "vt", "url": "url:" @@ -785,6 +811,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶつcloze-suffix", "tags": "vt", "url": "url:" @@ -818,6 +845,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "vt", "url": "url:" @@ -846,6 +874,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "vt", "url": "url:" @@ -874,6 +903,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "tags": "vt", "url": "url:" @@ -902,6 +932,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "tags": "vt", "url": "url:" @@ -935,6 +966,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶちこむcloze-suffix", "tags": "vt", "url": "url:" @@ -963,6 +995,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶちこむcloze-suffix", "tags": "vt", "url": "url:" @@ -991,6 +1024,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶちcloze-suffix", "tags": "vt", "url": "url:" @@ -1019,6 +1053,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixぶちcloze-suffix", "tags": "vt", "url": "url:" @@ -1052,6 +1087,7 @@ "reading": "がぞう", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixがぞうcloze-suffix", "tags": "n", "url": "url:" @@ -1097,6 +1133,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -1125,6 +1162,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -1153,6 +1191,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1181,6 +1220,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1209,6 +1249,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -1237,6 +1278,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -1270,6 +1312,7 @@ "reading": "うちこむ、ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" @@ -1298,6 +1341,7 @@ "reading": "うつ、ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1326,6 +1370,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -1354,6 +1399,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -1387,6 +1433,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "vt", "url": "url:" @@ -1415,6 +1462,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "vt", "url": "url:" @@ -1443,6 +1491,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "vt", "url": "url:" @@ -1471,6 +1520,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "vt", "url": "url:" @@ -1499,6 +1549,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1527,6 +1578,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1555,6 +1607,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1583,6 +1636,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1611,6 +1665,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -1639,6 +1694,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -1672,6 +1728,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "vt", "url": "url:" @@ -1700,6 +1757,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "vt", "url": "url:" @@ -1728,6 +1786,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "vt", "url": "url:" @@ -1756,6 +1815,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "vt", "url": "url:" @@ -1784,6 +1844,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1812,6 +1873,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1840,6 +1902,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1868,6 +1931,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "tags": "vt", "url": "url:" @@ -1896,6 +1960,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" @@ -1924,6 +1989,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -1957,6 +2023,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "vt", "url": "url:" @@ -1985,6 +2052,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "vt", "url": "url:" @@ -2013,6 +2081,7 @@ "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "vt", "url": "url:" @@ -2041,6 +2110,7 @@ "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "vt", "url": "url:" @@ -2069,6 +2139,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "vt", "url": "url:" @@ -2097,6 +2168,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "vt", "url": "url:" @@ -2125,6 +2197,7 @@ "reading": "うつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "vt", "url": "url:" @@ -2153,6 +2226,7 @@ "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "tags": "vt", "url": "url:" @@ -2181,6 +2255,7 @@ "reading": "だ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)cloze-suffix", "tags": "n", "url": "url:" @@ -2209,6 +2284,7 @@ "reading": "ダース", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefix(打)cloze-suffix", "tags": "abbr, n", "url": "url:" @@ -2242,6 +2318,7 @@ "reading": "よむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixtestcloze-suffix", "tags": "vt", "url": "url:" @@ -2275,6 +2352,7 @@ "reading": "つよみ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixつtestcloze-suffix", "tags": "n", "url": "url:" @@ -2308,6 +2386,7 @@ "reading": "よむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixtestましたcloze-suffix", "tags": "vt", "url": "url:" @@ -2341,6 +2420,7 @@ "reading": "うちこむ、ぶちこむ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "tags": "vt", "url": "url:" @@ -2369,6 +2449,7 @@ "reading": "うつ、ぶつ", "screenshot": "", "search-query": "fullQuery", + "selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "tags": "vt", "url": "url:" diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js index 607388fc..af9cd061 100644 --- a/test/test-anki-note-builder.js +++ b/test/test-anki-note-builder.js @@ -158,6 +158,7 @@ function getFieldMarkers(type) { 'reading', 'screenshot', 'search-query', + 'selection-text', 'sentence', 'tags', 'url' @@ -177,6 +178,7 @@ function getFieldMarkers(type) { 'onyomi', 'screenshot', 'search-query', + 'selection-text', 'sentence', 'stroke-count', 'tags', diff --git a/test/test-options-util.js b/test/test-options-util.js index 15a11265..d4a3bf9a 100644 --- a/test/test-options-util.js +++ b/test/test-options-util.js @@ -959,6 +959,7 @@ async function testFieldTemplatesUpdate(extDir) { {{~/if~}} {{/inline}} +<<>> {{~> (lookup . "marker") ~}}`.trimStart() }, // hasMedia/getMedia update @@ -1011,6 +1012,7 @@ async function testFieldTemplatesUpdate(extDir) { {{~#if (hasMedia "clipboardText")}}{{#getMedia "clipboardText" format="text"}}{{/getMedia}}{{/if~}} {{/inline}} +<<>> {{~> (lookup . "marker") ~}}`.trimStart() } ];