Skip to content

Commit 89bf40f

Browse files
authoredMar 24, 2025··
feat: add md footnote support (#1617)
1 parent 9d282ab commit 89bf40f

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed
 

‎elements/storytelling/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"js-yaml": "^4.1.0",
4343
"lit": "^3.2.0",
4444
"lodash.debounce": "^4.0.8",
45-
"markdown-it": "^14.0.0"
45+
"markdown-it": "^14.0.0",
46+
"markdown-it-footnote": "^4.0.0"
4647
},
4748
"peerDependencies": {
4849
"@eox/jsonform": "*"

‎elements/storytelling/src/helpers/render-html-string.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EVENT_REQ_MODES } from "../enums/index.js";
2+
import { scrollIntoView } from "./misc.js";
23
import GLightbox from "glightbox";
34

45
// Set up empty Lightbox
@@ -27,7 +28,17 @@ export function renderHtmlString(htmlString, sections, initDispatchFunc, that) {
2728

2829
// Open all links inside story in a new tab
2930
const anchorTagsArr = doc.querySelectorAll("a");
30-
anchorTagsArr.forEach((anchor) => (anchor.target = "_blank"));
31+
anchorTagsArr.forEach((anchor) => {
32+
if (!anchor.getAttribute("href")?.startsWith("#")) {
33+
anchor.target = "_blank";
34+
} else {
35+
anchor.addEventListener("click", () => {
36+
setTimeout(() => {
37+
scrollIntoView(that);
38+
});
39+
});
40+
}
41+
});
3142

3243
// Disconnecting old observers to create new empty Observers
3344
sectionObservers.forEach((observer) => observer?.disconnect());

‎elements/storytelling/src/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LitElement, html } from "lit";
22
import { when } from "lit/directives/when.js";
33
import markdownit from "markdown-it";
4+
import markdownitFootnote from "markdown-it-footnote";
45
import {
56
getCustomEleHandling,
67
loadMarkdownURL,
@@ -32,6 +33,7 @@ const md = /** @type {import("./types").CustomMarkdownIt} */ (
3233
);
3334

3435
md.use(markdownItDecorateImproved).use(markdownItConfig);
36+
md.use(markdownitFootnote);
3537
/**
3638
* Manage drawn features on a map
3739
*

‎elements/storytelling/src/style.eox.js

+7
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ ${slider}
176176
text-underline-offset: 4px;
177177
font-size: var(--font-size)
178178
}
179+
.story-telling sup a {
180+
font-size: smaller;
181+
}
182+
.story-telling sup a,
183+
.story-telling a.footnote-backref {
184+
text-decoration: none;
185+
}
179186
.story-telling a:hover {
180187
--bg-hover-transparency: 10%;
181188
background-color: color-mix(

‎elements/storytelling/stories/markdown-editor.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const MarkdownEditor = {
1414
1515
Storytelling is crucial in the realm of science because scientific data, while rich in information, can often be complex and challenging to communicate. By framing data within narratives, storytelling makes scientific concepts accessible, engaging, and memorable to a wider audience. It bridges the gap between the technical details of research and the public's understanding, fostering appreciation, curiosity, and ultimately, a deeper connection to the wonders of science.
1616
17+
Specifically, **scrolly**telling[^1] adds another layer of engagement, which allows the user to interact with the website by simply scrolling through it.
18+
19+
[^1]: Blend of *scroll* + *storytelling*. [Storytelling enriched with multimedial elements triggered while scrolling down a webpage](https://en.wiktionary.org/wiki/scrollytelling).
20+
1721
## How do I get started?
1822
### Story editor and live preview
1923
The main view of this page shows the live preview of the finished story. Floating above that you can see the story editor, which you can show and hide using the toggle:

‎package-lock.json

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.