Skip to content

Commit

Permalink
fix: handle storytelling without any content and when content without…
Browse files Browse the repository at this point in the history
… section tag (##) is added (#1487)
  • Loading branch information
srijitcoder authored Jan 14, 2025
1 parent c9260cb commit bd3b34d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions elements/storytelling/src/helpers/render-html-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,16 @@ export function parseNavWithAddSection(
html.splice(navIndex, 0, navDOM);
}

let containsSectionWrap = false;

if (html.length) {
const sectionStartIndex = navIndex + 1;
html[sectionStartIndex].classList.add("section-start");
html.slice(sectionStartIndex).forEach((section, key) => {
if (!section.classList) return;
if (section.classList.contains("section-wrap"))
containsSectionWrap = true;

section.classList.add("section-item");
section.setAttribute("data-section", `${key + 1}`);

Expand All @@ -382,5 +388,17 @@ export function parseNavWithAddSection(
});
}

if (!containsSectionWrap) {
let sectionWrap = document.createElement("div");
sectionWrap.className = "section-wrap container section-item";
html.forEach((element) => {
sectionWrap.appendChild(element);
});
sectionWrap.addEventListener("click", function (event) {
generateAddSectionClickEvt(event, false, this, EOxStoryTelling);
});
html = [sectionWrap];
}

return html;
}

0 comments on commit bd3b34d

Please sign in to comment.