Preserve and display bilingual and phonetic lyric cues
This commit is contained in:
@@ -87,7 +87,9 @@ export function sanitizeLyrics(input) {
|
||||
const text = cleanLyricText(l.text);
|
||||
if (!text) continue;
|
||||
const kind = l.kind === 'section' || l.kind === 'cue' ? l.kind : 'line';
|
||||
lines.push({ t: cleanTime(l.t), text, kind });
|
||||
const line = { t: cleanTime(l.t), text, kind };
|
||||
if (kind === 'line') { const secondary = cleanLyricText(l.secondary), phonetic = cleanLyricText(l.phonetic); if (secondary) line.secondary = secondary; if (phonetic) line.phonetic = phonetic; }
|
||||
lines.push(line);
|
||||
}
|
||||
const tags = (Array.isArray(input.tags) ? input.tags : [])
|
||||
.map((t) => cleanText(t, 40)).filter(Boolean).slice(0, MAX_TAGS);
|
||||
|
||||
@@ -267,3 +267,7 @@ test('saving a grouped cue preserves one timestamp in current and revision docum
|
||||
const flags = await (await app.request(`/api/notes/${id}/flags`)).json();
|
||||
expect(flags.flags[0].text).toBe(lines[0].text);
|
||||
});
|
||||
test('secondary and phonetic lyric fields survive validation without changing old documents', () => {
|
||||
const result = N.sanitizeLyrics({ lines:[{t:1,text:'主',kind:'line',secondary:' Your grace\n is enough ',phonetic:' zhǔ\u0007 '},{t:2,text:'Legacy',kind:'line'}] });
|
||||
expect(result.lines[0].secondary).toBe('Your grace\nis enough'); expect(result.lines[0].phonetic).toBe('zhǔ'); expect(result.lines[1]).toEqual({t:2,text:'Legacy',kind:'line'});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user