feat: Truncate chapter's title above the timeline thumbnail if is too long

This commit is contained in:
Yiannis Christodoulou 2025-09-25 12:29:27 +03:00
parent 89a74f6570
commit 71b9935d2c
2 changed files with 14 additions and 4 deletions

View File

@ -215,8 +215,12 @@ class ChapterMarkers extends Component {
const endTime = formatTime(currentChapter.endTime); const endTime = formatTime(currentChapter.endTime);
// const timeAtPosition = formatTime(currentTime); // const timeAtPosition = formatTime(currentTime);
// Update text content without rebuilding DOM // Update text content without rebuilding DOM - truncate if too long
this.chapterTitle.textContent = currentChapter.chapterTitle; const truncatedTitle =
currentChapter.chapterTitle.length > 30
? currentChapter.chapterTitle.substring(0, 30) + '...'
: currentChapter.chapterTitle;
this.chapterTitle.textContent = truncatedTitle;
this.chapterInfo.textContent = `${startTime} - ${endTime}`; this.chapterInfo.textContent = `${startTime} - ${endTime}`;
// this.positionInfo.textContent = `Position: ${timeAtPosition}`; // this.positionInfo.textContent = `Position: ${timeAtPosition}`;
@ -338,7 +342,9 @@ class ChapterMarkers extends Component {
const tooltip = videojs.dom.createEl('div', { const tooltip = videojs.dom.createEl('div', {
className: 'vjs-chapter-marker-tooltip', className: 'vjs-chapter-marker-tooltip',
}); });
tooltip.textContent = cue.chapterTitle; // Truncate tooltip text if too long
const truncatedTooltipTitle = cue.text.length > 30 ? cue.text.substring(0, 30) + '...' : cue.text;
tooltip.textContent = truncatedTooltipTitle;
marker.appendChild(tooltip); marker.appendChild(tooltip);
// Add click handler to jump to chapter // Add click handler to jump to chapter

View File

@ -43,7 +43,11 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
poster_url: poster_url:
'/media/original/thumbnails/user/markos/6497e960081b4b8abddcf4cbdf2bf4eb_btbR39g.20250604_080632.mp4.jpg', '/media/original/thumbnails/user/markos/6497e960081b4b8abddcf4cbdf2bf4eb_btbR39g.20250604_080632.mp4.jpg',
chapter_data: [ chapter_data: [
{ startTime: '00:00:00.000', endTime: '00:00:08.295', chapterTitle: 'A1 test' }, {
startTime: '00:00:00.000',
endTime: '00:00:08.295',
chapterTitle: 'A1 Lorem ipsum dolor sit amet consectetur adipisicing elit.',
},
{ startTime: '00:00:24.295', endTime: '00:00:48.590', chapterTitle: 'A2 of Marine Life' }, { startTime: '00:00:24.295', endTime: '00:00:48.590', chapterTitle: 'A2 of Marine Life' },
{ {
startTime: '00:00:48.590', startTime: '00:00:48.590',