You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Prefer modern DOM and event APIs (`addEventListener`, `EventTarget`) over jQuery.
15
+
- Use lifecycle overrides provided by V2: `_prepareContext`, `_renderHTML`, `_onFirstRender`, `_onRender`, `_preClose`, `_onChangeForm`, `submit()`, etc.
16
+
- For tabs, use the built-in `ApplicationV2.TABS` and `_getTabsConfig` rather than ad-hoc tab widgets.
17
+
- Only use methods documented as `@public` or `@protected` in the v14 API docs. Do not call `@private` or `@internal` methods.
18
+
19
+
## Canonical references (v14)
20
+
- `ApplicationV2` methods and lifecycle: https://foundryvtt.com/api/v14/classes/foundry.applications.api.ApplicationV2.html
21
+
- `DocumentSheetV2` hierarchy and lifecycle: https://foundryvtt.com/api/v14/classes/foundry.applications.api.DocumentSheetV2.html
Instantiate `DragDrop` in the constructor and wire targets via modern listeners—do not use V1 helpers. Keep handlers on `this.element` with `addEventListener` and translate drops into V2 updates.
72
-
---
73
-
description: Patterns and snippets for ApplicationV2 windows (v13)
74
-
globs: "src/**"
75
-
alwaysApply: true
76
-
---
70
+
Wire drag/drop handlers on `this.element` with `addEventListener` inside `_onRender`. Do not use V1 helpers.
77
71
78
-
# ApplicationV2 – How to structure windows
79
-
80
-
## Skeleton
81
-
Use `DEFAULT_OPTIONS`, implement `_prepareContext` and `_renderHTML`, and wire events with `addEventListener`:
82
-
83
-
```ts
84
-
import { HandlebarsApplicationMixin } from "foundry/applications/api.mjs"; // if using HBS
85
-
86
-
export class SyncManager extends HandlebarsApplicationMixin(ApplicationV2) {
V14 adds native pop-out support. Any `ApplicationV2` can call `attachWindow()` / `detachWindow()` to render in a separate browser window. No special code needed unless you need to customize the pop-out behavior.
All are described in `DocumentSheetV2`. [oai_citation:1‡Foundry Virtual Tabletop](https://foundryvtt.com/api/classes/foundry.applications.api.DocumentSheetV2.html)
50
+
51
+
API docs: https://foundryvtt.com/api/v14/classes/foundry.applications.api.DocumentSheetV2.html
58
52
59
53
## Images & assets
60
-
Bind image fields to `document.img` (or relevant system path) and update via `this.document.update({ img })` in submit handlers—do **not** rely on V1 jQuery form traversal.
54
+
Bind image fields to `document.img` and update via `this.document.update({ img })` in submit handlers. Do not rely on V1 jQuery form traversal.
61
55
62
56
## Tabs and header controls
63
-
Reuse `ApplicationV2` mechanisms from the window base: `TABS`, `_getTabsConfig`, `_getHeaderControls`. [oai_citation:11‡Foundry Virtual Tabletop](https://foundryvtt.com/api/classes/foundry.applications.api.ApplicationV2.html)
For rich text, prefer v13 editors or ProseMirror-based editors exposed by the system. Avoid direct DOM HTML scraping; persist via `update` on the document.
67
-
---
68
-
alwaysApply: true
69
-
---
60
+
For rich text, use ProseMirror-based editors exposed by Foundry. Avoid direct DOM HTML scraping; persist via `update` on the document.
description: How to build sidebar tabs and pop-out windows with V14 App V2 hooks
3
+
globs: "scripts/sidebar/**"
4
+
alwaysApply: false
5
+
---
6
+
7
+
# V14 Sidebar Tabs & Pop-outs
8
+
9
+
## Sidebar tab implementation
10
+
11
+
Custom sidebar tabs must extend `foundry.applications.sidebar.AbstractSidebarTab`, which is an `ApplicationV2` subclass. Use V2 lifecycle methods only:
12
+
13
+
```js
14
+
export class AskChatSidebarTab extends foundry.applications.sidebar.AbstractSidebarTab {
Any `ApplicationV2` can pop out. Sidebar tabs can use `renderPopout()` to create a detached copy. The framework handles window management. Override `_onDetach` / `_onAttach` if you need custom behavior when popping out or reattaching.
0 commit comments