Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatthes committed Nov 27, 2024
1 parent 0e080d4 commit 635ed18
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/component/joda-content-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ export class JodaContentElement extends HTMLElement {

document.body.classList.add("loaded");
document.querySelector("html").classList.remove("loader");


if (window.location.hash) {
let hash = window.location.hash.substring(1);
// urldecode hash
hash = decodeURIComponent(hash);
const element = document.getElementById(hash);
console.log("Scrolling to", window.location.hash, element);
if (element) {
element.scrollIntoView({behavior: "smooth"});
}
}

}


Expand Down
21 changes: 21 additions & 0 deletions src/processor/jodastyle-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,24 @@ jodaStyleCommands["--joda-on-empty-class"] = async (value : string, target, elem
}
return element
};


jodaStyleCommands["--joda-hide-empty"] = async(value : string, target, element : HTMLElement, logger : Logger) => {
function hideEmptyElements(node : HTMLElement) {
if (node.querySelectorAll("img, iframe").length > 0) {
return;
}
if (node.textContent.trim() !== "") {
return;
}
node.style.setProperty("display", "none", "important");
}

if (value === "true" || value === "1" || value === "yes" || value === "on") {
hideEmptyElements(element);
}


return element;
}

0 comments on commit 635ed18

Please sign in to comment.