mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Add support for GM Notes
This commit is contained in:
parent
3faf588e6c
commit
9d277ea8ea
16 changed files with 256 additions and 64 deletions
|
|
@ -49,7 +49,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
})
|
||||
};
|
||||
|
||||
if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });
|
||||
if (this.metadata.hasDescription) {
|
||||
schema.description = new fields.HTMLField({ required: true, nullable: true });
|
||||
schema.gmNotes = new fields.HTMLField({ required: true, nullable: true });
|
||||
}
|
||||
|
||||
if (this.metadata.hasResource) {
|
||||
schema.resource = new fields.SchemaField(
|
||||
|
|
@ -134,7 +137,7 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
/**
|
||||
* Augments the description for the item with type specific info to display. Implemented in applicable item subtypes.
|
||||
* @param {object} [options] - Options that modify the styling of the rendered template. { headerStyle: undefined|'none'|'large' }
|
||||
* @returns {string}
|
||||
* @returns {Promise<{ prefix: string | null; value: string | null; suffix: string | null }>}
|
||||
*/
|
||||
async getDescriptionData(_options) {
|
||||
return { prefix: null, value: this.description, suffix: null };
|
||||
|
|
@ -145,14 +148,21 @@ 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 {Promise<string>}
|
||||
*/
|
||||
async getEnrichedDescription() {
|
||||
async getEnrichedDescription({ gmNotes = true } = {}) {
|
||||
if (!this.metadata.hasDescription) return '';
|
||||
|
||||
const { prefix, value, suffix } = await this.getDescriptionData();
|
||||
const fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
|
||||
let fullDescription = [prefix, value, suffix].filter(p => !!p).join('\n<hr>\n');
|
||||
if (this.gmNotes && gmNotes) {
|
||||
const gmNotesElement = document.createElement('section');
|
||||
gmNotesElement.classList.add('gm-notes-section');
|
||||
gmNotesElement.dataset.visibility = 'gm';
|
||||
gmNotesElement.innerHTML = '<header class="gm-notes">GM Notes</header>' + this.gmNotes;
|
||||
fullDescription += gmNotesElement.outerHTML;
|
||||
}
|
||||
|
||||
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(fullDescription, {
|
||||
relativeTo: this,
|
||||
relativeTo: this.parent,
|
||||
rollData: this.getRollData(),
|
||||
secrets: this.parent.isOwner
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue