orgnote-api 0.2.2 → 0.4.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 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: Command[]): void;
72
- removeCommandFromSidebar(...commands: Command[]): void;
73
- addCommandToEditorPanel(...commands: Command[]): void;
74
- removeCommandFromEditorPanel(...commands: Command[]): void;
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
@@ -1,3 +1,5 @@
1
+ import { DefaultCommands } from './default-commands';
2
+
1
3
  export const DEFAULT_KEYBINDING_GROUP = 'default';
2
4
 
3
5
  export type CommandGroup =
@@ -8,26 +10,35 @@ export type CommandGroup =
8
10
  | 'completion'
9
11
  | string;
10
12
 
11
- export interface CommandHandlerParams {
13
+ export interface CommandHandlerParams<T = any> {
12
14
  event?: KeyboardEvent;
13
- data?: unknown;
15
+ data?: T;
14
16
  [key: string]: unknown;
15
17
  }
16
18
 
17
- export interface Command {
18
- // TODO: add support for multiple key sequences
19
- keySequence?: string | string[];
19
+ export interface CommandPreview {
20
20
  description?: string;
21
- command?: string;
21
+ command?: DefaultCommands | string;
22
22
  title?: string | (() => string);
23
23
  icon?: string | (() => string);
24
+ }
25
+
26
+ export interface CommandMeta<T = any> extends Partial<CommandPreview> {
27
+ // TODO: add support for multiple key sequences
28
+ keySequence?: string | string[];
24
29
  /* Where is this command available, default value is global */
25
30
  group?: CommandGroup;
26
31
  allowOnInput?: boolean;
27
32
  ignorePrompt?: boolean;
28
-
29
33
  /* When command is system command, it will not be shown for users */
30
34
  system?: boolean;
35
+ available?: () => boolean;
36
+ context?: {
37
+ [key: string]: T;
38
+ };
39
+ }
40
+
41
+ export interface Command<T = any> extends CommandMeta<T> {
31
42
  /* arguments depend on the current scope */
32
43
  handler: (params?: CommandHandlerParams) => unknown | Promise<unknown>;
33
44
  }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * This are default commands. It's not a complete list
3
+ * Some of the commands are dynamically generated or
4
+ * can be added by user extensions.
5
+ */
6
+ export enum DefaultCommands {
7
+ // Global commands
8
+ REPORT_BUG = 'report bug',
9
+ OPEN_DEBUG_INFO = 'open debug info',
10
+ SHOW_LOGS = 'show logs',
11
+ TOGGLE_SIDEBAR = 'toggle sidebar',
12
+ TOGGLE_FILE_MANAGER = 'toggle file manager',
13
+ CREATE_NOTE = 'create note',
14
+ PROJECT_INFO = 'project info',
15
+
16
+ // Completion commands
17
+ SEARCH = 'search',
18
+ TOGGLE_COMMANDS = 'toggle commands',
19
+ RESTORE_COMPLETION = 'restore last completion',
20
+ EXIT_COMMAND_EXECUTOR = 'exit command executor',
21
+ NEXT_CANDIDATE = 'next candidate',
22
+ PREV_CANDIDATE = 'previous candidate',
23
+ EXECUTE_CANDIDATE = 'execute candidate',
24
+
25
+ // Settings
26
+ SETTINGS = 'settings',
27
+ RESET_THEME = 'reset theme',
28
+ TOGGLE_DARK_MODE = 'toggle dark mode',
29
+ TOGGLE_DEBUG_MODE = 'toggle debug mode',
30
+ }
package/models/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from './widget';
7
7
  export * from './modal';
8
8
  export * from './widget-type';
9
9
  export * from './editor';
10
+ export * from './default-commands';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.ts",