Skip to content

Commit

Permalink
feat: WEB-2437 Added support for nested expansion macros
Browse files Browse the repository at this point in the history
  • Loading branch information
krystiankedra authored Jan 17, 2025
2 parents cf31502 + 134e65b commit f72cd24
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/proxy-page/steps/fixExpander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,35 @@ export default (): Step => (context: ContextService): void => {
let promiseFinallyState = false;
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
const content = this.nextElementSibling;
const toggleMaxHeight = (clear = false) =>
content.style.maxHeight = clear ? null : content.scrollHeight + "px";
const toggleOpacity = (value) => content.style.opacity = value;
const togglePromiseFinallyState = () => promiseFinallyState = !promiseFinallyState;
const toggleMaxHeight = (clear = false) => {
content.style.maxHeight = clear ? null : 'max-content';
};
const toggleOpacity = (value) => {
content.style.opacity = value;
};
const togglePromiseFinallyState = () => {
promiseFinallyState = !promiseFinallyState;
};
if (content.style.maxHeight) {
toggleMaxHeight(true);
} else {
const imagesCollection = content.querySelectorAll('img.confluence-embedded-image');
const notCompletedIamges = Array.from(imagesCollection).filter((image) => !image.complete);
if (notCompletedIamges && notCompletedIamges.length > 0 && !promiseFinallyState) {
toggleOpacity('0');
toggleMaxHeight();
const loadImageStatusFn = (image) => new Promise(
(res) => image.addEventListener('load', () => res())
);
Promise.all([...notCompletedIamges].map(loadImageStatusFn)).finally(() => {
toggleMaxHeight();
toggleOpacity('1');
Expand Down

0 comments on commit f72cd24

Please sign in to comment.