henkan 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -2741,17 +2741,22 @@ function generateAnkiNote(entry) {
2741
2741
  )
2742
2742
  ).join("")}</details>` : "";
2743
2743
  const readingsField = `${firstReading}${otherReadings}`;
2744
- const firstReadingWithoutAudio = createEntry(
2745
- `<span class="word word-reading">${entry.readings[0].reading}</span>`,
2746
- entry.readings[0].notes
2747
- );
2748
- const otherReadingsWithoutAudio = entry.readings.length > 1 ? `<details><summary>Show other readings</summary>${entry.readings.slice(1).map(
2749
- (readingEntry) => createEntry(
2750
- `<span class="word word-reading">${readingEntry.reading}</span>`,
2751
- readingEntry.notes
2752
- )
2753
- ).join("")}</details>` : "";
2754
- const readingsFieldWithoutAudio = `${firstReadingWithoutAudio}${otherReadingsWithoutAudio}`;
2744
+ let readingsFieldWithoutAudio = '<div id="no-r-audio" style="display: none"></div>';
2745
+ let hasAudio = false;
2746
+ if (entry.readings.some((r) => r.audio !== void 0)) {
2747
+ const firstReadingWithoutAudio = createEntry(
2748
+ `<span class="word word-reading">${entry.readings[0].reading}</span>`,
2749
+ entry.readings[0].notes
2750
+ );
2751
+ const otherReadingsWithoutAudio = entry.readings.length > 1 ? `<details><summary>Show other readings</summary>${entry.readings.slice(1).map(
2752
+ (readingEntry) => createEntry(
2753
+ `<span class="word word-reading">${readingEntry.reading}</span>`,
2754
+ readingEntry.notes
2755
+ )
2756
+ ).join("")}</details>` : "";
2757
+ readingsFieldWithoutAudio = `${firstReadingWithoutAudio}${otherReadingsWithoutAudio}`;
2758
+ hasAudio = true;
2759
+ }
2755
2760
  const firstKanjiForm = entry.kanjiForms !== void 0 ? createEntry(
2756
2761
  `<span class="word word-kanjiform"><ruby><rb>${entry.kanjiForms[0].kanjiForm}</rb><rt>${entry.readings[0].reading}</rt></ruby></span>`,
2757
2762
  entry.kanjiForms[0].notes
@@ -2823,13 +2828,16 @@ function generateAnkiNote(entry) {
2823
2828
  ) : "null"
2824
2829
  ).filter((definition) => definition !== "null").join("")}</details>` : "";
2825
2830
  const definitionsField = firstThreeDefinitions !== void 0 ? `${firstThreeDefinitions}${otherDefinitions}` : '<span class="word word-definition">(no definitions)</span>';
2826
- const searchField = [
2827
- entry.readings.map((r) => r.reading),
2828
- entry.kanjiForms?.map((kf) => kf.kanjiForm) ?? []
2829
- ].join(" ");
2831
+ const searchField = `${entry.readings.map((r) => r.reading).join(" ")}${entry.kanjiForms !== void 0 ? ` ${entry.kanjiForms.map((kf) => kf.kanjiForm).join(" ")}` : ""} ${entry.id}`;
2830
2832
  fields.push(
2831
- ...entry.kanjiForms !== void 0 && !entry.usuallyInKana ? [kanjiFormsField, readingsFieldWithoutAudio] : [readingsFieldWithoutAudio, kanjiFormsField],
2832
- readingsField,
2833
+ ...entry.kanjiForms !== void 0 && !entry.usuallyInKana ? [
2834
+ `${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="1"></div>`,
2835
+ `${hasAudio ? readingsFieldWithoutAudio : readingsField}<div id="r-pos" style="display: none" data-pos="2"></div>`
2836
+ ] : [
2837
+ `${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="2"></div>`,
2838
+ `${hasAudio ? readingsFieldWithoutAudio : readingsField}<div id="r-pos" style="display: none" data-pos="1"></div>`
2839
+ ],
2840
+ `${hasAudio ? readingsField : readingsFieldWithoutAudio}<div id="r-pos" style="display: none" data-pos="${entry.kanjiForms !== void 0 && !entry.usuallyInKana ? "2" : "1"}"></div>`,
2833
2841
  translationsField,
2834
2842
  phrasesField,
2835
2843
  definitionsField,