Skip to content

Commit

Permalink
Redefine textChars instead of changing type of text
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Oct 27, 2024
1 parent 83b64b8 commit 88b5627
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ext/js/data/anki-note-data-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,19 +968,19 @@ function getCloze(dictionaryEntry, context) {
}
if (typeof text !== 'string') { text = ''; }
if (typeof offset !== 'number') { offset = 0; }
text = [...text];
const textChars = [...text];

const textSegments = [];
for (const {text: text2, reading: reading2} of distributeFuriganaInflected(term, reading, text.slice(offset, offset + originalText.length).join(''))) {
for (const {text: text2, reading: reading2} of distributeFuriganaInflected(term, reading, textChars.slice(offset, offset + originalText.length).join(''))) {
textSegments.push(reading2.length > 0 ? reading2 : text2);
}

return {
sentence: text.join(''),
prefix: text.slice(0, offset).join(''),
body: text.slice(offset, offset + originalText.length).join(''),
sentence: textChars.join(''),
prefix: textChars.slice(0, offset).join(''),
body: textChars.slice(offset, offset + originalText.length).join(''),
bodyKana: textSegments.join(''),
suffix: text.slice(offset + originalText.length).join(''),
suffix: textChars.slice(offset + originalText.length).join(''),
};
}

Expand Down

0 comments on commit 88b5627

Please sign in to comment.