tw5-typed 0.2.19 → 0.2.21
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/boot/config.d.ts +2 -1
- package/src/modules/story.d.ts +5 -5
- package/src/modules/widgets/index.d.ts +330 -120
- package/src/modules/wiki.d.ts +6 -0
- package/src/utils/index.d.ts +3 -3
- package/src/wiki/index.d.ts +4 -1
package/package.json
CHANGED
package/src/boot/config.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ declare module 'tiddlywiki' {
|
|
|
13
13
|
export type ITWConfig = IConfig;
|
|
14
14
|
|
|
15
15
|
interface IConfig {
|
|
16
|
-
[configName: string]: unknown;
|
|
17
16
|
/** Map type to file content type */
|
|
18
17
|
contentTypeInfo: Record<string, IContentTypeInfo>;
|
|
19
18
|
/** @default 'TIDDLYWIKI_EDITION_PATH' */
|
|
@@ -51,5 +50,7 @@ declare module 'tiddlywiki' {
|
|
|
51
50
|
wikiThemesSubDir: string;
|
|
52
51
|
/** @default './tiddlers' */
|
|
53
52
|
wikiTiddlersSubDir: string;
|
|
53
|
+
htmlUnsafeElements: string[];
|
|
54
|
+
[configName: string]: any;
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/modules/story.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare module 'tiddlywiki' {
|
|
|
4
4
|
storyTitle: string;
|
|
5
5
|
historyTitle: string;
|
|
6
6
|
|
|
7
|
-
constructor(options
|
|
7
|
+
constructor(options?: {
|
|
8
8
|
wiki?: Wiki;
|
|
9
9
|
storyTitle?: string;
|
|
10
10
|
historyTitle?: string;
|
|
@@ -14,13 +14,13 @@ declare module 'tiddlywiki' {
|
|
|
14
14
|
|
|
15
15
|
navigateTiddler(
|
|
16
16
|
navigateTo: string,
|
|
17
|
-
navigateFromTitle
|
|
18
|
-
navigateFromClientRect
|
|
17
|
+
navigateFromTitle?: string,
|
|
18
|
+
navigateFromClientRect?: DOMRect,
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
addToStory(
|
|
22
22
|
navigateTo: string,
|
|
23
|
-
navigateFromTitle
|
|
23
|
+
navigateFromTitle?: string,
|
|
24
24
|
options?: {
|
|
25
25
|
openLinkFromInsideRiver?: 'top' | 'bottom' | 'above' | 'below';
|
|
26
26
|
},
|
|
@@ -28,7 +28,7 @@ declare module 'tiddlywiki' {
|
|
|
28
28
|
|
|
29
29
|
addToHistory(
|
|
30
30
|
navigateTo: string | string[],
|
|
31
|
-
navigateFromClientRect
|
|
31
|
+
navigateFromClientRect?: DOMRect,
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
saveStoryList(storyList: string[] | string);
|
|
@@ -9,6 +9,24 @@ declare module 'tiddlywiki' {
|
|
|
9
9
|
deleted?: boolean;
|
|
10
10
|
modified?: boolean;
|
|
11
11
|
}
|
|
12
|
+
export interface IWidgetVariableParam {
|
|
13
|
+
name: string;
|
|
14
|
+
default: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IWidgetVariable {
|
|
18
|
+
value: string;
|
|
19
|
+
params?: IWidgetVariableParam[];
|
|
20
|
+
isMacroDefinition: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IWidgetInitialiseOptions {
|
|
24
|
+
document?: Document;
|
|
25
|
+
parentWidget?: Widget;
|
|
26
|
+
wiki?: ITiddlyWiki;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type IWidgetInitializeOptions = IWidgetInitialiseOptions;
|
|
12
30
|
|
|
13
31
|
export interface IWidgetEvent {
|
|
14
32
|
[extraKeys: string]: unknown;
|
|
@@ -36,11 +54,6 @@ declare module 'tiddlywiki' {
|
|
|
36
54
|
widget: Widget;
|
|
37
55
|
}
|
|
38
56
|
|
|
39
|
-
export interface IWidgetInitializeOptions {
|
|
40
|
-
wiki?: ITiddlyWiki;
|
|
41
|
-
parentWidget?: Widget;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
57
|
/**
|
|
45
58
|
* @link https://tiddlywiki.com/dev/#Widgets
|
|
46
59
|
*
|
|
@@ -90,181 +103,378 @@ declare module 'tiddlywiki' {
|
|
|
90
103
|
* * params: array of {name:, default:} for each parameter
|
|
91
104
|
* * isMacroDefinition: true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
|
|
92
105
|
*/
|
|
93
|
-
variables: Record<
|
|
94
|
-
string,
|
|
95
|
-
{
|
|
96
|
-
value: string;
|
|
97
|
-
params?: { name: string; default: string }[];
|
|
98
|
-
isMacroDefinition: boolean;
|
|
99
|
-
}
|
|
100
|
-
>;
|
|
106
|
+
variables: Record<string, IWidgetVariable>;
|
|
101
107
|
|
|
102
108
|
constructor(
|
|
103
109
|
parseTreeNode: IParseTreeNode,
|
|
104
|
-
options?:
|
|
110
|
+
options?: IWidgetInitialiseOptions,
|
|
105
111
|
);
|
|
106
112
|
|
|
107
113
|
/**
|
|
108
|
-
|
|
109
|
-
And push them to `this.children`
|
|
110
|
-
@param parseTreeNodes default to `this.parseTreeNode.children`, can be undefined
|
|
111
|
-
*/
|
|
112
|
-
makeChildWidgets(
|
|
113
|
-
parseTreeNodes?: IParseTreeNode[],
|
|
114
|
-
options?: { variables?: unknown },
|
|
115
|
-
): void;
|
|
116
|
-
|
|
117
|
-
/**
|
|
114
|
+
* @en
|
|
118
115
|
* Initialise widget properties. These steps are pulled out of the constructor so that we can reuse them in subclasses
|
|
116
|
+
* @zh
|
|
117
|
+
* 初始化widget属性。这些步骤被拉出构造函数,以便我们可以在子类中重复使用它们
|
|
119
118
|
*/
|
|
120
119
|
initialise(
|
|
121
120
|
parseTreeNode: IParseTreeNode,
|
|
122
|
-
options?:
|
|
123
|
-
document?: Document;
|
|
124
|
-
parentWidget?: Widget;
|
|
125
|
-
wiki?: ITiddlyWiki;
|
|
126
|
-
},
|
|
121
|
+
options?: IWidgetInitialiseOptions,
|
|
127
122
|
): void;
|
|
123
|
+
|
|
128
124
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
125
|
+
* @en
|
|
126
|
+
* Lifecycle method: Render this widget into the DOM
|
|
127
|
+
* @zh
|
|
128
|
+
* 生命周期方法: 将这个微件渲染到DOM中;
|
|
129
|
+
* 只会在首次渲染、销毁后重新渲染时自动调用,或者通过 refreshSelf 等方法主动调用
|
|
133
130
|
*/
|
|
134
|
-
|
|
131
|
+
render(parent: Node, nextSibling: Node | null): void;
|
|
132
|
+
|
|
135
133
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
* @en
|
|
135
|
+
* Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering.
|
|
136
|
+
* You can do some cleanup or buildup before return true.
|
|
137
|
+
* @zh
|
|
138
|
+
* 如果需要的话,有选择地刷新该微件。如果该微件或其任何子项需要重新渲染,则返回 true。
|
|
139
|
+
* 你可以在返回 true 之前做一些清理或构建工作。
|
|
140
|
+
* @param {IChangedTiddlers} changedTiddlers Object key is tiddler title, value is metadata about the change
|
|
141
|
+
* @link https://tiddlywiki.com/dev/#Selective%20Update
|
|
142
|
+
*/
|
|
143
|
+
refresh(changedTiddlers: IChangedTiddlers): boolean | void;
|
|
144
|
+
|
|
144
145
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
* Compute the internal state of the widget.
|
|
147
|
+
* This will be automatically called in the `render` method.
|
|
148
|
+
*
|
|
149
|
+
* For example, `getAttribute` and set them to class members.
|
|
150
|
+
*/
|
|
151
|
+
execute(): void;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @en
|
|
155
|
+
* Set the value of a context variable
|
|
156
|
+
* @zh
|
|
157
|
+
* 设置一个上下文变量的值
|
|
158
|
+
*
|
|
159
|
+
* @param {string } name name of the variable
|
|
160
|
+
* @param {string} value value of the variable
|
|
161
|
+
* @param {IWidgetVariableParam[]} [params=[]] array of {name:, default:} for each parameter
|
|
162
|
+
* @param {boolean} [isMacroDefinition=true] true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
|
|
163
|
+
*/
|
|
164
|
+
setVariable(
|
|
165
|
+
name: string,
|
|
166
|
+
value: string,
|
|
167
|
+
parameters?: IWidgetVariableParam[],
|
|
168
|
+
isMacroDefinition?: boolean,
|
|
150
169
|
): void;
|
|
170
|
+
|
|
151
171
|
/**
|
|
152
|
-
|
|
172
|
+
* Get variable in the context of the widget.
|
|
173
|
+
* Simplified version of getVariableInfo() that just returns the text.
|
|
174
|
+
* @param name variable name, for example, `currentTiddler` in the widget context
|
|
175
|
+
* @param options options for getVariableInfo()
|
|
176
|
+
*
|
|
177
|
+
* Options include
|
|
178
|
+
* * params: array of {name:, value:} for each parameter
|
|
179
|
+
* * defaultValue: default value if the variable is not defined
|
|
180
|
+
*
|
|
181
|
+
* Returns an object with the following fields:
|
|
182
|
+
* * params: array of {name:,value:} of parameters passed to wikitext variables
|
|
183
|
+
* * text: text of variable, with parameters properly substituted
|
|
184
|
+
*
|
|
185
|
+
* @param {string} name
|
|
186
|
+
* @param {{ params?: IWidgetVariableParam[]; defaultValue: string }} [options]
|
|
187
|
+
* @return {*} {{
|
|
188
|
+
* text: string;
|
|
189
|
+
* params?: IWidgetVariableParam[];
|
|
190
|
+
* srcVariable?: IWidgetVariable;
|
|
191
|
+
* isCacheable?: boolean;
|
|
192
|
+
* }}
|
|
193
|
+
* @memberof Widget
|
|
194
|
+
*/
|
|
195
|
+
getVariableInfo(
|
|
196
|
+
name: string,
|
|
197
|
+
options?: { params?: IWidgetVariableParam[]; defaultValue: string },
|
|
198
|
+
): {
|
|
199
|
+
text: string;
|
|
200
|
+
params?: IWidgetVariableParam[];
|
|
201
|
+
srcVariable?: IWidgetVariable;
|
|
202
|
+
isCacheable?: boolean;
|
|
203
|
+
};
|
|
153
204
|
|
|
154
|
-
Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
|
|
155
|
-
*/
|
|
156
|
-
dispatchEvent(typeOrEvent: string | Omit<IWidgetEvent, 'widget'>): void;
|
|
157
205
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
206
|
+
* Simplified version of getVariableInfo() that just returns the text
|
|
207
|
+
*
|
|
208
|
+
* @param {string} name
|
|
209
|
+
* @param {{ params?: IWidgetVariableParam[]; defaultValue: string }} [options]
|
|
210
|
+
* @return {*} {string}
|
|
211
|
+
* @memberof Widget
|
|
212
|
+
*/
|
|
213
|
+
getVariable(
|
|
214
|
+
name: string,
|
|
215
|
+
options?: { params?: IWidgetVariableParam[]; defaultValue: string },
|
|
216
|
+
): string;
|
|
217
|
+
|
|
218
|
+
resolveVariableParameters(
|
|
219
|
+
formalParams?: IWidgetVariableParam[],
|
|
220
|
+
actualParams?: IWidgetVariableParam[],
|
|
221
|
+
): IWidgetVariableParam[];
|
|
222
|
+
|
|
223
|
+
substituteVariableReferences(
|
|
224
|
+
text: string,
|
|
225
|
+
options: { variables: Record<string, string> },
|
|
226
|
+
): string;
|
|
227
|
+
|
|
228
|
+
evaluateMacroModule(
|
|
229
|
+
name: string,
|
|
230
|
+
actualParams: IWidgetVariableParam[],
|
|
231
|
+
defaultValue: string,
|
|
232
|
+
): string;
|
|
166
233
|
|
|
167
234
|
/**
|
|
168
|
-
|
|
169
|
-
|
|
235
|
+
* @en
|
|
236
|
+
* Check whether a given context variable value exists in the parent chain
|
|
237
|
+
* @zh
|
|
238
|
+
* 检查一个给定的上下文变量值是否存在于父链中
|
|
239
|
+
*
|
|
240
|
+
* @param {string} name
|
|
241
|
+
* @param {string} value
|
|
242
|
+
* @return {*} {boolean}
|
|
243
|
+
* @memberof Widget
|
|
244
|
+
*/
|
|
245
|
+
hasVariable(name: string, value: string): boolean;
|
|
170
246
|
|
|
171
|
-
|
|
247
|
+
/**
|
|
248
|
+
* @en
|
|
249
|
+
* Construct a qualifying string based on a hash of concatenating the values of a given variable in the parent chain
|
|
250
|
+
* @zh
|
|
251
|
+
* 在连接父链中给定变量值的哈希基础上构建一个限定字符串
|
|
252
|
+
*
|
|
253
|
+
* @param {string} name
|
|
254
|
+
* @return {*} {string}
|
|
255
|
+
* @memberof Widget
|
|
256
|
+
*/
|
|
257
|
+
getStateQualifier(name: string): string;
|
|
172
258
|
|
|
173
|
-
*/
|
|
174
|
-
execute(): void;
|
|
175
259
|
/**
|
|
176
|
-
*
|
|
260
|
+
* @en
|
|
261
|
+
* Compute the current values of the attributes of the widget. Returns a hashmap of the names of the attributes that have changed
|
|
262
|
+
* @zh
|
|
263
|
+
* 计算微件的属性的当前值。返回一个已经改变的属性名称的哈希图
|
|
177
264
|
*
|
|
178
|
-
* @
|
|
179
|
-
* @
|
|
180
|
-
* @returns handled by any children
|
|
265
|
+
* @return {*} {Record<string, true>}
|
|
266
|
+
* @memberof Widget
|
|
181
267
|
*/
|
|
182
|
-
|
|
268
|
+
computeAttributes(): Record<string, true>;
|
|
269
|
+
|
|
270
|
+
computeAttribute(attribute: string): string;
|
|
271
|
+
|
|
183
272
|
/**
|
|
184
|
-
*
|
|
273
|
+
* @en
|
|
274
|
+
* Check for the presence of an evaluated attribute on the widget. Note that attributes set to a missing variable (ie `attr=<<missing>>`) will be treated as missing
|
|
275
|
+
* @zh
|
|
276
|
+
* 检查微件上是否存在一个已评估的属性。请注意,设置为缺失变量的属性(即`attr=<<missing>>`)将被视为缺失。
|
|
185
277
|
*
|
|
186
|
-
*
|
|
187
|
-
* @
|
|
188
|
-
* @
|
|
189
|
-
* @returns handled
|
|
278
|
+
* @param {string} attribute
|
|
279
|
+
* @return {*} {boolean}
|
|
280
|
+
* @memberof Widget
|
|
190
281
|
*/
|
|
191
|
-
|
|
192
|
-
triggeringWidget: Widget,
|
|
193
|
-
event: IWidgetEvent,
|
|
194
|
-
): boolean | undefined;
|
|
282
|
+
hasAttribute(attribute: string): boolean;
|
|
195
283
|
|
|
196
284
|
/**
|
|
197
|
-
*
|
|
285
|
+
* @en
|
|
286
|
+
* Check for the presence of a raw attribute on the widget parse tree node. Note that attributes set to a missing variable (ie `attr=<<missing>>`) will NOT be treated as missing
|
|
287
|
+
* @zh
|
|
288
|
+
* 检查微件解析树节点上是否存在原始属性。注意,设置为缺失变量的属性(即`ttr=<<missing>>`)不会被视为缺失。
|
|
289
|
+
*
|
|
290
|
+
* @param {string} attribute
|
|
291
|
+
* @return {*} {boolean}
|
|
292
|
+
* @memberof Widget
|
|
198
293
|
*/
|
|
199
|
-
|
|
294
|
+
hasParseTreeNodeAttribute(attribute: string): boolean;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @en
|
|
298
|
+
* Get parameters that user set in the widget
|
|
299
|
+
* @zh
|
|
300
|
+
* 获取用户在小组件中设置的参数
|
|
301
|
+
*
|
|
302
|
+
* @param {string} name attribute name, for example, `actions` in the button widget
|
|
303
|
+
* @param {string} [fallbackText] default value if the attribute is not set
|
|
304
|
+
* @return {*} {string}
|
|
305
|
+
* @memberof Widget
|
|
306
|
+
*/
|
|
307
|
+
getAttribute(name: string, fallbackText?: string): string;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @en
|
|
311
|
+
* Assign the computed attributes of the widget to a domNode
|
|
312
|
+
* options include:
|
|
313
|
+
* * `excludeEventAttributes`: ignores attributes whose name begins with "on"
|
|
314
|
+
* @zh
|
|
315
|
+
* 将微件的计算属性分配给一个domNode, 选项包括:
|
|
316
|
+
* * `excludeEventAttributes`: 忽略名称以 "on "开头的属性
|
|
317
|
+
* 一些特殊的属性:
|
|
318
|
+
* * `xlink:<xlink-name>`
|
|
319
|
+
* * `style.<css-style-name>`
|
|
320
|
+
*
|
|
321
|
+
* @param {*} domNode
|
|
322
|
+
* @param {*} options
|
|
323
|
+
* @memberof Widget
|
|
324
|
+
*/
|
|
325
|
+
assignAttributes(
|
|
326
|
+
domNode: Node,
|
|
327
|
+
options?: { excludeEventAttributes?: boolean },
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @en
|
|
332
|
+
* Get the number of ancestor widgets for this widget
|
|
333
|
+
* @zh
|
|
334
|
+
* 获取这个微件的祖先微件的数量
|
|
335
|
+
*
|
|
336
|
+
* @return {*} {number}
|
|
337
|
+
* @memberof Widget
|
|
338
|
+
*/
|
|
339
|
+
getAncestorCount(): number;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Make child widgets correspondng to specified parseTreeNodes
|
|
343
|
+
* And push them to `this.children`
|
|
344
|
+
* @param parseTreeNodes default to `this.parseTreeNode.children`, can be undefined
|
|
345
|
+
*/
|
|
346
|
+
makeChildWidgets(
|
|
347
|
+
parseTreeNodes?: IParseTreeNode[],
|
|
348
|
+
options?: { variables?: unknown },
|
|
349
|
+
): void;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Construct the widget object for a parse tree node, and return the new widget
|
|
353
|
+
* options include:
|
|
354
|
+
* variables: optional hashmap of variables to wrap around the widget
|
|
355
|
+
*/
|
|
356
|
+
makeChildWidget(
|
|
357
|
+
parseTreeNode: IParseTreeNode,
|
|
358
|
+
options?: { variables?: unknown },
|
|
359
|
+
): Widget;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @en
|
|
363
|
+
* Get the next sibling of this widget
|
|
364
|
+
*
|
|
365
|
+
* @return {*} {(Widget | null)}
|
|
366
|
+
* @memberof Widget
|
|
367
|
+
*/
|
|
368
|
+
nextSibling(): Widget | null;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @en
|
|
372
|
+
* Get the previous sibling of this widget
|
|
373
|
+
*
|
|
374
|
+
* @return {*} {(Widget | null)}
|
|
375
|
+
* @memberof Widget
|
|
376
|
+
*/
|
|
377
|
+
previousSibling(): Widget | null;
|
|
378
|
+
|
|
200
379
|
/**
|
|
201
380
|
* Render the children of this widget into the DOM
|
|
202
381
|
*/
|
|
203
382
|
renderChildren(parent: Node, nextSibling: Node | null): void;
|
|
383
|
+
|
|
204
384
|
/**
|
|
205
|
-
*
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
385
|
+
* Add a list of event listeners from an array [{type:,handler:},...]
|
|
386
|
+
*/
|
|
387
|
+
addEventListeners(
|
|
388
|
+
listeners: {
|
|
389
|
+
handler: (event: IWidgetEvent) => void | Promise<void>;
|
|
390
|
+
type: string;
|
|
391
|
+
}[],
|
|
392
|
+
): void;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Add an event listener
|
|
209
396
|
*/
|
|
210
|
-
|
|
397
|
+
addEventListener(
|
|
398
|
+
type: string,
|
|
399
|
+
handler: (event: IWidgetEvent) => void | Promise<void>,
|
|
400
|
+
): void;
|
|
401
|
+
|
|
211
402
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
403
|
+
* Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
|
|
404
|
+
* Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
|
|
405
|
+
*/
|
|
406
|
+
dispatchEvent(typeOrEvent: string | Omit<IWidgetEvent, 'widget'>): void;
|
|
214
407
|
|
|
215
|
-
Need to call this after `setVariable`
|
|
216
|
-
*/
|
|
217
|
-
refreshChildren(changedTiddlers?: IChangedTiddlers): boolean;
|
|
218
408
|
/**
|
|
219
409
|
* Rebuild a previously rendered widget
|
|
220
410
|
*/
|
|
221
411
|
refreshSelf(): boolean | void;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Refresh all the children of a widget, will call `this.render`.
|
|
415
|
+
* Need to call this after `setVariable`
|
|
416
|
+
*/
|
|
417
|
+
refreshChildren(changedTiddlers?: IChangedTiddlers): boolean;
|
|
418
|
+
|
|
222
419
|
/**
|
|
223
420
|
* Find the next sibling in the DOM to this widget. This is done by scanning the widget tree through all next siblings and their descendents that share the same parent DOM node
|
|
224
421
|
* @param startIndex Refer to this widget by its index within its parents children
|
|
225
422
|
*/
|
|
226
423
|
findNextSiblingDomNode(startIndex?: number): Node | null;
|
|
424
|
+
|
|
227
425
|
/**
|
|
228
426
|
* Find the first DOM node generated by a widget or its children
|
|
229
427
|
*/
|
|
230
428
|
findFirstDomNode(): Node | null;
|
|
231
|
-
|
|
429
|
+
|
|
232
430
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
431
|
+
* Remove any DOM nodes created by this widget or its children
|
|
432
|
+
*
|
|
433
|
+
* If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case.
|
|
434
|
+
* Otherwise, ask the child widgets to delete their DOM nodes
|
|
236
435
|
*/
|
|
237
|
-
|
|
436
|
+
removeChildDomNodes(): void;
|
|
437
|
+
|
|
238
438
|
/**
|
|
239
|
-
*
|
|
240
|
-
* Simplified version of getVariableInfo() that just returns the text.
|
|
241
|
-
* @param name variable name, for example, `currentTiddler` in the widget context
|
|
242
|
-
* @param options options for getVariableInfo()
|
|
439
|
+
* Invoke the action associated with this widget
|
|
243
440
|
*
|
|
244
|
-
*
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
Returns an object with the following fields:
|
|
249
|
-
|
|
250
|
-
params: array of {name:,value:} of parameters passed to wikitext variables
|
|
251
|
-
text: text of variable, with parameters properly substituted
|
|
441
|
+
* No every widget has this method, but some do, like `action-xxx` widget, e.g., `action-sendmessage`
|
|
442
|
+
* @param triggeringWidget
|
|
443
|
+
* @param event
|
|
444
|
+
* @returns handled
|
|
252
445
|
*/
|
|
253
|
-
|
|
446
|
+
invokeAction?(
|
|
447
|
+
triggeringWidget: Widget,
|
|
448
|
+
event: IWidgetEvent,
|
|
449
|
+
): boolean | undefined;
|
|
450
|
+
|
|
254
451
|
/**
|
|
255
|
-
|
|
452
|
+
* @en
|
|
453
|
+
* Invoke the action widgets that are descendents of the current widget.
|
|
454
|
+
*
|
|
455
|
+
* @param {Widget} triggeringWidget
|
|
456
|
+
* @param {IWidgetEvent} event
|
|
457
|
+
* @memberof Widget
|
|
458
|
+
*/
|
|
459
|
+
invokeActions(triggeringWidget: Widget, event: IWidgetEvent): boolean;
|
|
256
460
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
461
|
+
/**
|
|
462
|
+
* @en
|
|
463
|
+
* Invoke the action widgets defined in a string
|
|
464
|
+
*
|
|
465
|
+
* @param {string} actions
|
|
466
|
+
* @param {Widget} triggeringWidget
|
|
467
|
+
* @param {IWidgetEvent} event
|
|
468
|
+
* @param {Record<string, IWidgetVariable>} variables
|
|
469
|
+
* @return {*} {boolean}
|
|
470
|
+
* @memberof Widget
|
|
471
|
+
*/
|
|
472
|
+
invokeActionString(
|
|
473
|
+
actions: string,
|
|
474
|
+
triggeringWidget: Widget,
|
|
475
|
+
event: IWidgetEvent,
|
|
476
|
+
variables: Record<string, IWidgetVariable>,
|
|
477
|
+
): boolean;
|
|
268
478
|
}
|
|
269
479
|
|
|
270
480
|
export interface IFakeDocument {
|
package/src/modules/wiki.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ declare const getModificationFields: () => {
|
|
|
4
4
|
modifier?: string;
|
|
5
5
|
};
|
|
6
6
|
declare const getTiddlersWithTag: (tag: string) => string[];
|
|
7
|
+
declare const getTextReferenceParserInfo: (
|
|
8
|
+
title: string,
|
|
9
|
+
field?: string,
|
|
10
|
+
index?: string,
|
|
11
|
+
options: { subTiddler: string },
|
|
12
|
+
) => { sourceText: null | string; parserType: string | null };
|
|
7
13
|
|
|
8
14
|
declare module 'tiddlywiki' {
|
|
9
15
|
export interface Wiki {
|
package/src/utils/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
|
|
|
23
23
|
: unknown;
|
|
24
24
|
|
|
25
25
|
declare module 'tiddlywiki' {
|
|
26
|
-
export type TWDocument = Document;
|
|
26
|
+
export type TWDocument = Document | IFakeDocument;
|
|
27
27
|
export type TWElement = Element;
|
|
28
28
|
export type TWDOMElement = TWElement;
|
|
29
29
|
export type ITWUtils = IUtils;
|
|
@@ -209,10 +209,10 @@ declare module 'tiddlywiki' {
|
|
|
209
209
|
* 产生一个 DOM 元素
|
|
210
210
|
*
|
|
211
211
|
* @param {string} tag tag name
|
|
212
|
-
* @param {IDomMakerOptions}
|
|
212
|
+
* @param {IDomMakerOptions} options
|
|
213
213
|
* @returns {TWElement}
|
|
214
214
|
*/
|
|
215
|
-
domMaker: (tag: string, options
|
|
215
|
+
domMaker: (tag: string, options: IDomMakerOptions) => TWElement;
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
218
|
* @en
|
package/src/wiki/index.d.ts
CHANGED
|
@@ -217,7 +217,10 @@ declare module 'tiddlywiki' {
|
|
|
217
217
|
variables: hashmap of variables to set
|
|
218
218
|
parentWidget: optional parent widget for the root node
|
|
219
219
|
*/
|
|
220
|
-
makeWidget(
|
|
220
|
+
makeWidget(
|
|
221
|
+
parser: { tree: IParseTreeNode[] },
|
|
222
|
+
options?: IMakeWidgetOptions,
|
|
223
|
+
): Widget;
|
|
221
224
|
/**
|
|
222
225
|
Make a widget tree for transclusion
|
|
223
226
|
@params title: target tiddler title
|