From 7a495aff30dfff8ccd7aa4dffd62a5fc48a183f5 Mon Sep 17 00:00:00 2001 From: Vincent Lark Date: Thu, 19 Oct 2023 09:44:32 +0200 Subject: [PATCH 1/3] Show nested chapters in bookplayer TOC --- src/plugins/bookPlayer/style.scss | 6 +++++- src/plugins/bookPlayer/tableOfContents.js | 26 +++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/plugins/bookPlayer/style.scss b/src/plugins/bookPlayer/style.scss index 5348e9d3c6..7bf9901b9b 100644 --- a/src/plugins/bookPlayer/style.scss +++ b/src/plugins/bookPlayer/style.scss @@ -57,7 +57,11 @@ margin-bottom: 5px; list-style-type: none; - font-size: 120%; + font-size: 1.2rem; + + ul { + padding-left: 1.5rem; + } a:link { color: #000; diff --git a/src/plugins/bookPlayer/tableOfContents.js b/src/plugins/bookPlayer/tableOfContents.js index 2da57b9229..15c19e89d0 100644 --- a/src/plugins/bookPlayer/tableOfContents.js +++ b/src/plugins/bookPlayer/tableOfContents.js @@ -51,6 +51,25 @@ export default class TableOfContents { }); } + chapterTocItem(book, chapter) { + let itemHtml = '
  • '; + + // remove parent directory reference from href to fix certain books + const link = chapter.href.startsWith('../') ? chapter.href.slice(3) : chapter.href; + itemHtml += `${chapter.label}`; + + if (chapter.subitems?.length) { + const subHtml = chapter.subitems + .map((nestedChapter) => this.chapterTocItem(book, nestedChapter)) + .join(''); + + itemHtml += ``; + } + + itemHtml += '
  • '; + return itemHtml; + } + createMediaElement() { const rendition = this.rendition; @@ -67,12 +86,7 @@ export default class TableOfContents { tocHtml += ''; tocHtml += ''; From 38d8cafc73da844a72c742f37c63dbae238f6bfc Mon Sep 17 00:00:00 2001 From: Vincent Lark Date: Fri, 20 Oct 2023 11:37:16 +0200 Subject: [PATCH 2/3] Render the toplevel TOC items bolder --- src/plugins/bookPlayer/style.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/bookPlayer/style.scss b/src/plugins/bookPlayer/style.scss index 7bf9901b9b..db43730188 100644 --- a/src/plugins/bookPlayer/style.scss +++ b/src/plugins/bookPlayer/style.scss @@ -58,9 +58,14 @@ list-style-type: none; font-size: 1.2rem; + font-weight: bold; ul { padding-left: 1.5rem; + + li { + font-weight: normal; + } } a:link { From 55f5a78f5e7f03076c79b5c9d5d3356e8ec3dbbd Mon Sep 17 00:00:00 2001 From: Vincent Lark Date: Thu, 26 Oct 2023 18:54:50 +0200 Subject: [PATCH 3/3] Use escapeHTML on book chapter titles --- src/plugins/bookPlayer/tableOfContents.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/bookPlayer/tableOfContents.js b/src/plugins/bookPlayer/tableOfContents.js index 15c19e89d0..4c2012d0ec 100644 --- a/src/plugins/bookPlayer/tableOfContents.js +++ b/src/plugins/bookPlayer/tableOfContents.js @@ -1,3 +1,4 @@ +import escapeHTML from 'escape-html'; import dialogHelper from '../../components/dialogHelper/dialogHelper'; export default class TableOfContents { @@ -56,7 +57,7 @@ export default class TableOfContents { // remove parent directory reference from href to fix certain books const link = chapter.href.startsWith('../') ? chapter.href.slice(3) : chapter.href; - itemHtml += `${chapter.label}`; + itemHtml += `${escapeHTML(chapter.label)}`; if (chapter.subitems?.length) { const subHtml = chapter.subitems