Skip to content

Commit ca723d6

Browse files
committed
feat: added copy for youtube button for chapters
1 parent 35edc87 commit ca723d6

1 file changed

Lines changed: 32 additions & 16 deletions

File tree

inertia/pages/posts/form.vue

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ async function generateBodyOverview() {
166166
}
167167
}
168168
169+
function copyChaptersForYouTube() {
170+
if (!form.chapters?.length) return
171+
172+
const captionsText = form.chapters
173+
.map((chapter) => `${chapter.start}: ${chapter.text}`)
174+
.join('\n')
175+
176+
navigator.clipboard.writeText(captionsText)
177+
toast.success('Captions copied to clipboard in YouTube format')
178+
}
179+
169180
function onSubmit(stateId: States = Number(form.stateId)) {
170181
const action = form.transform((data) => {
171182
data.stateId = stateId
@@ -567,22 +578,27 @@ function onVideoTypeChanged(videoTypeId: string) {
567578
</Button>
568579
</div>
569580

570-
<Button
571-
type="button"
572-
size="sm"
573-
class="mt-2"
574-
variant="secondary"
575-
@click="
576-
form.chapters.push({
577-
start: form.chapters[form.chapters.length - 1]?.end ?? '00:00',
578-
end: secondsToTimecode(form.videoSeconds) ?? '00:00',
579-
text: '',
580-
})
581-
"
582-
>
583-
<Plus class="w-3 h-3" />
584-
Add Chapter
585-
</Button>
581+
<div class="flex items-center gap-3 mt-2">
582+
<Button
583+
type="button"
584+
size="sm"
585+
variant="secondary"
586+
@click="
587+
form.chapters.push({
588+
start: form.chapters[form.chapters.length - 1]?.end ?? '00:00',
589+
end: secondsToTimecode(form.videoSeconds) ?? '00:00',
590+
text: '',
591+
})
592+
"
593+
>
594+
<Plus class="w-3 h-3" />
595+
Add Chapter
596+
</Button>
597+
598+
<a role="button" @click="copyChaptersForYouTube" class="text-blue-500 text-sm underline">
599+
Copy for YouTube
600+
</a>
601+
</div>
586602
</fieldset>
587603

588604
<FormInput

0 commit comments

Comments
 (0)