Compendium Browser (#821)

This commit is contained in:
Dapoulp 2025-08-11 00:18:31 +02:00 committed by GitHub
parent b68d2e9ec2
commit f9774f130e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 20 deletions

View file

@ -121,6 +121,16 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
}
}
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement
.querySelectorAll('[data-action="selectFolder"]')
.forEach(element => element.addEventListener("contextmenu", (event) => {
event.target.classList.toggle('expanded');
}))
}
/* -------------------------------------------- */
/* Rendering */
/* -------------------------------------------- */
@ -179,9 +189,20 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
}
this.items = ItemBrowser.sortBy(items, 'name');
if(target) {
target.closest('.compendium-sidebar').querySelectorAll('[data-action="selectFolder"]').forEach(element => element.classList.remove("is-selected"))
target.classList.add('is-selected');
}
this.render({ force: true });
}
_replaceHTML(result, content, options) {
if(!options.isFirstRender) delete result.sidebar;
super._replaceHTML(result, content, options);
}
static expandContent(_, target) {
const parent = target.parentElement;
parent.classList.toggle('expanded');