mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Bug/103 enrich htmlfield content before its used in applications (#369)
* FIX: Add enritch to HTMLField FIX: Remove no-HTMLField from Manifest FIX: Convert Scar's HTMLField to StringField FIX: Remove unused HTMLField * REMOVE unused hanldebars helpers * FEAT: add inventory-fieldset-items-V2 and inventory-item-V2 partials for Actors * FIX showLabels to hideTags * FEAT: add template to items sheet * FEAT: add effects tabs on ItemSheet * FEAT: add context menus for all inventory-items * FEAT: add resources to inventory-item template * FEAT: add enritch on inventory-item description FEAT: add extensible behavior on inventory-item-content FEAT: add fade effect on item-img to roll-itmg * FEAT: add eritch to NPC description FIX: missing htmlFieldss on manfiest FIX: add misisng localizations * FIX_ minor fixes * Little resource fix. Noone will notice ._. * FIX: remove default list styles FIX: .extended css reduce max-height, shorten animation duration to 0.5s, and set overflow to auto. FIX: set enriched=notes.enriche on notes.hbs FIX: set experience.value on sidebar.hbs FIX: move tooltip from item-img to img-portrait on inventory-item-V2.hbs REMOVE: unused files --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
parent
615df65415
commit
b8930b18a4
61 changed files with 1768 additions and 1434 deletions
|
|
@ -9,11 +9,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
position: {
|
||||
width: 500
|
||||
},
|
||||
actions: {
|
||||
useItem: this.useItem,
|
||||
useAction: this.useItem,
|
||||
toChat: this.toChat
|
||||
},
|
||||
actions: {},
|
||||
dragDrop: [{ dragSelector: '.action-section .inventory-item', dropSelector: null }]
|
||||
};
|
||||
|
||||
|
|
@ -36,47 +32,67 @@ export default class DhpEnvironment extends DHBaseActorSheet {
|
|||
}
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
getItem(element) {
|
||||
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
|
||||
item = this.document.items.get(itemId);
|
||||
return item;
|
||||
/**@inheritdoc */
|
||||
async _preparePartContext(partId, context, options) {
|
||||
context = await super._preparePartContext(partId, context, options);
|
||||
switch (partId) {
|
||||
case 'header':
|
||||
await this._prepareHeaderContext(context, options);
|
||||
break;
|
||||
case 'notes':
|
||||
await this._prepareNotesContext(context, options);
|
||||
break;
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Application Clicks Actions */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {ApplicationClickAction}
|
||||
* Prepare render context for the Biography part.
|
||||
* @param {ApplicationRenderContext} context
|
||||
* @param {ApplicationRenderOptions} options
|
||||
* @returns {Promise<void>}
|
||||
* @protected
|
||||
*/
|
||||
async viewAdversary(_, button) {
|
||||
const target = button.closest('[data-item-uuid]');
|
||||
const adversary = await foundry.utils.fromUuid(target.dataset.itemUuid);
|
||||
if (!adversary) {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.adversaryMissing'));
|
||||
return;
|
||||
}
|
||||
async _prepareNotesContext(context, _options) {
|
||||
const { system } = this.document;
|
||||
const { TextEditor } = foundry.applications.ux;
|
||||
|
||||
adversary.sheet.render({ force: true });
|
||||
}
|
||||
const paths = {
|
||||
notes: 'notes'
|
||||
};
|
||||
|
||||
static async useItem(event, button) {
|
||||
const action = this.getItem(event);
|
||||
if (!action) {
|
||||
await this.viewAdversary(event, button);
|
||||
} else {
|
||||
action.use(event);
|
||||
for (const [key, path] of Object.entries(paths)) {
|
||||
const value = foundry.utils.getProperty(system, path);
|
||||
context[key] = {
|
||||
field: system.schema.getField(path),
|
||||
value,
|
||||
enriched: await TextEditor.implementation.enrichHTML(value, {
|
||||
secrets: this.document.isOwner,
|
||||
relativeTo: this.document
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static async toChat(event) {
|
||||
const item = this.getItem(event);
|
||||
item.toChat(this.document.id);
|
||||
/**
|
||||
* Prepare render context for the Header part.
|
||||
* @param {ApplicationRenderContext} context
|
||||
* @param {ApplicationRenderOptions} options
|
||||
* @returns {Promise<void>}
|
||||
* @protected
|
||||
*/
|
||||
async _prepareHeaderContext(context, _options) {
|
||||
const { system } = this.document;
|
||||
const { TextEditor } = foundry.applications.ux;
|
||||
|
||||
context.description = await TextEditor.implementation.enrichHTML(system.description, {
|
||||
secrets: this.document.isOwner,
|
||||
relativeTo: this.document
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async _onDragStart(event) {
|
||||
const item = event.currentTarget.closest('.inventory-item');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue