Compare commits

...

3 commits

Author SHA1 Message Date
Carlos Fernandez
0fd9ac52e3 Add tooltip to add gm note button 2026-07-13 05:03:43 -04:00
Carlos Fernandez
3af0dfbe19 Fix active editor height and menu auto sizing 2026-07-13 04:59:10 -04:00
Carlos Fernandez
bb2289fa95 Localize GM Notes header label 2026-07-13 04:06:11 -04:00
5 changed files with 27 additions and 5 deletions

View file

@ -2550,6 +2550,9 @@
}, },
"identifier": { "identifier": {
"label": "Identifier" "label": "Identifier"
},
"gmNotes": {
"label": "GM Notes"
} }
}, },
"Ancestry": { "Ancestry": {
@ -2565,6 +2568,9 @@
"severe": "Severe Threshold" "severe": "Severe Threshold"
} }
}, },
"Base": {
"addGMNote": "Add GM Note"
},
"Beastform": { "Beastform": {
"FIELDS": { "FIELDS": {
"beastformType": { "label": "Beastform Type" }, "beastformType": { "label": "Beastform Type" },

View file

@ -339,9 +339,21 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
} }
} }
/**
* Handles the Add GM Note button being pressed. This is only used when an item has no GM notes.
* Later edits to a GM note instead go through the normal editor toggle workflow.
* @this DHBaseItemSheet
*/
static #onEditGMNote() { static #onEditGMNote() {
// Open the editor, which might be hidden. We remove the css class to hide temporarily
// so that menu auto resizing functions properly.
const editor = this.element.querySelector('prose-mirror[name="system.gmNotes"]'); const editor = this.element.querySelector('prose-mirror[name="system.gmNotes"]');
const wasHidden = editor.classList.contains('hide-if-inactive');
editor.classList.remove('hide-if-inactive');
editor.open = true; editor.open = true;
window.setTimeout(() => {
if (wasHidden) editor.classList.add('hide-if-inactive');
}, 0);
} }
/** @inheritdoc */ /** @inheritdoc */
@ -359,6 +371,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) {
button.type = 'button'; button.type = 'button';
button.classList.add('icon', 'toggle', 'fa-regular', 'fa-note-medical'); button.classList.add('icon', 'toggle', 'fa-regular', 'fa-note-medical');
button.dataset.action = 'editGMNote'; button.dataset.action = 'editGMNote';
button.dataset.tooltip = 'DAGGERHEART.ITEMS.Base.addGMNote';
description.appendChild(button); description.appendChild(button);
} }

View file

@ -157,7 +157,10 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
const gmNotesElement = document.createElement('section'); const gmNotesElement = document.createElement('section');
gmNotesElement.classList.add('gm-notes-section'); gmNotesElement.classList.add('gm-notes-section');
gmNotesElement.dataset.visibility = 'gm'; gmNotesElement.dataset.visibility = 'gm';
gmNotesElement.innerHTML = '<header class="gm-notes">GM Notes</header>' + this.gmNotes; const header = document.createElement('header');
header.classList.add('gm-notes');
header.textContent = _loc('DAGGERHEART.ITEMS.FIELDS.gmNotes.label');
gmNotesElement.innerHTML = header.outerHTML + this.gmNotes;
fullDescription += gmNotesElement.outerHTML; fullDescription += gmNotesElement.outerHTML;
} }

View file

@ -61,12 +61,12 @@
flex: 1 0; flex: 1 0;
} }
&:has(prose-mirror[name="system.gmNotes"]:not(.hide-if-inactive)) { &:has(prose-mirror[name="system.gmNotes"]:not(.hide-if-inactive)) {
prose-mirror { prose-mirror.inactive {
--min-height: 3rem; --min-height: 3rem;
&.inactive[name="system.description"] { &[name="system.description"] {
flex: 0 0; flex: 0 0;
} }
&.inactive[name="system.gmNotes"] { &[name="system.gmNotes"] {
flex: 1 0; flex: 1 0;
} }
} }

View file

@ -8,7 +8,7 @@
{{#if (and systemFields.gmNotes @root.user.isGM)}} {{#if (and systemFields.gmNotes @root.user.isGM)}}
<section class="gm-notes-section"> <section class="gm-notes-section">
{{#if enrichedGMNotes}} {{#if enrichedGMNotes}}
<header class="gm-notes">GM Notes</header> <header class="gm-notes">{{localize "DAGGERHEART.ITEMS.FIELDS.gmNotes.label"}}</header>
{{/if}} {{/if}}
<prose-mirror <prose-mirror
name="system.gmNotes" name="system.gmNotes"