orgnote-api 0.2.2 → 0.3.0
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/api.ts +5 -4
- package/models/command.ts +15 -6
- package/package.json +1 -1
package/api.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
MultilineEmbeddedWidget,
|
|
8
8
|
OrgLineClass,
|
|
9
9
|
WidgetBuilder,
|
|
10
|
+
CommandPreview,
|
|
10
11
|
} from './models';
|
|
11
12
|
import type { NavigationFailure } from 'vue-router';
|
|
12
13
|
import { WidgetType } from './models/widget-type';
|
|
@@ -68,10 +69,10 @@ export interface OrgNoteApi {
|
|
|
68
69
|
remove(...commands: Command[]): void;
|
|
69
70
|
get(name: string): Command;
|
|
70
71
|
getAll(): Command[];
|
|
71
|
-
addCommandToSidebar(...commands:
|
|
72
|
-
removeCommandFromSidebar(...commands:
|
|
73
|
-
addCommandToEditorPanel(...commands:
|
|
74
|
-
removeCommandFromEditorPanel(...commands:
|
|
72
|
+
addCommandToSidebar(...commands: CommandPreview[]): void;
|
|
73
|
+
removeCommandFromSidebar(...commands: CommandPreview[]): void;
|
|
74
|
+
addCommandToEditorPanel(...commands: CommandPreview[]): void;
|
|
75
|
+
removeCommandFromEditorPanel(...commands: CommandPreview[]): void;
|
|
75
76
|
};
|
|
76
77
|
configuration: () => OrgNoteConfig;
|
|
77
78
|
}
|
package/models/command.ts
CHANGED
|
@@ -8,26 +8,35 @@ export type CommandGroup =
|
|
|
8
8
|
| 'completion'
|
|
9
9
|
| string;
|
|
10
10
|
|
|
11
|
-
export interface CommandHandlerParams {
|
|
11
|
+
export interface CommandHandlerParams<T = any> {
|
|
12
12
|
event?: KeyboardEvent;
|
|
13
|
-
data?:
|
|
13
|
+
data?: T;
|
|
14
14
|
[key: string]: unknown;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export interface
|
|
18
|
-
// TODO: add support for multiple key sequences
|
|
19
|
-
keySequence?: string | string[];
|
|
17
|
+
export interface CommandPreview {
|
|
20
18
|
description?: string;
|
|
21
19
|
command?: string;
|
|
22
20
|
title?: string | (() => string);
|
|
23
21
|
icon?: string | (() => string);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CommandMeta<T = any> extends Partial<CommandPreview> {
|
|
25
|
+
// TODO: add support for multiple key sequences
|
|
26
|
+
keySequence?: string | string[];
|
|
24
27
|
/* Where is this command available, default value is global */
|
|
25
28
|
group?: CommandGroup;
|
|
26
29
|
allowOnInput?: boolean;
|
|
27
30
|
ignorePrompt?: boolean;
|
|
28
|
-
|
|
29
31
|
/* When command is system command, it will not be shown for users */
|
|
30
32
|
system?: boolean;
|
|
33
|
+
available?: () => boolean;
|
|
34
|
+
context?: {
|
|
35
|
+
[key: string]: T;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface Command<T = any> extends CommandMeta<T> {
|
|
31
40
|
/* arguments depend on the current scope */
|
|
32
41
|
handler: (params?: CommandHandlerParams) => unknown | Promise<unknown>;
|
|
33
42
|
}
|