diff --git a/api/JoplinCommands.d.ts b/api/JoplinCommands.d.ts index 3e3452b..babb249 100644 --- a/api/JoplinCommands.d.ts +++ b/api/JoplinCommands.d.ts @@ -15,7 +15,7 @@ import { Command } from './types'; * * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) - * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) + * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/editorCommandDeclarations.ts) * * To view what arguments are supported, you can open any of these files * and look at the `execute()` command. diff --git a/api/JoplinWorkspace.d.ts b/api/JoplinWorkspace.d.ts index cfaecf0..0a12e26 100644 --- a/api/JoplinWorkspace.d.ts +++ b/api/JoplinWorkspace.d.ts @@ -16,8 +16,12 @@ interface ItemChangeEvent { interface SyncStartEvent { withErrors: boolean; } +interface ResourceChangeEvent { + id: string; +} declare type ItemChangeHandler = (event: ItemChangeEvent) => void; declare type SyncStartHandler = (event: SyncStartEvent) => void; +declare type ResourceChangeHandler = (event: ResourceChangeEvent) => void; /** * The workspace service provides access to all the parts of Joplin that * are being worked on - i.e. the currently selected notes or notebooks as @@ -42,6 +46,11 @@ export default class JoplinWorkspace { * Called when the content of the current note changes. */ onNoteChange(handler: ItemChangeHandler): Promise; + /** + * Called when a resource is changed. Currently this handled will not be + * called when a resource is added or deleted. + */ + onResourceChange(handler: ResourceChangeHandler): Promise; /** * Called when an alarm associated with a to-do is triggered. */ diff --git a/api/types.ts b/api/types.ts index 9effa4e..640d083 100644 --- a/api/types.ts +++ b/api/types.ts @@ -297,7 +297,7 @@ export interface MenuItem { /** * Set to "separator" to create a divider line */ - type?: string; + type?: ('normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'); /** * Accelerator associated with the menu item @@ -364,6 +364,12 @@ export enum SettingItemType { Button = 6, } +export enum SettingItemSubType { + FilePathAndArgs = 'file_path_and_args', + FilePath = 'file_path', // Not supported on mobile! + DirectoryPath = 'directory_path', // Not supported on mobile! +} + export enum AppType { Desktop = 'desktop', Mobile = 'mobile', @@ -381,6 +387,12 @@ export interface SettingItem { value: any; type: SettingItemType; + /** + * Currently only used to display a file or directory selector. Always set + * `type` to `SettingItemType.String` when using this property. + */ + subType?: SettingItemSubType; + label: string; description?: string; diff --git a/package.json b/package.json index a905f94..62f3792 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,8 @@ "dependencies": { "date-fns": "^2.28.0", "yaml": "^1.10.2" - } -} + }, + "files": [ + "publish" + ] +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 78d2f70..1c2d7e7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,6 +29,7 @@ const userConfig = Object.assign({}, { const manifestPath = `${srcDir}/manifest.json`; const packageJsonPath = `${rootDir}/package.json`; +const allPossibleCategories = ['appearance', 'developer tools', 'productivity', 'themes', 'integrations', 'viewer', 'search', 'tags', 'editor', 'files', 'personal knowledge management']; const manifest = readManifest(manifestPath); const pluginArchiveFilePath = path.resolve(publishDir, `${manifest.id}.jpl`); const pluginInfoFilePath = path.resolve(publishDir, `${manifest.id}.json`); @@ -67,10 +68,19 @@ function currentGitInfo() { } } +function validateCategories(categories) { + if (!categories) return null; + if ((categories.length !== new Set(categories).size)) throw new Error('Repeated categories are not allowed'); + categories.forEach(category => { + if (!allPossibleCategories.includes(category)) throw new Error(`${category} is not a valid category. Please make sure that the category name is lowercase. Valid Categories are: \n${allPossibleCategories}\n`); + }); +} + function readManifest(manifestPath) { const content = fs.readFileSync(manifestPath, 'utf8'); const output = JSON.parse(content); if (!output.id) throw new Error(`Manifest plugin ID is not set in ${manifestPath}`); + validateCategories(output.categories); return output; }