mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 07:38:53 +02:00
chore(collection/presentation): rewrite vertical slide links
This commit is contained in:
parent
c04c38e61d
commit
bfa1c2a2dd
@ -30,7 +30,8 @@ describe("Presentation model", () => {
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
id: "slide4",
|
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", () => {
|
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].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", () => {
|
it("doesn't rewrite links if they are not part of the slideshow", () => {
|
||||||
|
@ -62,9 +62,12 @@ async function processContent(note: FNote): Promise<DangerouslySetInnerHTML> {
|
|||||||
return { __html: $renderedContent.html() };
|
return { __html: $renderedContent.html() };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function postProcessSlides(slides: PresentationSlideModel[]) {
|
async function postProcessSlides(slides: (PresentationSlideModel | PresentationSlideBaseModel)[]) {
|
||||||
for (const slide of slides) {
|
for (const slide of slides) {
|
||||||
if (slide.type !== "text") continue;
|
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"`);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user