Skip to content

Commit

Permalink
Fix: Regression Embed Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashe committed Jun 11, 2024
1 parent e02d937 commit 4c19421
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
34 changes: 26 additions & 8 deletions src/module/item/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PTUItem extends Item {
return this.img.includes("class");
}

get enabled(){
get enabled() {
return !!(this.system.enabled ?? true)
}

Expand All @@ -74,11 +74,11 @@ class PTUItem extends Item {
* @param newState
* @return {Promise<abstract.Document|*>}
*/
async toggleEnableState(newState = !this.enabled){
await this.update({"system.enabled": newState})
for(const rule of this.rules) {
if(rule.ignored || !(rule instanceof GrantItemRuleElement)) continue;
return this.actor.update({"system.timestamp": Date.now()})
async toggleEnableState(newState = !this.enabled) {
await this.update({ "system.enabled": newState })
for (const rule of this.rules) {
if (rule.ignored || !(rule instanceof GrantItemRuleElement)) continue;
return this.actor.update({ "system.timestamp": Date.now() })
}
}

Expand All @@ -103,7 +103,7 @@ class PTUItem extends Item {
}
});

if(this.enabled) {
if (this.enabled) {
this.flags.ptu.rollOptions.all[`item:enabled`] = true;
this.flags.ptu.rollOptions.item[`item:enabled`] = true;
}
Expand All @@ -124,6 +124,24 @@ class PTUItem extends Item {
return super.delete(context);
}

/** @override */
async _buildEmbedHTML(config, options = {}) {
options = { ...options, _embedDepth: options._embedDepth + 1, relativeTo: this };
if (!this.system?.effect) return document.createElement("div");
const {
secrets = options.secrets,
documents = options.documents,
links = options.links,
rolls = options.rolls,
embeds = options.embeds
} = config;
foundry.utils.mergeObject(options, { secrets, documents, links, rolls, embeds });
const enrichedPage = await TextEditor.enrichHTML(this.system.effect, options);
const container = document.createElement("div");
container.innerHTML = enrichedPage;
return container;
}

/**
* Retrieve all roll option from the requested domains. Micro-optimized in an excessively verbose for-loop.
* @param domains The domains of discourse from which to pull options. Always includes the "all" domain.
Expand Down Expand Up @@ -199,7 +217,7 @@ class PTUItem extends Item {
source._id = foundry.utils.randomID();
}

if(source.system.stackSlugs) source.system.slug = sluggify(source.name + foundry.utils.randomID());
if (source.system.stackSlugs) source.system.slug = sluggify(source.name + foundry.utils.randomID());

const item = new CONFIG.Item.documentClass(source, { parent: actor });

Expand Down
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"verified": "12.327",
"maximum": 12
},
"version": "4.3.0",
"version": "4.3.1",
"templateVersion": 2,
"authors": [
{
Expand Down

0 comments on commit 4c19421

Please sign in to comment.