@league-of-foundry-developers/foundry-vtt-types 9.255.2 → 9.255.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/foundry/common/types.mjs.d.ts +2 -5
- package/src/foundry/foundry.js/applications/basePlaceableHUDs/tokenHUD.d.ts +7 -3
- package/src/foundry/foundry.js/applications/cameraViews.d.ts +3 -3
- package/src/foundry/foundry.js/applications/formApplication.d.ts +5 -0
- package/src/foundry/foundry.js/applications/hotbar.d.ts +7 -3
- package/src/foundry/foundry.js/pixi/containers/index.d.ts +1 -0
- package/src/foundry/foundry.js/pixi/containers/objectHUD.d.ts +82 -0
- package/src/foundry/foundry.js/pixi/containers/placeableObjects/measuredTemplate.d.ts +52 -15
- package/src/foundry/foundry.js/pixi/containers/placeableObjects/token.d.ts +216 -62
- package/src/foundry/foundry.js/pixi/containers/placeableObjects/wall.d.ts +107 -16
- package/src/foundry/foundry.js/textEditor.d.ts +266 -231
- package/src/types/utils.d.ts +5 -0
@@ -1,286 +1,321 @@
|
|
1
|
-
|
2
|
-
* A collection of helper functions and utility methods related to the rich text editor
|
3
|
-
*/
|
4
|
-
declare class TextEditor {
|
5
|
-
/**
|
6
|
-
* Create a Rich Text Editor. The current implementation uses TinyMCE
|
7
|
-
* @param options - Configuration options provided to the Editor init
|
8
|
-
* @param content - Initial HTML or text content to populate the editor with
|
9
|
-
* (default: `""`)
|
10
|
-
* @returns The editor instance.
|
11
|
-
*/
|
12
|
-
static create(options: TextEditor.Options, content: string): Promise<tinyMCE.Editor>;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Safely decode an HTML string, removing invalid tags and converting entities back to unicode characters.
|
16
|
-
* @param html - The original encoded HTML string
|
17
|
-
* @returns The decoded unicode string
|
18
|
-
*/
|
19
|
-
static decodeHTML(html: string): string;
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Enrich HTML content by replacing or augmenting components of it
|
23
|
-
* @param content - The original HTML content (as a string)
|
24
|
-
* @param options - Additional options which configure how HTML is enriched
|
25
|
-
* (default: `{}`)
|
26
|
-
* @returns The enriched HTML content
|
27
|
-
*/
|
28
|
-
static enrichHTML(content: string, options?: Partial<TextEditor.EnrichOptions>): string;
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Preview an HTML fragment by constructing a substring of a given length from its inner text.
|
32
|
-
* @param content - The raw HTML to preview
|
33
|
-
* @param length - The desired length
|
34
|
-
* (default: `250`)
|
35
|
-
* @returns The previewed HTML
|
36
|
-
*/
|
37
|
-
static previewHTML(content: string, length?: number): string;
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Truncate an HTML fragment to a maximum number of text content characters, removing any unused elements.
|
41
|
-
* @param html - The root HTML element.
|
42
|
-
* @param maxLength - The maximum allowed length of the text content.
|
43
|
-
* (default: `50`)
|
44
|
-
* @param splitWords - Whether to truncate by splitting on white space (if true) or breaking words.
|
45
|
-
* (default: `true`)
|
46
|
-
* @param suffix - A suffix string to append to denote that the text was truncated.
|
47
|
-
* (default: `'…'`)
|
48
|
-
*/
|
49
|
-
static truncateHTML(
|
50
|
-
html: HTMLElement,
|
51
|
-
{ maxLength, splitWords, suffix }: { maxLength?: number; splitWords?: boolean; suffix?: string }
|
52
|
-
): HTMLElement;
|
53
|
-
|
54
|
-
/**
|
55
|
-
* Truncate a fragment of text to a maximum number of characters.
|
56
|
-
* @param text - The original text fragment that should be truncated to a maximum length
|
57
|
-
* @param maxLength - The maximum allowed length of the truncated string.
|
58
|
-
* (default: `50`)
|
59
|
-
* @param splitWords - Whether to truncate by splitting on white space (if true) or breaking words.
|
60
|
-
* (default: `true`)
|
61
|
-
* @param suffix - A suffix string to append to denote that the text was truncated.
|
62
|
-
* (default: `'…'`)
|
63
|
-
*/
|
64
|
-
static truncateText(
|
65
|
-
text: string,
|
66
|
-
{ maxLength, splitWords, suffix }?: { maxLength?: number; splitWords?: boolean; suffix?: string }
|
67
|
-
): string;
|
1
|
+
import type { ConfiguredDocumentClassForName } from '../../types/helperTypes';
|
68
2
|
|
3
|
+
declare global {
|
69
4
|
/**
|
70
|
-
*
|
71
|
-
* @param parent - The parent HTML Element
|
72
|
-
* @returns An array of contained Text nodes
|
73
|
-
* @internal
|
5
|
+
* A collection of helper functions and utility methods related to the rich text editor
|
74
6
|
*/
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
func: (...match: RegExpMatchArray[]) => Node
|
85
|
-
): boolean;
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Replace a matched portion of a Text node with a replacement Node
|
89
|
-
* @internal
|
90
|
-
*/
|
91
|
-
protected static _replaceTextNode(text: Text, match: RegExpMatchArray, replacement: Node): void;
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Create a dynamic entity link from a regular expression match
|
95
|
-
* @param match - The full matched string
|
96
|
-
* @param type - The matched entity type or "Compendium"
|
97
|
-
* @param target - The requested match target (_id or name)
|
98
|
-
* @param name - A customized or over-ridden display name for the link
|
99
|
-
* @returns An HTML element for the entity link
|
100
|
-
* @internal
|
101
|
-
*/
|
102
|
-
protected static _createContentLink(match: string, type: string, target: string, name: string): HTMLAnchorElement;
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Replace a hyperlink-like string with an actual HTML <a> tag
|
106
|
-
* @param match - The full matched string
|
107
|
-
* @returns An HTML element for the entity link
|
108
|
-
* @internal
|
109
|
-
*/
|
110
|
-
protected static _createHyperlink(match: string): HTMLAnchorElement;
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Replace an inline roll formula with a rollable <a> element or an eagerly evaluated roll result
|
114
|
-
* @param match - The matched string
|
115
|
-
* @param command - An optional command
|
116
|
-
* @param formula - The matched formula
|
117
|
-
* @param closing - The closing brackets for the inline roll
|
118
|
-
* @param label - An optional label which configures the button text
|
119
|
-
* @returns The replaced match
|
120
|
-
* @internal
|
121
|
-
*/
|
122
|
-
protected static _createInlineRoll(
|
123
|
-
match: string,
|
124
|
-
command: string,
|
125
|
-
formula: string,
|
126
|
-
closing: string,
|
127
|
-
label?: string,
|
128
|
-
...args: object[]
|
129
|
-
): HTMLAnchorElement | null;
|
7
|
+
class TextEditor {
|
8
|
+
/**
|
9
|
+
* Create a Rich Text Editor. The current implementation uses TinyMCE
|
10
|
+
* @param options - Configuration options provided to the Editor init
|
11
|
+
* @param content - Initial HTML or text content to populate the editor with
|
12
|
+
* (default: `""`)
|
13
|
+
* @returns The editor instance.
|
14
|
+
*/
|
15
|
+
static create(options: TextEditor.Options, content: string): Promise<tinyMCE.Editor>;
|
130
16
|
|
131
|
-
|
17
|
+
/**
|
18
|
+
* A list of elements that are retained when truncating HTML.
|
19
|
+
* @internal
|
20
|
+
*/
|
21
|
+
protected static _PARAGRAPH_ELEMENTS: Set<string>;
|
132
22
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
23
|
+
/**
|
24
|
+
* Safely decode an HTML string, removing invalid tags and converting entities back to unicode characters.
|
25
|
+
* @param html - The original encoded HTML string
|
26
|
+
* @returns The decoded unicode string
|
27
|
+
*/
|
28
|
+
static decodeHTML(html: string): string;
|
138
29
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
30
|
+
/**
|
31
|
+
* Enrich HTML content by replacing or augmenting components of it
|
32
|
+
* @param content - The original HTML content (as a string)
|
33
|
+
* @param options - Additional options which configure how HTML is enriched
|
34
|
+
* (default: `{}`)
|
35
|
+
* @returns The enriched HTML content
|
36
|
+
*/
|
37
|
+
static enrichHTML(content: string, options?: Partial<TextEditor.EnrichOptions>): string;
|
145
38
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
39
|
+
/**
|
40
|
+
* Preview an HTML fragment by constructing a substring of a given length from its inner text.
|
41
|
+
* @param content - The raw HTML to preview
|
42
|
+
* @param length - The desired length
|
43
|
+
* (default: `250`)
|
44
|
+
* @returns The previewed HTML
|
45
|
+
*/
|
46
|
+
static previewHTML(content: string, length?: number): string;
|
152
47
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
48
|
+
/**
|
49
|
+
* Sanitises an HTML fragment and removes any non-paragraph-style text.
|
50
|
+
* @param html - The root HTML element.
|
51
|
+
*/
|
52
|
+
static truncateHTML(html: HTMLElement): HTMLElement;
|
158
53
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
54
|
+
/**
|
55
|
+
* Truncate a fragment of text to a maximum number of characters.
|
56
|
+
* @param text - The original text fragment that should be truncated to a maximum length
|
57
|
+
* @param maxLength - The maximum allowed length of the truncated string.
|
58
|
+
* (default: `50`)
|
59
|
+
* @param splitWords - Whether to truncate by splitting on white space (if true) or breaking words.
|
60
|
+
* (default: `true`)
|
61
|
+
* @param suffix - A suffix string to append to denote that the text was truncated.
|
62
|
+
* (default: `'…'`)
|
63
|
+
*/
|
64
|
+
static truncateText(
|
65
|
+
text: string,
|
66
|
+
{ maxLength, splitWords, suffix }?: { maxLength?: number; splitWords?: boolean; suffix?: string }
|
67
|
+
): string;
|
165
68
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
69
|
+
/**
|
70
|
+
* Recursively identify the text nodes within a parent HTML node for potential content replacement.
|
71
|
+
* @param parent - The parent HTML Element
|
72
|
+
* @returns An array of contained Text nodes
|
73
|
+
* @internal
|
74
|
+
*/
|
75
|
+
protected static _getTextNodes(parent: HTMLElement): Text[];
|
172
76
|
|
173
|
-
declare namespace TextEditor {
|
174
|
-
interface Options {
|
175
77
|
/**
|
176
|
-
*
|
78
|
+
* Facilitate the replacement of text node content using a matching regex rule and a provided replacement function.
|
79
|
+
* @internal
|
177
80
|
*/
|
178
|
-
|
81
|
+
protected static _replaceTextContent(
|
82
|
+
text: Text[],
|
83
|
+
rgx: RegExp,
|
84
|
+
func: (...match: RegExpMatchArray) => Node
|
85
|
+
): boolean;
|
179
86
|
|
180
87
|
/**
|
181
|
-
*
|
88
|
+
* Replace a matched portion of a Text node with a replacement Node
|
89
|
+
* @internal
|
182
90
|
*/
|
183
|
-
|
91
|
+
protected static _replaceTextNode(text: Text, match: RegExpMatchArray, replacement: Node): void;
|
184
92
|
|
185
93
|
/**
|
186
|
-
*
|
94
|
+
* Create a dynamic document link from a regular expression match
|
95
|
+
* @param match - The full matched string
|
96
|
+
* @param type - The matched document type or "Compendium"
|
97
|
+
* @param target - The requested match target (_id or name)
|
98
|
+
* @param name - A customized or over-ridden display name for the link
|
99
|
+
* @returns An HTML element for the document link
|
100
|
+
* @internal
|
187
101
|
*/
|
188
|
-
|
102
|
+
protected static _createContentLink(match: string, type: string, target: string, name: string): HTMLAnchorElement;
|
189
103
|
|
190
104
|
/**
|
191
|
-
*
|
105
|
+
* Replace a hyperlink-like string with an actual HTML <a> tag
|
106
|
+
* @param match - The full matched string
|
107
|
+
* @returns An HTML element for the document link
|
108
|
+
* @internal
|
192
109
|
*/
|
193
|
-
|
110
|
+
protected static _createHyperlink(match: string): HTMLAnchorElement;
|
194
111
|
|
195
112
|
/**
|
196
|
-
*
|
113
|
+
* Replace an inline roll formula with a rollable <a> element or an eagerly evaluated roll result
|
114
|
+
* @param match - The matched string
|
115
|
+
* @param command - An optional command
|
116
|
+
* @param formula - The matched formula
|
117
|
+
* @param closing - The closing brackets for the inline roll
|
118
|
+
* @param label - An optional label which configures the button text
|
119
|
+
* @returns The replaced match
|
120
|
+
* @internal
|
197
121
|
*/
|
198
|
-
|
122
|
+
protected static _createInlineRoll(
|
123
|
+
match: string,
|
124
|
+
command: string,
|
125
|
+
formula: string,
|
126
|
+
closing: string,
|
127
|
+
label?: string,
|
128
|
+
...args: object[]
|
129
|
+
): HTMLAnchorElement | null;
|
130
|
+
|
131
|
+
static activateListeners(): void;
|
199
132
|
|
200
133
|
/**
|
201
|
-
*
|
134
|
+
* Handle click events on Document Links
|
135
|
+
* @internal
|
202
136
|
*/
|
203
|
-
|
204
|
-
|
205
|
-
style_formats?: [
|
206
|
-
{
|
207
|
-
items?: [
|
208
|
-
{
|
209
|
-
/**
|
210
|
-
* @defaultValue `'section'`
|
211
|
-
*/
|
212
|
-
block?: string;
|
213
|
-
|
214
|
-
/**
|
215
|
-
* @defaultValue `'secrect'`
|
216
|
-
*/
|
217
|
-
classes?: string;
|
218
|
-
|
219
|
-
/**
|
220
|
-
* @defaultValue `'Secret'`
|
221
|
-
*/
|
222
|
-
title?: string;
|
223
|
-
|
224
|
-
/**
|
225
|
-
* @defaultValue `true`
|
226
|
-
*/
|
227
|
-
wrapper?: boolean;
|
228
|
-
}
|
229
|
-
];
|
230
|
-
|
231
|
-
/**
|
232
|
-
* @defaultValue `'Custom'`
|
233
|
-
*/
|
234
|
-
title?: string;
|
235
|
-
}
|
236
|
-
];
|
137
|
+
protected static _onClickContentLink(event: MouseEvent): void;
|
237
138
|
|
238
139
|
/**
|
239
|
-
*
|
140
|
+
* Handle left-mouse clicks on an inline roll, dispatching the formula or displaying the tooltip
|
141
|
+
* @param event - The initiating click event
|
142
|
+
* @internal
|
240
143
|
*/
|
241
|
-
|
144
|
+
protected static _onClickInlineRoll(event: MouseEvent): void;
|
242
145
|
|
243
146
|
/**
|
244
|
-
* @
|
147
|
+
* Toggle playing or stopping an embedded {@link PlaylistSound} link.
|
148
|
+
* @param doc - The PlaylistSound document to play/stop.
|
149
|
+
* @internal
|
245
150
|
*/
|
246
|
-
|
151
|
+
protected static _onPlaySound(doc: InstanceType<ConfiguredDocumentClassForName<'PlaylistSound'>>): void;
|
247
152
|
|
248
|
-
|
153
|
+
/**
|
154
|
+
* Find all content links belonging to a given {@link PlaylistSound}.
|
155
|
+
* @param doc - The PlaylistSound.
|
156
|
+
* @internal
|
157
|
+
*/
|
158
|
+
protected static _getSoundContentLinks(
|
159
|
+
doc: InstanceType<ConfiguredDocumentClassForName<'PlaylistSound'>>
|
160
|
+
): NodeListOf<Element>;
|
249
161
|
|
250
162
|
/**
|
251
|
-
*
|
163
|
+
* Begin a Drag+Drop workflow for a dynamic content link
|
164
|
+
* @param event - The originating drag event
|
165
|
+
* @internal
|
252
166
|
*/
|
253
|
-
|
254
|
-
}
|
167
|
+
protected static _onDragContentLink(event: DragEvent): void;
|
255
168
|
|
256
|
-
interface EnrichOptions {
|
257
169
|
/**
|
258
|
-
*
|
259
|
-
* @
|
170
|
+
* Handle dropping of transferred data onto the active rich text editor
|
171
|
+
* @param event - The originating drop event which triggered the data transfer
|
172
|
+
* @param editor - The TinyMCE editor instance being dropped on
|
173
|
+
* @internal
|
260
174
|
*/
|
261
|
-
|
175
|
+
protected static _onDropEditorData(event: DragEvent, editor: tinyMCE.Editor): void;
|
262
176
|
|
263
177
|
/**
|
264
|
-
*
|
265
|
-
* @
|
178
|
+
* Extract JSON data from a drag/drop event.
|
179
|
+
* @param event - The drag event which contains JSON data.
|
180
|
+
* @returns The extracted JSON data. The object will be empty if the DragEvent did not contain
|
181
|
+
* JSON-parseable data.
|
266
182
|
*/
|
267
|
-
|
183
|
+
protected static getDragEventData(event: DragEvent): object;
|
268
184
|
|
269
185
|
/**
|
270
|
-
*
|
271
|
-
* @
|
186
|
+
* Given a Drop event, returns a Content link if possible such as `@Actor[ABC123]`, else null
|
187
|
+
* @param eventData - The parsed object of data provided by the transfer event
|
272
188
|
*/
|
273
|
-
|
189
|
+
// TODO: improve as part of https://github.com/League-of-Foundry-Developers/foundry-vtt-types/issues/928
|
190
|
+
static getContentLink(eventData: object): Promise<string | null>;
|
274
191
|
|
275
192
|
/**
|
276
|
-
*
|
277
|
-
* @
|
193
|
+
* @deprecated since v9 - Use _onDragContentLink instead.
|
194
|
+
* @internal
|
278
195
|
*/
|
279
|
-
|
196
|
+
protected static _onDragEntityLink(
|
197
|
+
...args: Parameters<typeof TextEditor['_onDragContentLink']>
|
198
|
+
): ReturnType<typeof TextEditor['_onDragContentLink']>;
|
280
199
|
|
281
200
|
/**
|
282
|
-
*
|
201
|
+
* Singleton decoder area
|
202
|
+
* @internal
|
283
203
|
*/
|
284
|
-
|
204
|
+
protected static _decoder: HTMLTextAreaElement;
|
205
|
+
}
|
206
|
+
|
207
|
+
namespace TextEditor {
|
208
|
+
interface Options {
|
209
|
+
/**
|
210
|
+
* @defaultValue `false`
|
211
|
+
*/
|
212
|
+
branding?: boolean;
|
213
|
+
|
214
|
+
/**
|
215
|
+
* @defaultValue `['/css/mce.css']`
|
216
|
+
*/
|
217
|
+
content_css?: string[];
|
218
|
+
|
219
|
+
/**
|
220
|
+
* @defaultValue `false`
|
221
|
+
*/
|
222
|
+
menubar?: boolean;
|
223
|
+
|
224
|
+
/**
|
225
|
+
* @defaultValue `'lists image table hr code save link'`
|
226
|
+
*/
|
227
|
+
plugins?: string;
|
228
|
+
|
229
|
+
/**
|
230
|
+
* @defaultValue `true`
|
231
|
+
*/
|
232
|
+
save_enablewhendirty?: boolean;
|
233
|
+
|
234
|
+
/**
|
235
|
+
* @defaultValue `false`
|
236
|
+
*/
|
237
|
+
statusbar?: boolean;
|
238
|
+
|
239
|
+
style_formats?: [
|
240
|
+
{
|
241
|
+
items?: [
|
242
|
+
{
|
243
|
+
/**
|
244
|
+
* @defaultValue `'section'`
|
245
|
+
*/
|
246
|
+
block?: string;
|
247
|
+
|
248
|
+
/**
|
249
|
+
* @defaultValue `'secrect'`
|
250
|
+
*/
|
251
|
+
classes?: string;
|
252
|
+
|
253
|
+
/**
|
254
|
+
* @defaultValue `'Secret'`
|
255
|
+
*/
|
256
|
+
title?: string;
|
257
|
+
|
258
|
+
/**
|
259
|
+
* @defaultValue `true`
|
260
|
+
*/
|
261
|
+
wrapper?: boolean;
|
262
|
+
}
|
263
|
+
];
|
264
|
+
|
265
|
+
/**
|
266
|
+
* @defaultValue `'Custom'`
|
267
|
+
*/
|
268
|
+
title?: string;
|
269
|
+
}
|
270
|
+
];
|
271
|
+
|
272
|
+
/**
|
273
|
+
* @defaultValue `true`
|
274
|
+
*/
|
275
|
+
style_formats_merge?: boolean;
|
276
|
+
|
277
|
+
/**
|
278
|
+
* @defaultValue `{}`
|
279
|
+
*/
|
280
|
+
table_default_styles?: object;
|
281
|
+
|
282
|
+
target: HTMLElement;
|
283
|
+
|
284
|
+
/**
|
285
|
+
* @defaultValue `'styleselect bullist numlist image table hr link removeformat code save'`
|
286
|
+
*/
|
287
|
+
toolbar?: string;
|
288
|
+
}
|
289
|
+
|
290
|
+
interface EnrichOptions {
|
291
|
+
/**
|
292
|
+
* Include secret tags in the final HTML? If false secret blocks will be removed.
|
293
|
+
* @defaultValue `false`
|
294
|
+
*/
|
295
|
+
secrets: boolean;
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Replace dynamic document links?
|
299
|
+
* @defaultValue `true`
|
300
|
+
*/
|
301
|
+
documents: boolean;
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Replace hyperlink content?
|
305
|
+
* @defaultValue `true`
|
306
|
+
*/
|
307
|
+
links: boolean;
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Replace inline dice rolls?
|
311
|
+
* @defaultValue `true`
|
312
|
+
*/
|
313
|
+
rolls: boolean;
|
314
|
+
|
315
|
+
/**
|
316
|
+
* The data object providing context for inline rolls
|
317
|
+
*/
|
318
|
+
rollData: object | (() => object);
|
319
|
+
}
|
285
320
|
}
|
286
321
|
}
|
package/src/types/utils.d.ts
CHANGED
@@ -136,3 +136,8 @@ type StoredDocument<D extends foundry.abstract.Document<any, any>> = D & {
|
|
136
136
|
type TemporaryDocument<D> = D extends StoredDocument<infer U> ? U : D;
|
137
137
|
|
138
138
|
type PropertyTypeOrFallback<T, Key extends string, Fallback> = Key extends keyof T ? T[Key] : Fallback;
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Makes the given keys `K` of the type `T` required
|
142
|
+
*/
|
143
|
+
type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
|