|
276 | 276 |
|
277 | 277 | <script setup lang="ts"> |
278 | 278 | import { injectStrict, hkBackKey, hkChordsKey, hkDownKey, hkForwardKey, hkPresentKey, hkResetKey, hkUpKey, noActiveModalKey, setlistsKey, songsKey, userKey, versionKey } from '@/keys'; |
279 | | -import { keyScale, isChordLine, parsedContent, download, openLyricsXML, firstParam, isSlide } from '@/utils.js'; |
| 279 | +import { keyScale, isChordLine, parsedContent, songPlainTextContent, download, openLyricsXML, firstParam, isSlide } from '@/utils.js'; |
280 | 280 | import type { SetlistSong } from '@backend/models'; |
281 | 281 | import { logicAnd, logicOr } from '@vueuse/math'; |
282 | 282 | import { notify } from '@kyvg/vue3-notification'; |
@@ -439,36 +439,9 @@ const songExists = computed(() => { |
439 | 439 | const exportTxt = () => { |
440 | 440 | const s = song.value; |
441 | 441 | if (!s) return; |
442 | | - // add header |
443 | | - var content = s.title |
444 | | - + ' [' + keyScale[(12 + keyScale.indexOf(s.key ?? '') + (key.value % 12)) % 12] + ']' |
445 | | - + '\n\n'; |
446 | | - var lines = s.content.split(EOL); |
447 | | - // process lines |
448 | | - for (var i = 0; i < lines.length; i++) { |
449 | | - var line = lines[i]; |
450 | | - // handle chord line |
451 | | - if (!chords.value && isChordLine(line)) continue; |
452 | | - // handle verse marker indentation |
453 | | - if (line.trim().toLowerCase().indexOf('--v') >= 0 && !isNaN(parseInt(line.trim().charAt(3)))) { |
454 | | - // if next line is chord line, prepend number to the line after |
455 | | - if (isChordLine(lines[i+1])) { |
456 | | - lines[i+2] = line.trim().charAt(3) + '. ' + lines[i+2]; |
457 | | - // add 3 spaces to next line to sync chords with text again |
458 | | - lines[i+1] = ' ' + lines[i+1]; |
459 | | - } else { |
460 | | - lines[i+1] = line.trim().charAt(3) + '. ' + lines[i+1]; |
461 | | - } |
462 | | - } |
463 | | - // handle marker |
464 | | - if (line.trim().indexOf('--') >= 0) continue; |
465 | | - // keep line for export |
466 | | - content += line + EOL; |
467 | | - } |
468 | | - content += EOL + s.authors?.join(', ') + EOL + EOL |
469 | | - + '© ' + (s.year ? s.year + ' ' : '') + s.publisher.replace(/(?:\r\n|\r|\n)/g, '; '); |
| 442 | + const tuning = keyScale[(12 + keyScale.indexOf(s.key ?? '') + (key.value % 12)) % 12]; |
470 | 443 | // start download |
471 | | - download(content, songId + '.txt'); |
| 444 | + download(songPlainTextContent(s, tuning, chords.value), songId + '.txt'); |
472 | 445 | // toast success message |
473 | 446 | notify({ |
474 | 447 | title: t('toast.exportedText'), |
|
0 commit comments