diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js index 0a401a0c4e..43d1252e3a 100644 --- a/ext/js/data/anki-note-data-creator.js +++ b/ext/js/data/anki-note-data-creator.js @@ -968,18 +968,19 @@ function getCloze(dictionaryEntry, context) { } if (typeof text !== 'string') { text = ''; } if (typeof offset !== 'number') { offset = 0; } + const textChars = [...text]; const textSegments = []; - for (const {text: text2, reading: reading2} of distributeFuriganaInflected(term, reading, text.substring(offset, offset + originalText.length))) { + 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, - prefix: text.substring(0, offset), - body: text.substring(offset, offset + originalText.length), + sentence: textChars.join(''), + prefix: textChars.slice(0, offset).join(''), + body: textChars.slice(offset, offset + originalText.length).join(''), bodyKana: textSegments.join(''), - suffix: text.substring(offset + originalText.length), + suffix: textChars.slice(offset + originalText.length).join(''), }; }