tw5-typed 0.3.8 → 0.3.10

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  "description": "Types for tiddlywiki",
3
3
  "license": "MIT",
4
4
  "name": "tw5-typed",
5
- "version": "0.3.8",
5
+ "version": "0.3.10",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
@@ -9,6 +9,8 @@ declare module 'tiddlywiki' {
9
9
  */
10
10
  parseAsInline?: boolean;
11
11
  defaultType?: string;
12
+ parentWidget?: Widget;
13
+ document?: TWDocument;
12
14
  }
13
15
 
14
16
  export class WikiParseRule {
@@ -106,6 +106,12 @@ declare module 'tiddlywiki' {
106
106
  data: string;
107
107
  server: Server;
108
108
  wiki: Wiki;
109
+ /**
110
+ * With `exports.path = /^\/recipes\/default\/tiddlers\/(.+)$/;` you can use:
111
+ *
112
+ * `title = $tw.utils.decodeURIComponentSafe(state.params[0])`
113
+ */
114
+ params: string[];
109
115
  }
110
116
  /**
111
117
  * @link https://talk.tiddlywiki.org/t/what-is-the-state-in-server-route-handler/2877
@@ -23,6 +23,12 @@ declare module 'tiddlywiki' {
23
23
  * Notifier mechanism
24
24
  */
25
25
  Notifier: typeof Notifier;
26
+ /**
27
+ * Copy plain text to the clipboard on browsers that support it.
28
+ *
29
+ * And send a notification to the user if doNotNotify is not true.
30
+ */
31
+ copyToClipboard(text: string, option?: { doNotNotify?: boolean }): void;
26
32
  }
27
33
  export class Notifier {
28
34
  /**
@@ -470,6 +470,14 @@ declare module 'tiddlywiki' {
470
470
  event: IWidgetEvent,
471
471
  variables: Record<string, IWidgetVariable>,
472
472
  ): boolean;
473
+
474
+ /**
475
+ * The destroy method will be called by parent widget.
476
+ * If you widget don't have any child widget, you can just write your own tear down logic. If it may have some child widget, don't forget to call original destroy method in the Widget class to destroy children widgets.
477
+ * @version >=5.3.0
478
+ * @url https://tiddlywiki.com/dev/#Widget%20%60destroy%60%20method%20examples
479
+ */
480
+ destroy(): void;
473
481
  }
474
482
 
475
483
  export type ModalWidget = {
@@ -38,7 +38,7 @@ declare module 'tiddlywiki' {
38
38
  Get all the fields as a hashmap of strings. Options:
39
39
  exclude: an array of field names to exclude
40
40
  */
41
- getFieldStrings(field: string, defaultValue?: string): string;
41
+ getFieldStrings(options?: { exclude?: string[] }): Record<string, string>;
42
42
  getFieldDay(field: string): string;
43
43
  /**
44
44
  Get the value of a field as a list
@@ -194,7 +194,7 @@ declare module 'tiddlywiki' {
194
194
  parseTiddler(title: string, options?: IParseOptions): WikiParser;
195
195
  /**
196
196
  Parse a block of text of a specified MIME type
197
- @param {string} type: content type of text to be parsed
197
+ @param {string} type: MIME content type of text to be parsed
198
198
  @param {string} text: text
199
199
  @param {object}options: see below
200
200
 
@@ -203,6 +203,22 @@ declare module 'tiddlywiki' {
203
203
  - _canonical_uri: optional string of the canonical URI of this content
204
204
  */
205
205
  parseText(type: string, text: string, options?: IParseOptions): WikiParser;
206
+ /**
207
+ * Extracts tiddlers from a typed block of text, specifying default field values
208
+ * @param {string} type: MIME content type of text to be parsed
209
+ * @param {string} text: text
210
+ * @param {object} srcFields: default field values
211
+ * @param {object} options: see below
212
+ *
213
+ * Options include:
214
+ * - deserializer: string, key of `$tw.Wiki.tiddlerDeserializerModules`
215
+ */
216
+ deserializeTiddlers(
217
+ type: string,
218
+ text: string,
219
+ srcFields?: ITiddlerFieldsParam,
220
+ options?: IParseOptions,
221
+ ): ITiddlerFieldsParam[];
206
222
  /**
207
223
  Parse text from a tiddler and render it into another format
208
224
  outputType: content type for the output
@@ -314,17 +330,11 @@ declare module 'tiddlywiki' {
314
330
  handler: (event: unknown) => void | Promise<void>,
315
331
  ): void;
316
332
  addEventListener(
317
- type: "change",
333
+ type: 'change',
318
334
  handler: (change: IChangedTiddlers) => void | Promise<void>,
319
335
  ): void;
320
336
 
321
- dispatchEvent(
322
- type: string,
323
- dataOrEvent: unknown,
324
- ): void;
325
- dispatchEvent(
326
- type: "change",
327
- change: IChangedTiddlers,
328
- ): void;
337
+ dispatchEvent(type: string, dataOrEvent: unknown): void;
338
+ dispatchEvent(type: 'change', change: IChangedTiddlers): void;
329
339
  }
330
340
  }