From c879dbd1d2ae0216e12e6f6910a8f7667cba1df6 Mon Sep 17 00:00:00 2001 From: Joaquin Pereyra Date: Wed, 25 Jun 2025 18:47:10 -0300 Subject: [PATCH] FEAT: add description enrichement for items sheet --- module/applications/sheets/api/base-item.mjs | 30 +++++++++++++++++-- module/applications/sheets/items/armor.mjs | 2 +- .../sheets/global/tabs/tab-description.hbs | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/module/applications/sheets/api/base-item.mjs b/module/applications/sheets/api/base-item.mjs index 020b482d..5528f8fc 100644 --- a/module/applications/sheets/api/base-item.mjs +++ b/module/applications/sheets/api/base-item.mjs @@ -35,6 +35,30 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { } }; + /* -------------------------------------------- */ + /* Prepare Context */ + /* -------------------------------------------- */ + + /**@inheritdoc */ + async _preparePartContext(partId, context) { + await super._preparePartContext(partId, context); + const { TextEditor } = foundry.applications.ux; + + switch (partId) { + case 'description': + const value = foundry.utils.getProperty(this.document, "system.description") ?? ""; + context.enrichedDescription = await TextEditor.enrichHTML(value, { + relativeTo: this.item, + rollData: this.item.getRollData(), + secrets: this.item.isOwner + }) + break; + } + + return context; + } + + /* -------------------------------------------- */ /* Application Clicks Actions */ /* -------------------------------------------- */ @@ -46,9 +70,9 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { */ static async selectActionType() { const content = await foundry.applications.handlebars.renderTemplate( - 'systems/daggerheart/templates/views/actionType.hbs', - { types: SYSTEM.ACTIONS.actionTypes } - ), + 'systems/daggerheart/templates/views/actionType.hbs', + { types: SYSTEM.ACTIONS.actionTypes } + ), title = 'Select Action Type', //useless var type = 'form', data = {}; //useless var diff --git a/module/applications/sheets/items/armor.mjs b/module/applications/sheets/items/armor.mjs index dc3643fe..4e53d8fa 100644 --- a/module/applications/sheets/items/armor.mjs +++ b/module/applications/sheets/items/armor.mjs @@ -31,7 +31,7 @@ export default class ArmorSheet extends DHBaseItemSheet { /**@inheritdoc */ async _preparePartContext(partId, context) { - super._preparePartContext(partId, context); + await super._preparePartContext(partId, context); switch (partId) { case 'settings': diff --git a/templates/sheets/global/tabs/tab-description.hbs b/templates/sheets/global/tabs/tab-description.hbs index 58a90ed7..4e2de269 100755 --- a/templates/sheets/global/tabs/tab-description.hbs +++ b/templates/sheets/global/tabs/tab-description.hbs @@ -5,6 +5,6 @@ >
{{localize "DAGGERHEART.Sheets.Feature.Description"}} - {{formInput systemFields.description value=source.system.description enriched=source.system.description localize=true toggled=true}} + {{formInput systemFields.description value=document.system.description enriched=enrichedDescription toggled=true}}
\ No newline at end of file