tw5-typed 0.2.8 → 0.2.9
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/ast.d.ts +15 -5
- package/src/tw.d.ts +37 -1
- package/src/widget.d.ts +42 -5
package/package.json
CHANGED
package/src/ast.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ declare module 'tiddlywiki' {
|
|
|
3
3
|
end?: number;
|
|
4
4
|
name?: string;
|
|
5
5
|
start?: number;
|
|
6
|
-
type: 'string' | 'number' | 'bigint' | 'boolean' | '
|
|
7
|
-
value: string;
|
|
6
|
+
type: 'string' | 'number' | 'bigint' | 'boolean' | 'macro' | 'macro-parameter';
|
|
7
|
+
value: string | IMacroCallParseTreeNode;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface IWikiASTNode {
|
|
@@ -59,10 +59,17 @@ declare module 'tiddlywiki' {
|
|
|
59
59
|
value: string;
|
|
60
60
|
}
|
|
61
61
|
export interface IMacroCallParseTreeNode extends IWikiASTNode {
|
|
62
|
-
name
|
|
63
|
-
params
|
|
62
|
+
name?: string;
|
|
63
|
+
params?: IMacroParameterCallParseTreeNode[];
|
|
64
|
+
/** `tag: '$macrocall',` */
|
|
65
|
+
tag?: string;
|
|
64
66
|
type: 'macrocall';
|
|
65
67
|
}
|
|
68
|
+
export interface IMacroParseTreeNode extends IWikiASTNode {
|
|
69
|
+
name: string;
|
|
70
|
+
type: 'macro';
|
|
71
|
+
value: IMacroCallParseTreeNode;
|
|
72
|
+
}
|
|
66
73
|
export interface ICustomParseTreeNode extends IWikiASTNode {
|
|
67
74
|
params: IMacroParameterCallParseTreeNode[];
|
|
68
75
|
tag?: string;
|
|
@@ -70,6 +77,7 @@ declare module 'tiddlywiki' {
|
|
|
70
77
|
type: string;
|
|
71
78
|
}
|
|
72
79
|
export type IParseTreeNode =
|
|
80
|
+
| IWikiASTNode
|
|
73
81
|
| IDomParseTreeNode
|
|
74
82
|
| IMacroParameterCallParseTreeNode
|
|
75
83
|
| IMacroCallParseTreeNode
|
|
@@ -79,5 +87,7 @@ declare module 'tiddlywiki' {
|
|
|
79
87
|
| ITiddlerParseTreeNode
|
|
80
88
|
| ICodeBlockParseTreeNode
|
|
81
89
|
| ILinkParseTreeNode
|
|
82
|
-
| ICustomParseTreeNode
|
|
90
|
+
| ICustomParseTreeNode
|
|
91
|
+
| IMacroParseTreeNode
|
|
92
|
+
| IParseTreeAttribute;
|
|
83
93
|
}
|
package/src/tw.d.ts
CHANGED
|
@@ -59,7 +59,43 @@ declare module 'tiddlywiki' {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
browser: null |
|
|
62
|
+
browser: null | {
|
|
63
|
+
is?: {
|
|
64
|
+
android?: boolean;
|
|
65
|
+
bada?: boolean;
|
|
66
|
+
blackberry?: boolean;
|
|
67
|
+
chrome?: boolean;
|
|
68
|
+
firefox?: boolean;
|
|
69
|
+
firefoxos?: boolean;
|
|
70
|
+
gecko?: boolean;
|
|
71
|
+
ios?: boolean;
|
|
72
|
+
ipad?: boolean;
|
|
73
|
+
iphone?: boolean;
|
|
74
|
+
mobile?: boolean;
|
|
75
|
+
name?: boolean;
|
|
76
|
+
opera?: boolean;
|
|
77
|
+
phantomjs?: boolean;
|
|
78
|
+
safari?: boolean;
|
|
79
|
+
sailfish?: boolean;
|
|
80
|
+
seamonkey?: boolean;
|
|
81
|
+
silk?: boolean;
|
|
82
|
+
tizen?: boolean;
|
|
83
|
+
version?: boolean;
|
|
84
|
+
webkit?: boolean;
|
|
85
|
+
webos?: boolean;
|
|
86
|
+
windowsphone?: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated
|
|
90
|
+
* Install `$:/plugins/tiddlywiki/browser-sniff` to use `browser.is`
|
|
91
|
+
*/
|
|
92
|
+
isFirefox: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated
|
|
95
|
+
* Install `$:/plugins/tiddlywiki/browser-sniff` to use `browser.is`
|
|
96
|
+
*/
|
|
97
|
+
isIE: boolean;
|
|
98
|
+
};
|
|
63
99
|
|
|
64
100
|
config: ITWConfig;
|
|
65
101
|
|
package/src/widget.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare module 'tiddlywiki' {
|
|
|
12
12
|
[extraKeys: string]: unknown;
|
|
13
13
|
/** maybe a DOM click event, if trigger by button click */
|
|
14
14
|
event: UIEvent | Event;
|
|
15
|
+
name: string;
|
|
15
16
|
navigateFromTitle?: string;
|
|
16
17
|
/**
|
|
17
18
|
* Get `$param`
|
|
@@ -45,8 +46,11 @@ declare module 'tiddlywiki' {
|
|
|
45
46
|
parseTreeNode: IParseTreeNode;
|
|
46
47
|
wiki: ITiddlyWiki;
|
|
47
48
|
parentWidget?: Widget;
|
|
48
|
-
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
49
|
-
|
|
49
|
+
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
50
|
+
*
|
|
51
|
+
* This is a set of all widgets defined in tiddlywiki.
|
|
52
|
+
*/
|
|
53
|
+
widgetClasses: Record<string, Widget>;
|
|
50
54
|
/** we can use $tw.rootWidget.widgetClasses.widget to new a widget
|
|
51
55
|
*
|
|
52
56
|
* Like `new widget.widget(widgetNode,{` in `$tw.wiki.makeWidget`
|
|
@@ -59,6 +63,13 @@ declare module 'tiddlywiki' {
|
|
|
59
63
|
@param parseTreeNodes default to `this.parseTreeNode.children`, can be undefined
|
|
60
64
|
*/
|
|
61
65
|
makeChildWidgets(parseTreeNodes?: IParseTreeNode[], options?: { variables?: unknown }): void;
|
|
66
|
+
/**
|
|
67
|
+
* Remove any DOM nodes created by this widget or its children
|
|
68
|
+
*
|
|
69
|
+
* 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.
|
|
70
|
+
* Otherwise, ask the child widgets to delete their DOM nodes
|
|
71
|
+
*/
|
|
72
|
+
removeChildDomNodes(): void;
|
|
62
73
|
/**
|
|
63
74
|
Construct the widget object for a parse tree node, and return the new widget
|
|
64
75
|
options include:
|
|
@@ -90,6 +101,23 @@ declare module 'tiddlywiki' {
|
|
|
90
101
|
|
|
91
102
|
*/
|
|
92
103
|
execute(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Invoke the action widgets that are descendents of the current widget. Will call child widget's invokeAction recursively.
|
|
106
|
+
*
|
|
107
|
+
* @param triggeringWidget
|
|
108
|
+
* @param event
|
|
109
|
+
* @returns handled by any children
|
|
110
|
+
*/
|
|
111
|
+
invokeActions(triggeringWidget: Widget, event: IWidgetEvent): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Invoke the action associated with this widget
|
|
114
|
+
*
|
|
115
|
+
* No every widget has this method, but some do, like `action-xxx` widget, e.g., `action-sendmessage`
|
|
116
|
+
* @param triggeringWidget
|
|
117
|
+
* @param event
|
|
118
|
+
* @returns handled
|
|
119
|
+
*/
|
|
120
|
+
invokeAction: (triggeringWidget: Widget, event: IWidgetEvent) => boolean | undefined;
|
|
93
121
|
|
|
94
122
|
/**
|
|
95
123
|
* Lifecycle method: Render this widget into the DOM
|
|
@@ -112,9 +140,18 @@ declare module 'tiddlywiki' {
|
|
|
112
140
|
*/
|
|
113
141
|
refreshChildren(changedTiddlers: IChangedTiddlers): boolean;
|
|
114
142
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
refreshSelf(): boolean;
|
|
143
|
+
* Rebuild a previously rendered widget
|
|
144
|
+
*/
|
|
145
|
+
refreshSelf(): boolean | void;
|
|
146
|
+
/**
|
|
147
|
+
* 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
|
|
148
|
+
* @param startIndex Refer to this widget by its index within its parents children
|
|
149
|
+
*/
|
|
150
|
+
findNextSiblingDomNode(startIndex?: number): Node | null;
|
|
151
|
+
/**
|
|
152
|
+
* Find the first DOM node generated by a widget or its children
|
|
153
|
+
*/
|
|
154
|
+
findFirstDomNode(): Node | null;
|
|
118
155
|
computeAttributes(): Record<string, IParseTreeAttribute>;
|
|
119
156
|
/**
|
|
120
157
|
* Get parameters that user set in the widget
|