diff --git a/src/apps/item-sheet.js b/src/apps/item-sheet.js index c8245b00..0cd3bb4a 100644 --- a/src/apps/item-sheet.js +++ b/src/apps/item-sheet.js @@ -34,6 +34,8 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { }, }; + + static TABS = {}; constructor(options = {}) { @@ -95,17 +97,11 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { } } - // Enrich description HTML content - if (context.data.system.description) { - context.data.system.description = await TextEditor.enrichHTML( - context.data.system.description, - { - async: true, - relativeTo: this.item, - } - ); - } + // Provide raw description content to editor (let editor handle enrichment) + // Don't pre-enrich the HTML as it interferes with editor activation + // The editor will handle enrichment internally + console.log("DS4ItemSheet: _prepareContext completed for item:", this.item.name); return context; } @@ -244,22 +240,39 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { } } + + /** @override */ async _onRender(context, options) { + console.log("DS4ItemSheet: _onRender called for item:", this.item.name); await super._onRender(context, options); + console.log("DS4ItemSheet: About to initialize tabs"); // Initialize first tab as active this._initializeTabs(); + console.log("DS4ItemSheet: Tabs initialized"); + + console.log("DS4ItemSheet: _onRender completed, elements handle editor activation automatically"); + } + + + + /** @override */ + async _onClose(options) { + console.log("DS4ItemSheet: _onClose called"); + await super._onClose(options); } /** * Initialize tab state - show first tab, hide others */ _initializeTabs() { + console.log("DS4ItemSheet: _initializeTabs called"); const nav = this.element.querySelector(".ds4-sheet-tab-nav"); const sheet = this.element.querySelector(".ds4-sheet-body"); if (!nav || !sheet) { + console.warn("DS4ItemSheet: Could not find nav or sheet elements"); return; } @@ -267,6 +280,8 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { const navItems = nav.querySelectorAll(".ds4-sheet-tab-nav__item"); const tabContents = sheet.querySelectorAll(".ds4-sheet-tab"); + console.log("DS4ItemSheet: Found", navItems.length, "nav items and", tabContents.length, "tab contents"); + // Remove active class from all items first navItems.forEach(item => item.classList.remove("active")); tabContents.forEach(content => content.classList.remove("active")); @@ -281,6 +296,8 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { targetTab = targetNavItem?.dataset.tab; } + console.log("DS4ItemSheet: Setting active tab to:", targetTab); + // Set target tab navigation as active if (targetNavItem && targetTab) { targetNavItem.classList.add("active"); @@ -289,7 +306,9 @@ export class DS4ItemSheet extends foundry.applications.sheets.ItemSheetV2 { const activeTabContent = sheet.querySelector(`.ds4-sheet-tab[data-tab="${targetTab}"]`); if (activeTabContent) { activeTabContent.classList.add("active"); + console.log("DS4ItemSheet: Tab content activated:", activeTabContent); } } + console.log("DS4ItemSheet: _initializeTabs completed"); } } diff --git a/templates/sheets/item/tabs/description.hbs b/templates/sheets/item/tabs/description.hbs index cde3089c..42b4928d 100644 --- a/templates/sheets/item/tabs/description.hbs +++ b/templates/sheets/item/tabs/description.hbs @@ -5,6 +5,5 @@ SPDX-License-Identifier: MIT --}}
- {{editor data.system.description target="system.description" button=true owner=owner - editable=editable engine="prosemirror"}} +