orgnote-api 0.2.1 → 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/README.org +6 -1
- package/api.ts +6 -4
- package/models/command.ts +15 -6
- package/package.json +1 -1
package/README.org
CHANGED
|
@@ -30,6 +30,8 @@ You can find all available methods here. They are currently undocumented.
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
* Connected links
|
|
33
|
+
- [[https://github.com/Artawower/orgnote-client/tree/master/src/components/extensions][Built-in extensions]]
|
|
34
|
+
- [[https://github.com/Artawower/orgnote-api/blob/master/src/api.ts#L24][Type definition for existing extension API]]
|
|
33
35
|
- [[https://github.com/artawower/orgnote][OrgNote entrypoint]]
|
|
34
36
|
- [[https://org-note.com/][Official website]]
|
|
35
37
|
- [[https://github.com/Artawower/orgnote-client][Org Note client]]
|
|
@@ -51,6 +53,8 @@ interface Extension {
|
|
|
51
53
|
}
|
|
52
54
|
#+END_SRC
|
|
53
55
|
|
|
56
|
+
You can find available methods of =OrgNoteApi= [[https://github.com/Artawower/orgnote-api/blob/master/src/api.ts#L24][here]]
|
|
57
|
+
|
|
54
58
|
** Extension manifest
|
|
55
59
|
Also, each extension should export manifest const:
|
|
56
60
|
#+BEGIN_SRC typescript
|
|
@@ -65,7 +69,7 @@ interface ExtensionManifest {
|
|
|
65
69
|
description?: string;
|
|
66
70
|
keywords?: string[];
|
|
67
71
|
// Repository url
|
|
68
|
-
sourceType: 'git' | 'file';
|
|
72
|
+
sourceType: 'git' | 'file' | 'builtin';
|
|
69
73
|
/* Default value is README.org */
|
|
70
74
|
readmeFilePath?: string;
|
|
71
75
|
/* WIP */
|
|
@@ -77,6 +81,7 @@ interface ExtensionManifest {
|
|
|
77
81
|
icon?: string;
|
|
78
82
|
}
|
|
79
83
|
#+END_SRC
|
|
84
|
+
** Extension API
|
|
80
85
|
* Publish to official repository
|
|
81
86
|
OrgNote has an official [[https://github.com/Artawower/orgnote-extensions][repository]] for user-based extensions. You can easily add new =recipes/<package>.json=
|
|
82
87
|
with =ExtensionManifest=
|
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';
|
|
@@ -67,10 +68,11 @@ export interface OrgNoteApi {
|
|
|
67
68
|
add(...commands: Command[]): void;
|
|
68
69
|
remove(...commands: Command[]): void;
|
|
69
70
|
get(name: string): Command;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
getAll(): Command[];
|
|
72
|
+
addCommandToSidebar(...commands: CommandPreview[]): void;
|
|
73
|
+
removeCommandFromSidebar(...commands: CommandPreview[]): void;
|
|
74
|
+
addCommandToEditorPanel(...commands: CommandPreview[]): void;
|
|
75
|
+
removeCommandFromEditorPanel(...commands: CommandPreview[]): void;
|
|
74
76
|
};
|
|
75
77
|
configuration: () => OrgNoteConfig;
|
|
76
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
|
}
|