orgnote-api 0.0.17 → 0.0.19

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 ADDED
@@ -0,0 +1,70 @@
1
+ import { Command , CSSVariable, ThemeVariable, Note } from './models';
2
+ import type { NavigationFailure } from 'vue-router';
3
+
4
+ export interface OrgNoteApi {
5
+ [key: string]: unknown;
6
+ getExtension?<T>(config: string): T;
7
+
8
+ system: {
9
+ reload: (params?: { verbose: boolean }) => Promise<void>;
10
+ };
11
+ navigation: {
12
+ openNote: (id: string) => Promise<void | NavigationFailure>;
13
+ editNote: (id: string) => Promise<void | NavigationFailure>;
14
+ };
15
+ ui: {
16
+ applyTheme: (theme: { [key in ThemeVariable]: string | number }) => void;
17
+ applyCssVariables: (styles: {
18
+ [key in CSSVariable]: string | number;
19
+ }) => void;
20
+ setThemeByMode: (themeName?: string) => void;
21
+ setDarkTheme: (themeName?: string) => void;
22
+ setLightTheme: (themeName?: string) => void;
23
+ applyStyles: (scopeName: string, styles: string) => void;
24
+ removeStyles: (scopeName: string) => void;
25
+ resetTheme: () => void;
26
+ };
27
+ interaction: {
28
+ confirm: (title: string, message: string) => Promise<boolean>;
29
+ };
30
+ currentNote: {
31
+ get: () => Note;
32
+ };
33
+ // hooks: {
34
+ // add: () => void;
35
+ // };
36
+ editor: {
37
+ widgets: {
38
+ add: () => void;
39
+ };
40
+ };
41
+ commands: {
42
+ add(...commands: Command[]): void;
43
+ // delete(...commands: Command[]): void;
44
+ // update(...commands: Command[]): void;
45
+ };
46
+ configuration: () => OrgNoteConfig;
47
+ }
48
+
49
+ export interface OrgNoteConfig {
50
+ editor: {
51
+ showSpecialSymbols: boolean;
52
+ showPropertyDrawer: boolean;
53
+ },
54
+ common: {
55
+ developerMode: boolean;
56
+ maximumLogsCount: number;
57
+ },
58
+ completion: {
59
+ showGroup: boolean;
60
+ defaultCompletionLimit: number;
61
+ },
62
+ ui: {
63
+ theme: 'light' | 'dark';
64
+ darkThemeName?: string;
65
+ lightThemeName?: string;
66
+ },
67
+ extensions: {
68
+ sources: string[];
69
+ }
70
+ }
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './api';
2
+ export * from './models';
@@ -0,0 +1,30 @@
1
+ export const DEFAULT_KEYBINDING_GROUP = 'default';
2
+
3
+ export type CommandGroup =
4
+ | 'settings'
5
+ | 'editor'
6
+ | 'global'
7
+ | 'note-detail'
8
+ | 'completion'
9
+ | string;
10
+
11
+ export interface CommandHandlerParams {
12
+ event?: KeyboardEvent;
13
+ data?: unknown;
14
+ [key: string]: unknown;
15
+ }
16
+
17
+ export interface Command {
18
+ // TODO: add support for multiple key sequences
19
+ keySequence?: string | string[];
20
+ description?: string;
21
+ command?: string;
22
+ title?: string | (() => string);
23
+ icon?: string | (() => string);
24
+ /* Where is this command available, default value is global */
25
+ group?: CommandGroup;
26
+ allowOnInput?: boolean;
27
+ ignorePrompt?: boolean;
28
+ /* arguments depend on the current scope */
29
+ handler: (params?: CommandHandlerParams) => unknown | Promise<unknown>;
30
+ }
@@ -0,0 +1,30 @@
1
+ export interface CompletionCandidate<T = unknown> {
2
+ icon?: string | (() => string);
3
+ group?: string;
4
+ title?: string | (() => string);
5
+ description?: string;
6
+ command: string;
7
+ data: T;
8
+ /* Command handler could be used instead of command string */
9
+ commandHandler?: (data: T) => void;
10
+ }
11
+
12
+ export interface CompletionSearchResult<T = unknown> {
13
+ total?: number;
14
+ result: CompletionCandidate<T>[];
15
+ }
16
+
17
+ export type CandidateGetterFn<T = unknown> = (
18
+ filter: string,
19
+ limit?: number,
20
+ offset?: number
21
+ ) => CompletionSearchResult<T> | Promise<CompletionSearchResult<T>>;
22
+
23
+ export interface CompletionConfigs<T = unknown> {
24
+ searchAutocompletions?: string[];
25
+ itemsGetter: CandidateGetterFn<T>;
26
+ placeholder?: string;
27
+ itemHeight?: string;
28
+ searchText?: string;
29
+ onClicked?: (candidate: CompletionCandidate<T>) => void;
30
+ }
@@ -0,0 +1,45 @@
1
+ import { OrgNoteApi } from '../api';
2
+
3
+ export interface ExtensionManifest {
4
+ /* Should be unique in the extension repo */
5
+ name: string;
6
+ version: string;
7
+ category: 'theme' | 'extension' | 'language pack' | 'other';
8
+ /* OrgNote api semver, 0.13.4 for example */
9
+ apiVersion?: string;
10
+ author?: string;
11
+ description?: string;
12
+ keywords?: string[];
13
+ // Repository url
14
+ sourceType: 'git' | 'file';
15
+ /* Default value is README.org */
16
+ readmeFilePath?: string;
17
+ /* WIP */
18
+ permissions?: Array<'files' | 'personal info' | '*' | 'third party'>;
19
+ reloadRequired?: boolean;
20
+ sourceUrl?: string;
21
+ sponsor?: string[];
22
+ development?: boolean;
23
+ icon?: string;
24
+ }
25
+
26
+ export interface Extension {
27
+ [key: string]: unknown;
28
+
29
+ onMounted: (api: OrgNoteApi) => Promise<void>;
30
+ onUnmounted?: (api: OrgNoteApi) => Promise<void>;
31
+ }
32
+
33
+ export interface ExtensionMeta {
34
+ manifest: ExtensionManifest;
35
+ uploaded?: boolean;
36
+ active?: boolean;
37
+ }
38
+
39
+ export interface StoredExtension extends ExtensionMeta {
40
+ module?: string;
41
+ }
42
+
43
+ export interface ActiveExtension extends ExtensionMeta {
44
+ module: Extension;
45
+ }
@@ -0,0 +1,7 @@
1
+ export * from './note';
2
+ export * from './command';
3
+ export * from './completion';
4
+ export * from './extension';
5
+ export * from './theme-variables';
6
+ export * from './widget';
7
+ export * from './modal';
@@ -0,0 +1,4 @@
1
+ export interface ModalConfig {
2
+ closable?: boolean;
3
+ title?: string;
4
+ }
package/models/note.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { ModelsPublicNote, ModelsPublicUser } from '../remote-api';
2
+
3
+ export interface NotesFilter {
4
+ searchText?: string;
5
+ userId?: string;
6
+ limit?: number;
7
+ offset?: number;
8
+ }
9
+
10
+ export interface NotePreview {
11
+ id: ModelsPublicNote['id'];
12
+ meta: ModelsPublicNote['meta'];
13
+ createdAt: ModelsPublicNote['createdAt'];
14
+ updatedAt: ModelsPublicNote['updatedAt'];
15
+ filePath: ModelsPublicNote['filePath'];
16
+ isMy: ModelsPublicNote['isMy'];
17
+ author?: ModelsPublicUser;
18
+ bookmarked?: boolean;
19
+ }
20
+
21
+ export interface Note extends ModelsPublicNote {
22
+ deleted?: Date;
23
+ bookmarked?: boolean;
24
+ }
@@ -0,0 +1,194 @@
1
+ /**
2
+ * This file is generated by the script `collect-css-variables.js`.
3
+ * Do not edit it manually.
4
+ **/
5
+
6
+ export enum ThemeVariable {
7
+ red = 'red',
8
+ orange = 'orange',
9
+ green = 'green',
10
+ teal = 'teal',
11
+ yellow = 'yellow',
12
+ blue = 'blue',
13
+ darkBlue = 'darkBlue',
14
+ magenta = 'magenta',
15
+ violet = 'violet',
16
+ cyan = 'cyan',
17
+ darkCyan = 'darkCyan',
18
+ white = 'white',
19
+ bg = 'bg',
20
+ bgAlt = 'bgAlt',
21
+ bgAlt2 = 'bgAlt2',
22
+ fg = 'fg',
23
+ fgAlt = 'fgAlt',
24
+ base0 = 'base0',
25
+ base1 = 'base1',
26
+ base2 = 'base2',
27
+ base3 = 'base3',
28
+ base4 = 'base4',
29
+ base5 = 'base5',
30
+ base6 = 'base6',
31
+ base7 = 'base7',
32
+ base8 = 'base8',
33
+ }
34
+
35
+ export enum CSSVariable {
36
+ bg = 'bg',
37
+ fg = 'fg',
38
+ dur = 'dur',
39
+ easyTableHeaderBackgroundColor = 'easyTableHeaderBackgroundColor',
40
+ easyTableHeaderFontColor = 'easyTableHeaderFontColor',
41
+ easyTableBodyRowBackgroundColor = 'easyTableBodyRowBackgroundColor',
42
+ easyTableBodyRowFontColor = 'easyTableBodyRowFontColor',
43
+ easyTableBodyRowHoverBackgroundColor = 'easyTableBodyRowHoverBackgroundColor',
44
+ easyTableFooterBackgroundColor = 'easyTableFooterBackgroundColor',
45
+ easyTableFooterFontColor = 'easyTableFooterFontColor',
46
+ easyTableBodyRowHoverFontColor = 'easyTableBodyRowHoverFontColor',
47
+ easyTableRowBorder = 'easyTableRowBorder',
48
+ easyTableBorder = 'easyTableBorder',
49
+ easyTableMessageFontColor = 'easyTableMessageFontColor',
50
+ btnFlatSize = 'btnFlatSize',
51
+ btnFlatBorder = 'btnFlatBorder',
52
+ btnFlatBorderRadius = 'btnFlatBorderRadius',
53
+ btnFlatBoxShadow = 'btnFlatBoxShadow',
54
+ btnMainColor = 'btnMainColor',
55
+ btnSocialSize = 'btnSocialSize',
56
+ btnSocialBackground = 'btnSocialBackground',
57
+ checkboxColor = 'checkboxColor',
58
+ editorFontFamily = 'editorFontFamily',
59
+ flexGapMd = 'flexGapMd',
60
+ flexGapSm = 'flexGapSm',
61
+ inlineCodeBackground = 'inlineCodeBackground',
62
+ inlineCodeFontColor = 'inlineCodeFontColor',
63
+ scrollBarWidth = 'scrollBarWidth',
64
+ scrollBarColor = 'scrollBarColor',
65
+ fontSizeSm = 'fontSizeSm',
66
+ fontSizeMd = 'fontSizeMd',
67
+ fontSizeLg = 'fontSizeLg',
68
+ headlineMargin = 'headlineMargin',
69
+ paragraphFontSize = 'paragraphFontSize',
70
+ mainFontFamily = 'mainFontFamily',
71
+ editorFontFamilyMain = 'editorFontFamilyMain',
72
+ paragraphFontFamily = 'paragraphFontFamily',
73
+ headlineFontFamily = 'headlineFontFamily',
74
+ codeFontFamily = 'codeFontFamily',
75
+ descriptionFontFamily = 'descriptionFontFamily',
76
+ descriptionFontSize = 'descriptionFontSize',
77
+ descriptionFontStyle = 'descriptionFontStyle',
78
+ descriptionFontColor = 'descriptionFontColor',
79
+ descriptionPadding = 'descriptionPadding',
80
+ codeFontSize = 'codeFontSize',
81
+ headlineFontWeight = 'headlineFontWeight',
82
+ fontColorAction = 'fontColorAction',
83
+ fontSm = 'fontSm',
84
+ fontMd = 'fontMd',
85
+ fontLg = 'fontLg',
86
+ ulFontSize = 'ulFontSize',
87
+ ulLineHeight = 'ulLineHeight',
88
+ ulFontFamily = 'ulFontFamily',
89
+ topBarHeight = 'topBarHeight',
90
+ contentMaxWidth = 'contentMaxWidth',
91
+ modelineHeight = 'modelineHeight',
92
+ modelinePadding = 'modelinePadding',
93
+ modelineBackground = 'modelineBackground',
94
+ cardBackgroundColor = 'cardBackgroundColor',
95
+ shadowMain = 'shadowMain',
96
+ sidebarWidth = 'sidebarWidth',
97
+ actionPaneOpenedWidth = 'actionPaneOpenedWidth',
98
+ footerHeight = 'footerHeight',
99
+ publicPreviewImageWidth = 'publicPreviewImageWidth',
100
+ publicPreviewImageHeight = 'publicPreviewImageHeight',
101
+ publicPreviewMaxHeight = 'publicPreviewMaxHeight',
102
+ completionItemMinHeight = 'completionItemMinHeight',
103
+ completionItemPadding = 'completionItemPadding',
104
+ completionItemMargin = 'completionItemMargin',
105
+ completionItemHoverBackground = 'completionItemHoverBackground',
106
+ completionItemHoverColor = 'completionItemHoverColor',
107
+ completionFloatTop = 'completionFloatTop',
108
+ completionBorderRadius = 'completionBorderRadius',
109
+ completionWidth = 'completionWidth',
110
+ completionMaxWidth = 'completionMaxWidth',
111
+ completionBorder = 'completionBorder',
112
+ completionBoxShadow = 'completionBoxShadow',
113
+ completionInputHeight = 'completionInputHeight',
114
+ completionContainerMargin = 'completionContainerMargin',
115
+ menuPadding = 'menuPadding',
116
+ fileUploaderBorderWidth = 'fileUploaderBorderWidth',
117
+ fileUploaderBorderStyle = 'fileUploaderBorderStyle',
118
+ fileUploaderBorderColor = 'fileUploaderBorderColor',
119
+ fileUploaderBg = 'fileUploaderBg',
120
+ fileUploaderOpacity = 'fileUploaderOpacity',
121
+ notePreviewLinkMaxWidth = 'notePreviewLinkMaxWidth',
122
+ notePreviewLinkHeight = 'notePreviewLinkHeight',
123
+ btnActionShadow = 'btnActionShadow',
124
+ btnActionBorder = 'btnActionBorder',
125
+ btnActionBorderColor = 'btnActionBorderColor',
126
+ btnActionPadding = 'btnActionPadding',
127
+ btnActionRadius = 'btnActionRadius',
128
+ btnActionFireColor = 'btnActionFireColor',
129
+ btnActionFireBorderColor = 'btnActionFireBorderColor',
130
+ btnActionMd = 'btnActionMd',
131
+ btnActionSm = 'btnActionSm',
132
+ btnActionLg = 'btnActionLg',
133
+ btnActionColor = 'btnActionColor',
134
+ btnActionBg = 'btnActionBg',
135
+ miniBufferBackground = 'miniBufferBackground',
136
+ miniBufferFontColor = 'miniBufferFontColor',
137
+ miniBufferBorderTop = 'miniBufferBorderTop',
138
+ miniBufferMaxHeight = 'miniBufferMaxHeight',
139
+ tagHoverBackground = 'tagHoverBackground',
140
+ tagHoverColor = 'tagHoverColor',
141
+ toolbarBorderTop = 'toolbarBorderTop',
142
+ toolbarHoverColor = 'toolbarHoverColor',
143
+ headerbarHeight = 'headerbarHeight',
144
+ headerbarBorderRadius = 'headerbarBorderRadius',
145
+ headerbarBackgroundColor = 'headerbarBackgroundColor',
146
+ headerbarColor = 'headerbarColor',
147
+ headerbarBorder = 'headerbarBorder',
148
+ fileItemBgHover = 'fileItemBgHover',
149
+ fileItemColorHover = 'fileItemColorHover',
150
+ fileItemHeight = 'fileItemHeight',
151
+ iconBtnColor = 'iconBtnColor',
152
+ iconBtnHoverColor = 'iconBtnHoverColor',
153
+ modalMaxHeight = 'modalMaxHeight',
154
+ modalMaxWidth = 'modalMaxWidth',
155
+ modalPadding = 'modalPadding',
156
+ blockPaddingSm = 'blockPaddingSm',
157
+ blockPaddingMd = 'blockPaddingMd',
158
+ blockPaddingLg = 'blockPaddingLg',
159
+ blockMarginMd = 'blockMarginMd',
160
+ blockMarginSm = 'blockMarginSm',
161
+ blockBorderRadiusMd = 'blockBorderRadiusMd',
162
+ blockBorderRadiusSm = 'blockBorderRadiusSm',
163
+ itemDefaultRadius = 'itemDefaultRadius',
164
+ searchIcnSize = 'searchIcnSize',
165
+ gapMd = 'gapMd',
166
+ gapSm = 'gapSm',
167
+ gapXs = 'gapXs',
168
+ srcBlockHeaderPaddingY = 'srcBlockHeaderPaddingY',
169
+ srcBlockFooterPaddingY = 'srcBlockFooterPaddingY',
170
+ srcBlockPaddingX = 'srcBlockPaddingX',
171
+ srcBlockPaddingY = 'srcBlockPaddingY',
172
+ srcBlockMarginY = 'srcBlockMarginY',
173
+ pagePadding = 'pagePadding',
174
+ editorLineHeight = 'editorLineHeight',
175
+ editorHeadlineLineHeight = 'editorHeadlineLineHeight',
176
+ editorDefaultLineHeight = 'editorDefaultLineHeight',
177
+ editorPaddingBottom = 'editorPaddingBottom',
178
+ editorCursorColor = 'editorCursorColor',
179
+ editorSelectionBgColor = 'editorSelectionBgColor',
180
+ editorSelectionColor = 'editorSelectionColor',
181
+ editorGutterColor = 'editorGutterColor',
182
+ editorGutterHoverColor = 'editorGutterHoverColor',
183
+ editorFoldPlaceholderColor = 'editorFoldPlaceholderColor',
184
+ editorActiveLineBgColor = 'editorActiveLineBgColor',
185
+ editorCaretColor = 'editorCaretColor',
186
+ orgListItemBulletMarginLeft = 'orgListItemBulletMarginLeft',
187
+ devicePaddingBottom = 'devicePaddingBottom',
188
+ graphNodeColor = 'graphNodeColor',
189
+ graphEdgeColor = 'graphEdgeColor',
190
+ graphActiveColor = 'graphActiveColor',
191
+ inputHeight = 'inputHeight',
192
+ inputLgHeight = 'inputLgHeight',
193
+ borderMain = 'borderMain',
194
+ }
@@ -0,0 +1,56 @@
1
+ import type { ChangeSpec } from '@codemirror/state';
2
+ import type { EditorView } from 'codemirror';
3
+ import type { NodeType, OrgNode } from 'org-mode-ast';
4
+
5
+ export type EmbeddedWidget = {
6
+ destroy: () => void;
7
+ refresh?: (...args: unknown[]) => void;
8
+ };
9
+
10
+ export interface WidgetBuilderParams {
11
+ wrap: HTMLElement;
12
+ orgNode: OrgNode;
13
+ rootNodeSrc: () => OrgNode;
14
+ onUpdateFn?: (newVal: string) => void;
15
+ editorView: EditorView;
16
+ readonly?: boolean;
17
+ }
18
+
19
+ export type WidgetBuilder = (params: WidgetBuilderParams) => EmbeddedWidget;
20
+
21
+ export interface CommonEmbeddedWidget {
22
+ satisfied?: (orgNode: OrgNode) => boolean;
23
+ widgetBuilder?: WidgetBuilder;
24
+ viewUpdater?: (orgNode: OrgNode, newVal: string) => ViewUpdateSchema;
25
+ ignoreEvent?: boolean;
26
+ showRangeOffset?: [number, number];
27
+ }
28
+
29
+ export interface MultilineEmbeddedWidget extends CommonEmbeddedWidget {
30
+ widgetBuilder: WidgetBuilder;
31
+ suppressEdit?: boolean;
32
+ }
33
+
34
+ export type MultilineEmbeddedWidgets = {
35
+ [key in NodeType]?: MultilineEmbeddedWidget;
36
+ };
37
+
38
+ export type ViewUpdateSchema = ChangeSpec;
39
+
40
+ export interface InlineEmbeddedWidget extends CommonEmbeddedWidget {
41
+ classBuilder?: (orgNode: OrgNode) => string;
42
+ decorationType: 'mark' | 'widget' | 'replace' | 'line';
43
+ ignoreEditing?: boolean;
44
+ side?: number;
45
+ wrapComponent?: string;
46
+ inclusive?: boolean;
47
+ }
48
+
49
+ export type InlineEmbeddedWidgets = {
50
+ [key in NodeType]?: InlineEmbeddedWidget;
51
+ };
52
+
53
+ export type EmbeddedWidgetBuilder = (
54
+ wrap: HTMLElement,
55
+ dynamicProps?: { [key: string]: unknown }
56
+ ) => EmbeddedWidget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orgnote-api",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Official API for creating extensions for OrgNote app",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -11,7 +11,7 @@
11
11
  "codegen:api": "openapi-generator-cli generate",
12
12
  "codegen:css-doc": "node collect-css-variables.cjs --docs",
13
13
  "codegen:css-types": "node collect-css-variables.cjs --types",
14
- "prepublish": "mv -rf ./src/* . && rm -rf ./src"
14
+ "prepublish": "mv -f ./src/* . && rm -rf ./src"
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
@@ -0,0 +1,4 @@
1
+ wwwroot/*.js
2
+ node_modules
3
+ typings
4
+ dist
@@ -0,0 +1 @@
1
+ # empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
@@ -0,0 +1,9 @@
1
+ .gitignore
2
+ .npmignore
3
+ .openapi-generator-ignore
4
+ api.ts
5
+ base.ts
6
+ common.ts
7
+ configuration.ts
8
+ git_push.sh
9
+ index.ts
@@ -0,0 +1 @@
1
+ 6.4.0
@@ -0,0 +1,23 @@
1
+ # OpenAPI Generator Ignore
2
+ # Generated by openapi-generator https://github.com/openapitools/openapi-generator
3
+
4
+ # Use this file to prevent files from being overwritten by the generator.
5
+ # The patterns follow closely to .gitignore or .dockerignore.
6
+
7
+ # As an example, the C# client generator defines ApiClient.cs.
8
+ # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9
+ #ApiClient.cs
10
+
11
+ # You can match any string of characters against a directory, file or extension with a single asterisk (*):
12
+ #foo/*/qux
13
+ # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14
+
15
+ # You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16
+ #foo/**/qux
17
+ # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18
+
19
+ # You can also negate patterns with an exclamation (!).
20
+ # For example, you can ignore all files in a docs folder with the file extension .md:
21
+ #docs/*.md
22
+ # Then explicitly reverse the ignore rule for a single file:
23
+ #!docs/README.md