Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2678] Fix "Reveal" button in secret blocks in multi-editor #4985

Open
wants to merge 1 commit into
base: 4.2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module/applications/api/application-v2-mixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default function ApplicationV2Mixin(Base) {
const selector = `.window-content :is(${[
"INPUT", "SELECT", "TEXTAREA", "BUTTON", "DND5E-CHECKBOX", "COLOR-PICKER", "DOCUMENT-TAGS",
"FILE-PICKER", "HUE-SLIDER", "MULTI-SELECT", "PROSE-MIRROR", "RANGE-PICKER", "STRING-TAGS"
].join(", ")}):not(.interface-only)`;
].join(", ")}):not(.interface-only, .secret > button)`;
for ( const element of this.element.querySelectorAll(selector) ) {
if ( element.tagName === "TEXTAREA" ) element.readOnly = true;
else element.disabled = true;
Expand Down
2 changes: 1 addition & 1 deletion module/applications/item/sheet-v2-mixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default function ItemSheetV2Mixin(Base) {
const selector = `:is(${[
"INPUT", "SELECT", "TEXTAREA", "BUTTON", "DND5E-CHECKBOX", "COLOR-PICKER", "DOCUMENT-TAGS",
"FILE-PICKER", "HUE-SLIDER", "MULTI-SELECT", "PROSE-MIRROR", "RANGE-PICKER", "STRING-TAGS"
].join(", ")}):not(.interface-only, .description-edit)`;
].join(", ")}):not(.interface-only, .description-edit, .secret > button)`;
for ( const element of form.querySelectorAll(selector) ) {
if ( element.tagName === "TEXTAREA" ) element.readOnly = true;
else element.disabled = true;
Expand Down
20 changes: 19 additions & 1 deletion module/applications/mixins/sheet-v2-mixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ export default function DocumentSheetV2Mixin(Base) {

/* -------------------------------------------- */

/** @override */
_getSecretContent(secret) {
const edit = secret.closest("[data-edit]")?.dataset.edit
?? secret.closest("[data-target]")?.dataset.target;
if ( edit ) return foundry.utils.getProperty(this.document, edit);
}

/* -------------------------------------------- */

/**
* Handle the user toggling the sheet mode.
* @param {Event} event The triggering event.
Expand Down Expand Up @@ -277,13 +286,22 @@ export default function DocumentSheetV2Mixin(Base) {
const content = await renderTemplate("systems/dnd5e/templates/items/parts/item-summary.hbs", context);
summary.querySelectorAll(".item-summary").forEach(el => el.remove());
summary.insertAdjacentHTML("beforeend", content);
await new Promise(resolve => requestAnimationFrame(resolve));
await new Promise(resolve => { requestAnimationFrame(resolve); });
this._expanded.add(item.id);
}

row.classList.toggle("collapsed", expanded);
icon.classList.toggle("fa-compress", !expanded);
icon.classList.toggle("fa-expand", expanded);
}

/* -------------------------------------------- */

/** @override */
_updateSecret(secret, content) {
const edit = secret.closest("[data-edit]")?.dataset.edit
?? secret.closest("[data-target]")?.dataset.target;
if ( edit ) return this.document.update({ [edit]: content });
}
};
}
2 changes: 1 addition & 1 deletion templates/actors/tabs/character-biography.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</div>

{{!-- Biography --}}
<div class="bottom">
<div class="bottom" data-target="system.details.biography.value">
<h3 class="icon">
<i class="fas fa-feather"></i>
<dnd5e-icon src="systems/dnd5e/icons/svg/ink-pot.svg"></dnd5e-icon>
Expand Down
7 changes: 4 additions & 3 deletions templates/items/parts/item-description2.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#*inline "description"}}
<div class="card description {{#if collapsible}}collapsible{{/if}} {{#if (lookup @root.collapsed target)}}collapsed{{/if}} {{#unless enriched}}empty{{/unless}}"
data-target="{{ target }}">
<div class="card description {{#if collapsible}}collapsible{{/if}} {{#if (lookup @root.collapsed target)}}collapsed{{/if}}
{{~#unless enriched}} empty{{/unless}}" data-target="{{ target }}">
<div class="header">
<span>{{ localize label }}</span>
{{#if @root.owner}}
Expand All @@ -18,7 +18,8 @@
</div>
{{/inline}}

<div class="tab {{#if singleDescription}}single-description{{/if}}" data-group="primary" data-tab="description">
<div class="tab {{#if singleDescription}}single-description{{/if}}" data-group="primary" data-tab="description"
{{~#if singleDescription}} data-target="system.description.value"{{/if}}>

{{#if editingDescriptionTarget}}
{{ editor enriched.editing target=editingDescriptionTarget button=false editable=true engine="prosemirror"
Expand Down