44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
const { HandlebarsApplicationMixin } = foundry.applications.api
|
|
|
|
export class CDEBaseItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ["fvtt-chroniques-de-l-etrange", "item"],
|
|
position: { width: 520, height: "auto" },
|
|
window: { resizable: true },
|
|
form: { submitOnChange: true },
|
|
actions: {},
|
|
}
|
|
|
|
tabGroups = { primary: "details" }
|
|
|
|
get title() {
|
|
return this.document.name
|
|
}
|
|
|
|
async _prepareContext() {
|
|
const cssClass = this.options.classes?.join(" ") ?? ""
|
|
const enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description ?? "", { async: true })
|
|
const enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes ?? "", { async: true })
|
|
return {
|
|
item: this.document,
|
|
system: this.document.system,
|
|
systemData: this.document.system,
|
|
systemFields: this.document.system.schema.fields,
|
|
editable: this.isEditable,
|
|
cssClass,
|
|
enrichedDescription,
|
|
enrichedNotes,
|
|
descriptionHTML: enrichedDescription,
|
|
notesHTML: enrichedNotes,
|
|
}
|
|
}
|
|
|
|
// Restore the active tab after every render (including re-renders from submitOnChange).
|
|
_onRender(context, options) {
|
|
super._onRender?.(context, options)
|
|
for (const [group, tab] of Object.entries(this.tabGroups)) {
|
|
this.changeTab(tab, group, { force: true })
|
|
}
|
|
}
|
|
}
|