diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 24f59be..1e04433 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -27,7 +27,9 @@ "editThis": "Diese Seite bearbeiten", "export": "Export", "exportSetlistList": "Liste als PDF", + "exportSetlistListTxt": "Liste als TXT", "exportSetlistSheets": "Liedzettel als PDF", + "exportSetlistSheetsTxt": "Liedzettel als TXT", "filetypeOsz": "OpenLP Service [.osz]", "filetypePdf": "PDF-Datei [.pdf]", "filetypeSng": "SongBeamer-Datei [.sng]", @@ -310,6 +312,7 @@ "copiedToClipboard": "In die Zwischenablage kopiert", "exportedPdf": "Exportiert als PDF", "exportedSetlistPdfText": "Die Setlist wurde erfolgreich als PDF Datei exportiert.", + "exportedSetlistTextText": "Die Setlist wurde erfolgreich im Textformat exportiert.", "exportedSng": "Exportiert als SNG", "exportedSongPdfText": "Der Song wurde erfolgreich als PDF Datei exportiert.", "exportedSongSngText": "Der Song wurde erfolgreich im SNG Format exportiert.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 6d2a6b7..0b37873 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -27,7 +27,9 @@ "editThis": "Edit this page", "export": "Export", "exportSetlistList": "List as PDF", + "exportSetlistListTxt": "List as TXT", "exportSetlistSheets": "Sheets as PDF", + "exportSetlistSheetsTxt": "Sheets as TXT", "filetypeOsz": "OpenLP Service [.osz]", "filetypePdf": "PDF file [.pdf]", "filetypeSng": "SongBeamer file [.sng]", @@ -310,6 +312,7 @@ "copiedToClipboard": "Copied to clipboard", "exportedPdf": "Exported as PDF", "exportedSetlistPdfText": "The setlist was successfully exported as PDF file.", + "exportedSetlistTextText": "The setlist was successfully exported in plain text format.", "exportedSng": "Exported as SNG", "exportedSongPdfText": "The song was successfully exported in PDF format.", "exportedSongSngText": "The song was successfully exported in SNG format.", diff --git a/frontend/src/utils.ts b/frontend/src/utils.ts index fd0a1e1..60b3249 100644 --- a/frontend/src/utils.ts +++ b/frontend/src/utils.ts @@ -316,6 +316,28 @@ function parsedContent(content: string, keyOffset: number, showChords: boolean, } }; +// Build plain text content for a song's songsheet: header (title [key]), lyrics (transposed by keyOffset, with chord +// lines optionally stripped and verse numbers re-attached to their lyric line), and an authors/copyright footer. +const songPlainTextContent = (song: SongEntity, keyOffset: number, tuning: string, showChords: boolean): string => { + // add header + var content = song.title + ' [' + tuning + ']' + '\n\n'; + parsedContent(song.content, keyOffset, showChords, false).forEach(part => { + var block = part.content; + // re-attach the verse number to its lyric line (skipping a leading chord line, padded to stay aligned) + if (part.type == 'v' && part.number != '0') { + var lines = block.split('\n'); + var target = isChordLine(lines[0]) ? 1 : 0; + if (target == 1) lines[0] = ' ' + lines[0]; + lines[target] = part.number + '. ' + (lines[target] ?? ''); + block = lines.join('\n'); + } + content += block + '\n\n'; + }); + content += song.authors?.join(', ') + '\n\n' + + '© ' + (song.year ? song.year + ' ' : '') + song.publisher.replace(/(?:\r\n|\r|\n)/g, '; '); + return content; +}; + // file download const download = (data: string | Blob, filename: string, isBlob = false): void => { var a = document.createElement('a'); @@ -524,6 +546,7 @@ export { bufferAndDefer, maximizePresentFontsize, parsedContent, + songPlainTextContent, download, humanDate, humanFileSize, diff --git a/frontend/src/views/SetlistShow.vue b/frontend/src/views/SetlistShow.vue index 3f2cb84..10ee6a5 100644 --- a/frontend/src/views/SetlistShow.vue +++ b/frontend/src/views/SetlistShow.vue @@ -125,7 +125,7 @@ class="px-3 py-2 w-full flex items-center gap-3 hover:bg-blade-100 dark:hover:bg-blade-750" @click="exportPdf('list')" > - + {{ t('button.exportSetlistList') }} + + @@ -213,7 +227,7 @@ class="px-3 py-2 w-full flex items-center gap-3 hover:bg-blade-100 dark:hover:bg-blade-750 sm:hidden" @click="exportPdf('list')" > - + {{ t('button.exportSetlistList') }} + + + @@ -519,7 +554,7 @@