From 85af21316e4f95f03f745373bac188fa22564c7a Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:16:45 -0500 Subject: [PATCH] Add {sentence-furigana-plain} handlebar (#1834) * Initial implementation * Add handlebars update * Fix distribution of furigana when rendered * Deduplicate code * Add to docs and dropdown * Update tests * Consolidate textFurigana and textFuriganaPlain --- ...nki-field-templates-upgrade-v61.handlebars | 9 ++ .../default-anki-field-templates.handlebars | 10 ++ ext/js/data/anki-note-builder.js | 26 ++++- ext/js/data/anki-template-util.js | 2 + ext/js/data/options-util.js | 9 ++ .../template-renderer-media-provider.js | 13 ++- ext/templates-modals.html | 4 + test/data/anki-note-builder-test-results.json | 109 ++++++++++++++++++ test/options-util.test.js | 2 +- types/ext/anki-note-builder.d.ts | 2 + types/ext/anki-templates.d.ts | 3 +- 11 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 ext/data/templates/anki-field-templates-upgrade-v61.handlebars diff --git a/ext/data/templates/anki-field-templates-upgrade-v61.handlebars b/ext/data/templates/anki-field-templates-upgrade-v61.handlebars new file mode 100644 index 0000000000..781d9f6387 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v61.handlebars @@ -0,0 +1,9 @@ +{{#*inline "sentence-furigana-plain"}} + {{~#if definition.cloze~}} + {{~#if (hasMedia "textFuriganaPlain" definition.cloze.sentence)~}} + {{{getMedia "textFuriganaPlain" definition.cloze.sentence escape=false}}} + {{~else~}} + {{{definition.cloze.sentence}}} + {{~/if~}} + {{~/if~}} +{{/inline}} \ No newline at end of file diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index a065e3848c..8efe3df51e 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -472,4 +472,14 @@ {{~/if~}} {{/inline}} +{{#*inline "sentence-furigana-plain"}} + {{~#if definition.cloze~}} + {{~#if (hasMedia "textFuriganaPlain" definition.cloze.sentence)~}} + {{{getMedia "textFuriganaPlain" definition.cloze.sentence escape=false}}} + {{~else~}} + {{{definition.cloze.sentence}}} + {{~/if~}} + {{~/if~}} +{{/inline}} + {{~> (lookup . "marker") ~}} diff --git a/ext/js/data/anki-note-builder.js b/ext/js/data/anki-note-builder.js index d7dcbcbac2..a9e7d144ee 100644 --- a/ext/js/data/anki-note-builder.js +++ b/ext/js/data/anki-note-builder.js @@ -522,8 +522,9 @@ export class AnkiNoteBuilder { break; } if (data !== null) { - const value = this._createFuriganaHtml(data, readingMode); - results.push({text, readingMode, details: {value}}); + const valueHtml = this._createFuriganaHtml(data, readingMode); + const valuePlain = this._createFuriganaPlain(data, readingMode); + results.push({text, readingMode, detailsHtml: {value: valueHtml}, detailsPlain: {value: valuePlain}}); } } return results; @@ -551,6 +552,27 @@ export class AnkiNoteBuilder { return result; } + /** + * @param {import('api').ParseTextLine[]} data + * @param {?import('anki-templates').TextFuriganaReadingMode} readingMode + * @returns {string} + */ + _createFuriganaPlain(data, readingMode) { + let result = ''; + for (const term of data) { + for (const {text, reading} of term) { + if (reading.length > 0) { + const reading2 = this._convertReading(reading, readingMode); + result += ` ${text}[${reading2}]`; + } else { + result += text; + } + } + } + result = result.substring(1); + return result; + } + /** * @param {string} reading * @param {?import('anki-templates').TextFuriganaReadingMode} readingMode diff --git a/ext/js/data/anki-template-util.js b/ext/js/data/anki-template-util.js index 4c8127ae5f..94384a29f0 100644 --- a/ext/js/data/anki-template-util.js +++ b/ext/js/data/anki-template-util.js @@ -63,6 +63,7 @@ export function getStandardFieldMarkers(type) { 'popup-selection-text', 'sentence', 'sentence-furigana', + 'sentence-furigana-plain', 'tags', 'url', ]; @@ -91,6 +92,7 @@ export function getStandardFieldMarkers(type) { 'popup-selection-text', 'sentence', 'sentence-furigana', + 'sentence-furigana-plain', 'stroke-count', 'tags', 'url', diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index b4d6129940..50b94d2e04 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -572,6 +572,7 @@ export class OptionsUtil { this._updateVersion58, this._updateVersion59, this._updateVersion60, + this._updateVersion61, ]; /* eslint-enable @typescript-eslint/unbound-method */ if (typeof targetVersion === 'number' && targetVersion < result.length) { @@ -1606,6 +1607,14 @@ export class OptionsUtil { } } + /** + * - Added sentence-furigana-plain handlebar + * @type {import('options-util').UpdateFunction} + */ + async _updateVersion61(options) { + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v61.handlebars'); + } + /** * @param {string} url * @returns {Promise} diff --git a/ext/js/templates/template-renderer-media-provider.js b/ext/js/templates/template-renderer-media-provider.js index 52b40382dc..4d0258b462 100644 --- a/ext/js/templates/template-renderer-media-provider.js +++ b/ext/js/templates/template-renderer-media-provider.js @@ -102,7 +102,8 @@ export class TemplateRendererMediaProvider { case 'clipboardImage': return this._getSimpleMediaData(media, 'clipboardImage'); case 'clipboardText': return this._getSimpleMediaData(media, 'clipboardText'); case 'popupSelectionText': return this._getSimpleMediaData(media, 'popupSelectionText'); - case 'textFurigana': return this._getTextFurigana(media, args[1], namedArgs); + case 'textFurigana': return this._getTextFurigana(media, args[1], namedArgs, 'furiganaHtml'); + case 'textFuriganaPlain': return this._getTextFurigana(media, args[1], namedArgs, 'furiganaPlain'); case 'dictionaryMedia': return this._getDictionaryMedia(media, args[1], namedArgs); default: return null; } @@ -155,16 +156,22 @@ export class TemplateRendererMediaProvider { * @param {import('anki-templates').Media} media * @param {unknown} text * @param {import('core').SerializableObject} namedArgs + * @param {import('anki-note-builder').TextFuriganaFormats} furiganaFormat * @returns {?import('anki-templates').MediaObject} */ - _getTextFurigana(media, text, namedArgs) { + _getTextFurigana(media, text, namedArgs, furiganaFormat) { if (typeof text !== 'string') { return null; } const readingMode = this._normalizeReadingMode(namedArgs.readingMode); const {textFurigana} = media; if (Array.isArray(textFurigana)) { for (const entry of textFurigana) { if (entry.text !== text || entry.readingMode !== readingMode) { continue; } - return entry.details; + switch (furiganaFormat) { + case 'furiganaHtml': + return entry.detailsHtml; + case 'furiganaPlain': + return entry.detailsPlain; + } } } this._addRequirement({ diff --git a/ext/templates-modals.html b/ext/templates-modals.html index 04cf78793c..c19d262ddf 100644 --- a/ext/templates-modals.html +++ b/ext/templates-modals.html @@ -1122,6 +1122,10 @@

Pronunciation Dictionaries

{sentence-furigana} Sentence, quote, or phrase that the term or kanji appears in from the source content, with furigana added. + + {sentence-furigana-plain} + Sentence, quote, or phrase that the term or kanji appears in from the source content, with furigana added in brackets. + {url} Address of the web page in which the term or kanji appeared in. diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 06abe67ea9..b06a67e5d0 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -26,6 +26,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", "url": "url:" @@ -59,6 +60,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix込cloze-suffix", "sentence-furigana": "cloze-prefix込cloze-suffix", + "sentence-furigana-plain": "cloze-prefix込cloze-suffix", "stroke-count": "Stroke count: Unknown", "tags": "", "url": "url:" @@ -111,6 +113,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -153,6 +156,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -200,6 +204,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "sentence-furigana": "cloze-prefix打つcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打つcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -242,6 +247,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "sentence-furigana": "cloze-prefix打つcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打つcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -284,6 +290,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "sentence-furigana": "cloze-prefix打つcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打つcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -326,6 +333,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打つcloze-suffix", "sentence-furigana": "cloze-prefix打つcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打つcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -368,6 +376,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -410,6 +419,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -457,6 +467,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -499,6 +510,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -541,6 +553,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -583,6 +596,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -625,6 +639,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -667,6 +682,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -709,6 +725,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -751,6 +768,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -793,6 +811,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -835,6 +854,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -882,6 +902,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix画像cloze-suffix", "sentence-furigana": "cloze-prefix画像cloze-suffix", + "sentence-furigana-plain": "cloze-prefix画像cloze-suffix", "tags": "E1, P, n", "url": "url:" } @@ -929,6 +950,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixだcloze-suffix", "sentence-furigana": "cloze-prefixだcloze-suffix", + "sentence-furigana-plain": "cloze-prefixだcloze-suffix", "tags": "E1, n", "url": "url:" } @@ -976,6 +998,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixダースcloze-suffix", "sentence-furigana": "cloze-prefixダースcloze-suffix", + "sentence-furigana-plain": "cloze-prefixダースcloze-suffix", "tags": "E1, abbr, n", "url": "url:" }, @@ -1018,6 +1041,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixダcloze-suffix", "sentence-furigana": "cloze-prefixダcloze-suffix", + "sentence-furigana-plain": "cloze-prefixダcloze-suffix", "tags": "E1, n", "url": "url:" } @@ -1065,6 +1089,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうつcloze-suffix", "sentence-furigana": "cloze-prefixうつcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうつcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1107,6 +1132,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうつcloze-suffix", "sentence-furigana": "cloze-prefixうつcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうつcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -1154,6 +1180,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶつcloze-suffix", "sentence-furigana": "cloze-prefixぶつcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶつcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1196,6 +1223,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶつcloze-suffix", "sentence-furigana": "cloze-prefixぶつcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶつcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -1243,6 +1271,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "sentence-furigana": "cloze-prefixうちこむcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちこむcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1285,6 +1314,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "sentence-furigana": "cloze-prefixうちこむcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちこむcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -1327,6 +1357,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "sentence-furigana": "cloze-prefixうちcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1369,6 +1400,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "sentence-furigana": "cloze-prefixうちcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -1416,6 +1448,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶちこむcloze-suffix", "sentence-furigana": "cloze-prefixぶちこむcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶちこむcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1458,6 +1491,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶちこむcloze-suffix", "sentence-furigana": "cloze-prefixぶちこむcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶちこむcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -1500,6 +1534,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶちcloze-suffix", "sentence-furigana": "cloze-prefixぶちcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -1542,6 +1577,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixぶちcloze-suffix", "sentence-furigana": "cloze-prefixぶちcloze-suffix", + "sentence-furigana-plain": "cloze-prefixぶちcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -1589,6 +1625,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixがぞうcloze-suffix", "sentence-furigana": "cloze-prefixがぞうcloze-suffix", + "sentence-furigana-plain": "cloze-prefixがぞうcloze-suffix", "tags": "E1, P, n", "url": "url:" } @@ -1648,6 +1685,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E1, E2, P, vt", "url": "url:" }, @@ -1690,6 +1728,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "E1, E2, P, vt", "url": "url:" }, @@ -1732,6 +1771,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, E2, P, vt", "url": "url:" }, @@ -1774,6 +1814,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, E2, P, vt", "url": "url:" }, @@ -1816,6 +1857,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -1858,6 +1900,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -1905,6 +1948,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込むcloze-suffix", "sentence-furigana": "cloze-prefix打ち込むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込むcloze-suffix", "tags": "vt", "url": "url:" }, @@ -1947,6 +1991,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "vt", "url": "url:" }, @@ -1989,6 +2034,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "n", "url": "url:" }, @@ -2031,6 +2077,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "abbr, n", "url": "url:" } @@ -2078,6 +2125,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "sentence-furigana": "cloze-prefix打ち込んでいませんでしたcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2120,6 +2168,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "sentence-furigana": "cloze-prefix打ち込んでいませんでしたcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2162,6 +2211,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "sentence-furigana": "cloze-prefix打ち込んでいませんでしたcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2204,6 +2254,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "sentence-furigana": "cloze-prefix打ち込んでいませんでしたcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ち込んでいませんでしたcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2246,6 +2297,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2288,6 +2340,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2330,6 +2383,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2372,6 +2426,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打ちcloze-suffix", "sentence-furigana": "cloze-prefix打ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2414,6 +2469,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -2456,6 +2512,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打cloze-suffix", "sentence-furigana": "cloze-prefix打cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -2503,6 +2560,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ち込(こ)むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2545,6 +2603,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ち込(こ)むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2587,6 +2646,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ち込(こ)むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2629,6 +2689,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ち込(こ)むcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ち込(こ)むcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2671,6 +2732,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2713,6 +2775,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ちcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2755,6 +2818,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2797,6 +2861,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)ちcloze-suffix", "sentence-furigana": "cloze-prefix打(う)ちcloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)ちcloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -2839,6 +2904,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)cloze-suffix", "sentence-furigana": "cloze-prefix打(う)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -2881,6 +2947,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix打(う)cloze-suffix", "sentence-furigana": "cloze-prefix打(う)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix打(う)cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -2928,6 +2995,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -2970,6 +3038,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -3012,6 +3081,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -3054,6 +3124,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)(込)(む)cloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -3096,6 +3167,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)cloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -3138,6 +3210,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)cloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -3180,6 +3253,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)cloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -3222,6 +3296,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)(ち)cloze-suffix", "sentence-furigana": "cloze-prefix(打)(ち)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)(ち)cloze-suffix", "tags": "E2, P, vt", "url": "url:" }, @@ -3264,6 +3339,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)cloze-suffix", "sentence-furigana": "cloze-prefix(打)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)cloze-suffix", "tags": "E1, n", "url": "url:" }, @@ -3306,6 +3382,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix(打)cloze-suffix", "sentence-furigana": "cloze-prefix(打)cloze-suffix", + "sentence-furigana-plain": "cloze-prefix(打)cloze-suffix", "tags": "E1, abbr, n", "url": "url:" } @@ -3353,6 +3430,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixtestcloze-suffix", "sentence-furigana": "cloze-prefixtestcloze-suffix", + "sentence-furigana-plain": "cloze-prefixtestcloze-suffix", "tags": "E1, P, vt", "url": "url:" } @@ -3400,6 +3478,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixつtestcloze-suffix", "sentence-furigana": "cloze-prefixつtestcloze-suffix", + "sentence-furigana-plain": "cloze-prefixつtestcloze-suffix", "tags": "E1, P, n", "url": "url:" } @@ -3447,6 +3526,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixtestましたcloze-suffix", "sentence-furigana": "cloze-prefixtestましたcloze-suffix", + "sentence-furigana-plain": "cloze-prefixtestましたcloze-suffix", "tags": "E1, P, vt", "url": "url:" } @@ -3494,6 +3574,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちこむcloze-suffix", "sentence-furigana": "cloze-prefixうちこむcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちこむcloze-suffix", "tags": "vt", "url": "url:" }, @@ -3536,6 +3617,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixうちcloze-suffix", "sentence-furigana": "cloze-prefixうちcloze-suffix", + "sentence-furigana-plain": "cloze-prefixうちcloze-suffix", "tags": "vt", "url": "url:" } @@ -3583,6 +3665,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixお手前cloze-suffix", "sentence-furigana": "cloze-prefixお手前cloze-suffix", + "sentence-furigana-plain": "cloze-prefixお手前cloze-suffix", "tags": "n", "url": "url:" } @@ -3630,6 +3713,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix番号cloze-suffix", "sentence-furigana": "cloze-prefix番号cloze-suffix", + "sentence-furigana-plain": "cloze-prefix番号cloze-suffix", "tags": "n", "url": "url:" } @@ -3677,6 +3761,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix中腰cloze-suffix", "sentence-furigana": "cloze-prefix中腰cloze-suffix", + "sentence-furigana-plain": "cloze-prefix中腰cloze-suffix", "tags": "n", "url": "url:" } @@ -3724,6 +3809,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix所業cloze-suffix", "sentence-furigana": "cloze-prefix所業cloze-suffix", + "sentence-furigana-plain": "cloze-prefix所業cloze-suffix", "tags": "n", "url": "url:" } @@ -3771,6 +3857,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix土木工事cloze-suffix", "sentence-furigana": "cloze-prefix土木工事cloze-suffix", + "sentence-furigana-plain": "cloze-prefix土木工事cloze-suffix", "tags": "n", "url": "url:" } @@ -3818,6 +3905,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix好きcloze-suffix", "sentence-furigana": "cloze-prefix好きcloze-suffix", + "sentence-furigana-plain": "cloze-prefix好きcloze-suffix", "tags": "adj-na, n", "url": "url:" } @@ -3865,6 +3953,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix構造cloze-suffix", "sentence-furigana": "cloze-prefix構造cloze-suffix", + "sentence-furigana-plain": "cloze-prefix構造cloze-suffix", "tags": "E1, P, n", "url": "url:" } @@ -3912,6 +4001,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixのたもうたcloze-suffix", "sentence-furigana": "cloze-prefixのたもうたcloze-suffix", + "sentence-furigana-plain": "cloze-prefixのたもうたcloze-suffix", "tags": "v5", "url": "url:" } @@ -3959,6 +4049,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix39cloze-suffix", "sentence-furigana": "cloze-prefix39cloze-suffix", + "sentence-furigana-plain": "cloze-prefix39cloze-suffix", "tags": "", "url": "url:" } @@ -4006,6 +4097,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixEnglishcloze-suffix", "sentence-furigana": "cloze-prefixEnglishcloze-suffix", + "sentence-furigana-plain": "cloze-prefixEnglishcloze-suffix", "tags": "n", "url": "url:" } @@ -4053,6 +4145,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixUSBcloze-suffix", "sentence-furigana": "cloze-prefixUSBcloze-suffix", + "sentence-furigana-plain": "cloze-prefixUSBcloze-suffix", "tags": "n", "url": "url:" } @@ -4100,6 +4193,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixutsucloze-suffix", "sentence-furigana": "cloze-prefixutsucloze-suffix", + "sentence-furigana-plain": "cloze-prefixutsucloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -4142,6 +4236,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixutsucloze-suffix", "sentence-furigana": "cloze-prefixutsucloze-suffix", + "sentence-furigana-plain": "cloze-prefixutsucloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -4189,6 +4284,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixウツcloze-suffix", "sentence-furigana": "cloze-prefixウツcloze-suffix", + "sentence-furigana-plain": "cloze-prefixウツcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -4231,6 +4327,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixウツcloze-suffix", "sentence-furigana": "cloze-prefixウツcloze-suffix", + "sentence-furigana-plain": "cloze-prefixウツcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -4278,6 +4375,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixてきすとcloze-suffix", "sentence-furigana": "cloze-prefixてきすとcloze-suffix", + "sentence-furigana-plain": "cloze-prefixてきすとcloze-suffix", "tags": "E1, P, n", "url": "url:" } @@ -4325,6 +4423,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixウツcloze-suffix", "sentence-furigana": "cloze-prefixウツcloze-suffix", + "sentence-furigana-plain": "cloze-prefixウツcloze-suffix", "tags": "E1, P, vt", "url": "url:" }, @@ -4367,6 +4466,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixウツcloze-suffix", "sentence-furigana": "cloze-prefixウツcloze-suffix", + "sentence-furigana-plain": "cloze-prefixウツcloze-suffix", "tags": "E2, P, vt", "url": "url:" } @@ -4414,6 +4514,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixすっっごーーいcloze-suffix", "sentence-furigana": "cloze-prefixすっっごーーいcloze-suffix", + "sentence-furigana-plain": "cloze-prefixすっっごーーいcloze-suffix", "tags": "adj-i", "url": "url:" } @@ -4461,6 +4562,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixenglishcloze-suffix", "sentence-furigana": "cloze-prefixenglishcloze-suffix", + "sentence-furigana-plain": "cloze-prefixenglishcloze-suffix", "tags": "n", "url": "url:" } @@ -4508,6 +4610,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixLANGUAGEcloze-suffix", "sentence-furigana": "cloze-prefixLANGUAGEcloze-suffix", + "sentence-furigana-plain": "cloze-prefixLANGUAGEcloze-suffix", "tags": "n", "url": "url:" } @@ -4555,6 +4658,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix마시거나cloze-suffix", "sentence-furigana": "cloze-prefix마시거나cloze-suffix", + "sentence-furigana-plain": "cloze-prefix마시거나cloze-suffix", "tags": "v", "url": "url:" } @@ -4602,6 +4706,7 @@ "popup-selection-text": "", "sentence": "cloze-prefixenglishcloze-suffix", "sentence-furigana": "cloze-prefixenglishcloze-suffix", + "sentence-furigana-plain": "cloze-prefixenglishcloze-suffix", "tags": "n", "url": "url:" } @@ -4649,6 +4754,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix自重cloze-suffix", "sentence-furigana": "cloze-prefix自重cloze-suffix", + "sentence-furigana-plain": "cloze-prefix自重cloze-suffix", "tags": "n", "url": "url:" }, @@ -4691,6 +4797,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix自重cloze-suffix", "sentence-furigana": "cloze-prefix自重cloze-suffix", + "sentence-furigana-plain": "cloze-prefix自重cloze-suffix", "tags": "n", "url": "url:" } @@ -4738,6 +4845,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix自重cloze-suffix", "sentence-furigana": "cloze-prefix自重cloze-suffix", + "sentence-furigana-plain": "cloze-prefix自重cloze-suffix", "tags": "n", "url": "url:" }, @@ -4780,6 +4888,7 @@ "popup-selection-text": "", "sentence": "cloze-prefix自重cloze-suffix", "sentence-furigana": "cloze-prefix自重cloze-suffix", + "sentence-furigana-plain": "cloze-prefix自重cloze-suffix", "tags": "n", "url": "url:" } diff --git a/test/options-util.test.js b/test/options-util.test.js index 8505a27204..08230c3b7b 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -680,7 +680,7 @@ function createOptionsUpdatedTestData1() { }, ], profileCurrent: 0, - version: 60, + version: 61, global: { database: { prefixWildcardsSupported: false, diff --git a/types/ext/anki-note-builder.d.ts b/types/ext/anki-note-builder.d.ts index e2a8d1af59..fcade7e34b 100644 --- a/types/ext/anki-note-builder.d.ts +++ b/types/ext/anki-note-builder.d.ts @@ -82,6 +82,8 @@ export type RequirementTextFurigana = { readingMode: AnkiTemplates.TextFuriganaReadingMode; }; +export type TextFuriganaFormats = 'furiganaHtml' | 'furiganaPlain'; + export type RequirementDictionaryMedia = { type: 'dictionaryMedia'; dictionary: string; diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index b9b864122b..c78edc7501 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -50,7 +50,8 @@ export type MediaSimpleType = ( export type TextFuriganaSegment = { text: string; readingMode: TextFuriganaReadingMode; - details: MediaObject; + detailsHtml: MediaObject; + detailsPlain: MediaObject; }; export type TextFuriganaReadingMode = 'hiragana' | 'katakana' | null;