-
Notifications
You must be signed in to change notification settings - Fork 8
/
HtmlTab.ts
49 lines (44 loc) · 1.34 KB
/
HtmlTab.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import type { OnRenderTabParams } from 'src/types/types';
import type { RenderScheme } from '../api.types';
import {
CustomTabBase,
type CustomTabTitle,
type TabId,
} from './CustomTabBase';
/**
* The information necessary for rendering an HTML-based tab.
* @example Getting the API and creating an HTML tab that wires an even on render
* ```js
* Hooks.once('tidy5e-sheet.ready', (api) => {
* const myTab = new api.models.HtmlTab({
* title: 'My Tab',
* tabId: "my-module-id-my-example-html-tab",
* html: `<button type="button" class="my-button">My button</button>`,
* onRender(params) {
* params.element
* .querySelector('.my-button')
* ?.addEventListener('click', () => {
* alert('clicked');
* });
* },
* });
* // To Do: Register this HTML-based tab!
* });
* ```
*/
/** @category Tabs */
export class HtmlTab extends CustomTabBase {
title: CustomTabTitle = '';
tabId: TabId = '';
html: string = '';
renderScheme: RenderScheme = 'handlebars';
tabContentsClasses: string[] = [];
activateDefaultSheetListeners?: boolean | undefined = false;
constructor(props?: Partial<HtmlTab>) {
super();
const merged = mergeObject(this, props);
Object.assign(this, merged);
}
enabled?: (context: any) => boolean;
onRender?: (params: OnRenderTabParams) => void;
}