Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions ext/data/templates/anki-field-templates-upgrade-v77.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{<<<<<<<}}
{{~#*inline "glossary-first"~}}
<div style="text-align: left;" class="yomitan-glossary">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
{{~#if definition.glossaryScopedStyles~}}
<style>{{{definition.glossaryScopedStyles}}}</style>
{{~/if~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
{{~#with definition.definitions.[0]~}}
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
{{~/with~}}
{{~else~}}
{{~#with definition.definitions.[0]~}}
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
{{~/with~}}
{{~/if~}}
{{~/if~}}
{{~/scope~}}
</div>
{{~/inline~}}
{{=======}}
{{~#*inline "glossary-first"~}}
<div style="text-align: left;" class="yomitan-glossary">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</div>
{{~#if definition.glossaryScopedStyles~}}
<style>{{{definition.glossaryScopedStyles}}}</style>
{{~/if~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
{{~#with definition.definitions.[0]~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</div>
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
{{~/with~}}
{{~else~}}
{{~#with definition.definitions.[0]~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</div>
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
{{~/with~}}
{{~/if~}}
{{~/if~}}
{{~/scope~}}
</div>
{{~/inline~}}
{{>>>>>>>}}
12 changes: 9 additions & 3 deletions ext/data/templates/default-anki-field-templates.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,27 @@
<div style="text-align: left;" class="yomitan-glossary">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
Comment on lines +156 to +157

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Render term glossary-first from the definition context

For non-grouped term definitions this block is still in the root render context, so dictionary and . are not the term definition; the previous template passed definition explicitly. In that scenario {glossary-first} now emits an empty data-dictionary and an empty glossary/tag block (the updated test expectations include data-dictionary="" and <ul></ul>), which breaks ordinary term cards using this marker. Pass definition to glossary-single and read definition.dictionary here, and apply the same correction in the v77 upgrade template.

Useful? React with 👍 / 👎.

</div>
{{~#if definition.glossaryScopedStyles~}}
<style>{{{definition.glossaryScopedStyles}}}</style>
{{~/if~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
{{~#with definition.definitions.[0]~}}
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</div>
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
{{~/with~}}
{{~else~}}
{{~#with definition.definitions.[0]~}}
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
<div data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</div>
{{~#if glossaryScopedStyles~}}
<style>{{{glossaryScopedStyles}}}</style>
{{~/if~}}
Expand Down
9 changes: 9 additions & 0 deletions ext/js/data/options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export class OptionsUtil {
this._updateVersion74,
this._updateVersion75,
this._updateVersion76,
this._updateVersion77,
];
/* eslint-enable @typescript-eslint/unbound-method */
if (typeof targetVersion === 'number' && targetVersion < result.length) {
Expand Down Expand Up @@ -1851,6 +1852,14 @@ export class OptionsUtil {
}
}

/**
* - Fix {glossary-first} handlebar not including data-dictionary in html
* @type {import('options-util').UpdateFunction}
*/
async _updateVersion77(options) {
await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v77.handlebars');
}

/**
* @param {string} url
* @returns {Promise<chrome.tabs.Tab>}
Expand Down
Loading
Loading