henkan 2.4.6 → 2.4.7

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
@@ -2727,7 +2727,7 @@ function isGrammar(entry) {
2727
2727
  }
2728
2728
  var createNotes = (notes, phrase) => `${phrase === true ? "<details><summary>Show translation</summary>" : ""}<ul class="note-list">${notes.map((note) => `<li class="note">${note}</li>`).join("")}</ul>${phrase === true ? "</details>" : ""}`;
2729
2729
  var createEntry = (entry, notes, phrase, glossSpecific) => `<div class="entry${glossSpecific === true ? " gloss-specific" : ""}">${entry}${notes !== void 0 && notes.length > 0 ? createNotes(notes, phrase) : ""}</div>`;
2730
- function generateAnkiNote(entry) {
2730
+ function generateAnkiNote(entry, customData) {
2731
2731
  const fields = [];
2732
2732
  if (isWord(entry)) {
2733
2733
  const firstReading = createEntry(
@@ -2831,10 +2831,10 @@ function generateAnkiNote(entry) {
2831
2831
  const searchField = `${entry.readings.map((r) => r.reading).join(" ")}${entry.kanjiForms !== void 0 ? ` ${entry.kanjiForms.map((kf) => kf.kanjiForm).join(" ")}` : ""} ${entry.id}`;
2832
2832
  fields.push(
2833
2833
  ...entry.kanjiForms !== void 0 && !entry.usuallyInKana ? [
2834
- `${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="1"></div>`,
2834
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="1"></div>`,
2835
2835
  `${hasAudio ? readingsFieldWithoutAudio : readingsField}<div id="r-pos" style="display: none" data-pos="2"></div>`
2836
2836
  ] : [
2837
- `${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="2"></div>`,
2837
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${kanjiFormsField}<div id="kf-pos" style="display: none" data-pos="2"></div>`,
2838
2838
  `${hasAudio ? readingsFieldWithoutAudio : readingsField}<div id="r-pos" style="display: none" data-pos="1"></div>`
2839
2839
  ],
2840
2840
  `${hasAudio ? readingsField : readingsFieldWithoutAudio}<div id="r-pos" style="display: none" data-pos="${entry.kanjiForms !== void 0 && !entry.usuallyInKana ? "2" : "1"}"></div>`,
@@ -2857,9 +2857,9 @@ function generateAnkiNote(entry) {
2857
2857
  }
2858
2858
  if (isRadical(entry))
2859
2859
  fields.push(
2860
- createEntry(
2860
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${createEntry(
2861
2861
  `<span class="radical radical-character">${entry.radical}</span>`
2862
- ),
2862
+ )}`,
2863
2863
  createEntry(
2864
2864
  `<span class="radical radical-reading">${entry.reading}</span>`
2865
2865
  ),
@@ -2888,7 +2888,7 @@ function generateAnkiNote(entry) {
2888
2888
  );
2889
2889
  if (isKanji(entry))
2890
2890
  fields.push(
2891
- createEntry(`<span class="kanji kanji-character">${entry.kanji}</span>`),
2891
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${createEntry(`<span class="kanji kanji-character">${entry.kanji}</span>`)}`,
2892
2892
  entry.meanings !== void 0 ? entry.meanings.map(
2893
2893
  (meaningEntry) => createEntry(
2894
2894
  `<span class="kanji kanji-meaning">${meaningEntry}</span>`
@@ -2934,7 +2934,7 @@ function generateAnkiNote(entry) {
2934
2934
  );
2935
2935
  if (isKana(entry))
2936
2936
  fields.push(
2937
- createEntry(`<span class="kana kana-character">${entry.kana}</span>`),
2937
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${createEntry(`<span class="kana kana-character">${entry.kana}</span>`)}`,
2938
2938
  createEntry(
2939
2939
  `<span class="kana kana-reading">${entry.reading}${entry.audio !== void 0 ? `<br>[sound:${entry.audio}]` : ""}</span>`
2940
2940
  ),
@@ -2949,7 +2949,7 @@ function generateAnkiNote(entry) {
2949
2949
  );
2950
2950
  if (isGrammar(entry))
2951
2951
  fields.push(
2952
- createEntry(`<span class="grammar grammar-point">${entry.point}</span>`),
2952
+ `${customData !== void 0 ? `<div id="custom-data" style="display: none" data-custom="${customData}"></div>` : ""}${createEntry(`<span class="grammar grammar-point">${entry.point}</span>`)}`,
2953
2953
  entry.readings !== void 0 ? entry.readings.map(
2954
2954
  (readingEntry) => createEntry(
2955
2955
  `<span class="grammar grammar-reading">${readingEntry.reading}</span>`
@@ -2979,7 +2979,7 @@ function generateAnkiNote(entry) {
2979
2979
  );
2980
2980
  return fields.map((field) => field.replaceAll("\n", "<br>"));
2981
2981
  }
2982
- function generateAnkiNotesFile(list, defaultNoteInfo) {
2982
+ function generateAnkiNotesFile(list, defaultNoteInfo, customData) {
2983
2983
  const headers = [noteHeaderKeys.separator, noteHeaderKeys.html];
2984
2984
  let ankiNotes = "";
2985
2985
  if (list.length > 0) {
@@ -3029,7 +3029,7 @@ function generateAnkiNotesFile(list, defaultNoteInfo) {
3029
3029
  headers.push(`${noteHeaderKeys.deck}${++headerCount}`);
3030
3030
  hasHeader.deckPath = true;
3031
3031
  }
3032
- const note = generateAnkiNote(result);
3032
+ const note = generateAnkiNote(result, customData);
3033
3033
  if (!hasHeader.tags) {
3034
3034
  headers.push(`${noteHeaderKeys.tags}${note.length + headerCount}`);
3035
3035
  hasHeader.tags = true;