Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(collection/presentation): rewrite vertical slide links
Elian Doranbfa1c2a2ddc9
diff --git a/apps/client/src/widgets/collections/presentation/model.spec.ts b/apps/client/src/widgets/collections/presentation/model.spec.tsindex c63b00bad0..7f63d8a42a 100644--- a/apps/client/src/widgets/collections/presentation/model.spec.ts+++ b/apps/client/src/widgets/collections/presentation/model.spec.ts@@ -30,7 +30,8 @@ describe("Presentation model", () => {children: [{id: "slide4",- title: "Second-sub"+ title: "Second-sub",+ content: `<p>Go to <a class="reference-link" href="#root/presentation/slide2">First-sub</a>.</p>`,}]}@@ -68,6 +69,7 @@ describe("Presentation model", () => {it("rewrites links to other slides", () => {expect(data.slides[1].content.__html).toStrictEqual(`<div class="ck-content"><p>Go to <a class="reference-link" href="#/slide1"><span class="bx bx-folder"></span>First slide</a>.</p></div>`);+ expect(data.slides[1].verticalSlides![0].content.__html).toStrictEqual(`<div class="ck-content"><p>Go to <a class="reference-link" href="#/slide2"><span class="bx bx-note"></span>First-sub</a>.</p></div>`);});it("doesn't rewrite links if they are not part of the slideshow", () => {diff --git a/apps/client/src/widgets/collections/presentation/model.ts b/apps/client/src/widgets/collections/presentation/model.tsindex 769a8d6da9..14bd30c4d0 100644--- a/apps/client/src/widgets/collections/presentation/model.ts+++ b/apps/client/src/widgets/collections/presentation/model.ts@@ -62,9 +62,12 @@ async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {return { __html: $renderedContent.html() };}-async function postProcessSlides(slides: PresentationSlideModel[]) {+async function postProcessSlides(slides: (PresentationSlideModel | PresentationSlideBaseModel)[]) {for (const slide of slides) {if (slide.type !== "text") continue;slide.content.__html = slide.content.__html.replaceAll(/href="[^"]*#root[a-zA-Z0-9_\/]*\/([a-zA-Z0-9_]+)[^"]*"/g, `href="#/$1"`);+ if ("verticalSlides" in slide && slide.verticalSlides) {+ postProcessSlides(slide.verticalSlides);+ }}}