tw5-typed 0.4.3 → 0.4.5

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.4.3",
5
+ "version": "0.4.5",
6
6
  "url": "https://github.com/tiddly-gittly/tw5-typed",
7
7
  "homepage": "https://github.com/tiddly-gittly/tw5-typed",
8
8
  "bugs": {
package/src/core.d.ts CHANGED
@@ -21,6 +21,12 @@ declare module 'tiddlywiki' {
21
21
  getString(key: string, options: { variables: { title: string } }): string;
22
22
  }
23
23
 
24
+ export interface IMacro {
25
+ name: string;
26
+ params: Array[];
27
+ run: Function;
28
+ }
29
+
24
30
  export type IWikiInfo = Record<string, unknown>;
25
31
 
26
32
  export interface ITiddlyWiki {
@@ -50,6 +56,8 @@ declare module 'tiddlywiki' {
50
56
  passwordPrompt: PasswordPrompt;
51
57
  packageInfo: Record<string, unknown>;
52
58
  modal: IModal;
59
+ keyboardManager: KeyboardManager;
60
+ macros: Record<string, IMacro>;
53
61
 
54
62
  /**
55
63
  * Check for this window being the source of the drag. If true, some drop target widget will stop responding to the drop event, so you can handle drop event in your own widget.
@@ -7,6 +7,7 @@
7
7
  /// <reference path="parsers/index.d.ts" />
8
8
  /// <reference path="syncer/syncAdaptor.d.ts" />
9
9
  /// <reference path="syncer/syncer.d.ts" />
10
+ /// <reference path="keyboard.d.ts" />
10
11
 
11
12
  declare module 'tiddlywiki' {
12
13
  export interface ITWModuleExports {
@@ -0,0 +1,49 @@
1
+ declare module 'tiddlywiki' {
2
+ // 定义键盘事件信息的接口
3
+ export interface KeyInfo {
4
+ keyCode: number;
5
+ shiftKey: boolean;
6
+ altKey: boolean;
7
+ ctrlKey: boolean;
8
+ metaKey: boolean;
9
+ }
10
+
11
+ // 定义键盘管理器类的接口
12
+ export interface KeyboardManager {
13
+ namedKeys: Record<string, number>;
14
+ keyNames: string[];
15
+ metaKeyName: string;
16
+ shortcutKeysList: string[];
17
+ shortcutActionList: string[];
18
+ shortcutParsedList: (KeyInfo[] | undefined)[];
19
+ shortcutPriorityList: boolean[];
20
+ lookupNames: string[];
21
+ getModifierKeys: () => number[];
22
+ parseKeyDescriptor: (
23
+ keyDescriptor: string,
24
+ options?: { keyDescriptor?: string },
25
+ ) => KeyInfo | null;
26
+ parseKeyDescriptors: (
27
+ keyDescriptors: string[] | string,
28
+ options?: { stack?: string[]; wiki?: any },
29
+ ) => KeyInfo[];
30
+ getPrintableShortcuts: (keyInfoArray: KeyInfo[]) => string[];
31
+ checkKeyDescriptor: (event: any, keyInfo: KeyInfo) => boolean;
32
+ checkKeyDescriptors: (event: any, keyInfoArray: KeyInfo[]) => boolean;
33
+ getMatchingKeyDescriptor: (
34
+ event: any,
35
+ keyInfoArray: KeyInfo[],
36
+ ) => KeyInfo | null;
37
+ getEventModifierKeyDescriptor: (event: any) => string;
38
+ getShortcutTiddlerList: () => string[];
39
+ updateShortcutLists: (tiddlerList: string[]) => void;
40
+ handleKeydownEvent: (
41
+ event: any,
42
+ options?: { onlyPriority?: boolean },
43
+ ) => boolean;
44
+ detectNewShortcuts: (
45
+ changedTiddlers: Record<string, any>,
46
+ ) => boolean | string[];
47
+ handleShortcutChanges: (changedTiddlers: Record<string, any>) => void;
48
+ }
49
+ }
@@ -0,0 +1,16 @@
1
+ declare module 'tiddlywiki' {
2
+ export class EditWidget extends Widget {
3
+ editTitle: string;
4
+ editField: string;
5
+ editIndex: string;
6
+ editClass: string;
7
+ editPlaceholder: string;
8
+ editTabIndex: string;
9
+ editFocus: string;
10
+ editCancelPopups: string;
11
+ editInputActions: string;
12
+ editRefreshTitle: string;
13
+ editAutoComplete: string;
14
+ editorType: string;
15
+ }
16
+ }
@@ -1,4 +1,5 @@
1
1
  /// <reference path="./navigator.d.ts" />
2
+ /// <reference path="./edit.d.ts" />
2
3
 
3
4
  declare module 'tiddlywiki' {
4
5
  /**
@@ -387,7 +388,10 @@ declare module 'tiddlywiki' {
387
388
  ): void;
388
389
 
389
390
  /**
390
- * Add an event listener
391
+ * Add an event listener.
392
+ * If the handler is sync, then should return a boolean, `false` means the event is handled and don't propagate, and `true` will be dispatched to the parent widget.
393
+ * If the handler is async, then it is always propagate to the parent widget.
394
+ * @returns should propagate to parent widget
391
395
  */
392
396
  addEventListener(
393
397
  type: string,
@@ -398,7 +402,7 @@ declare module 'tiddlywiki' {
398
402
  * Dispatch an event to a widget. If the widget doesn't handle the event then it is also dispatched to the parent widget
399
403
  * Events added via `addEventListener`, like `tm-notify`, can be invoked by this.
400
404
  */
401
- dispatchEvent(typeOrEvent: string | Omit<IWidgetEvent, 'widget'>): void;
405
+ dispatchEvent(widgetEvent: Omit<IWidgetEvent, 'widget'> & { widget?: IWidgetEvent['widget'] }): void;
402
406
 
403
407
  /**
404
408
  * Rebuild a previously rendered widget
@@ -471,13 +475,6 @@ declare module 'tiddlywiki' {
471
475
  variables: Record<string, IWidgetVariable>,
472
476
  ): boolean;
473
477
 
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;
481
478
  removeLocalDomNodes(): void;
482
479
  }
483
480
  }
@@ -11,6 +11,7 @@ declare module 'tiddlywiki' {
11
11
  readonly text: string;
12
12
  readonly title: string;
13
13
  readonly type: string;
14
+ readonly 'color-scheme': 'dark' | 'light';
14
15
  }
15
16
 
16
17
  export class Tiddler {