fix: replace {{editor}} handlebars helper with <prose-mirror> custom element
This commit is contained in:
parent
093c94961d
commit
3284b132b4
2 changed files with 30 additions and 12 deletions
|
@ -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, <prose-mirror> 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,5 @@ SPDX-License-Identifier: MIT
|
|||
--}}
|
||||
|
||||
<div class="ds4-sheet-tab tab description" data-group="primary" data-tab="description">
|
||||
{{editor data.system.description target="system.description" button=true owner=owner
|
||||
editable=editable engine="prosemirror"}}
|
||||
<prose-mirror name="system.description" toggled="{{editable}}" value="{{data.system.description}}"></prose-mirror>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue