Improved description enrichment to not bloat it outside of the CompendiumBrowser

This commit is contained in:
WBHarry 2026-03-07 00:31:33 +01:00
parent 83c3da0130
commit e1fef44d21
7 changed files with 46 additions and 41 deletions

View file

@ -252,7 +252,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
/* If any noticeable slowdown occurs, consider replacing with enriching description on clicking to expand descriptions */
for (const item of this.items) {
item.system.enrichedDescription =
(await item.system.getEnrichedDescription?.()) ??
(await item.system.getEnrichedDescription?.({ inCompendiumBrowser: true })) ??
(await foundry.applications.ux.TextEditor.implementation.enrichHTML(item.description));
}

View file

@ -53,14 +53,14 @@ export default class DHArmor extends AttachableItem {
}
/**@inheritdoc */
async getDescriptionData() {
async getDescriptionData({ inCompendiumBrowser }) {
const baseDescription = this.description;
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
const features = this.armorFeatures.map(x => allFeatures[x.value]).filter(x => x);
const prefix = await foundry.applications.handlebars.renderTemplate(
'systems/daggerheart/templates/sheets/items/armor/description.hbs',
{ item: this.parent, features }
{ item: this.parent, features, inCompendiumBrowser }
);
return { prefix, value: baseDescription, suffix: null };

View file

@ -138,10 +138,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
* @returns {string}
*/
async getEnrichedDescription() {
async getEnrichedDescription(options = { inCompendiumBrowser: false }) {
if (!this.metadata.hasDescription) return '';
const { prefix, value, suffix } = await this.getDescriptionData();
const { prefix, value, suffix } = await this.getDescriptionData(options);
const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {

View file

@ -109,7 +109,7 @@ export default class DHWeapon extends AttachableItem {
}
/**@inheritdoc */
async getDescriptionData() {
async getDescriptionData({ inCompendiumBrowser }) {
const baseDescription = this.description;
const tier = game.i18n.localize(`DAGGERHEART.GENERAL.Tiers.${this.tier}`);
@ -129,7 +129,8 @@ export default class DHWeapon extends AttachableItem {
trait,
range,
damage,
burden
burden,
inCompendiumBrowser
}
);