Desktop: Resolves #8408: Adding support for plugin icons (#8499)

pull/8554/head
Hubert 2023-07-25 11:47:43 -03:00 committed by GitHub
parent c50181f0a6
commit 672ef1fd7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 4 deletions

View File

@ -10,5 +10,6 @@
"repository_url": "<%= pluginRepositoryUrl %>",
"keywords": [],
"categories": [],
"screenshots": []
}
"screenshots": [],
"icons": {}
}

View File

@ -1,4 +1,4 @@
import { PluginManifest, PluginPermission, Screenshot } from './types';
import { PluginManifest, PluginPermission, Screenshot, Icons } from './types';
import validatePluginId from './validatePluginId';
export default function manifestFromObject(o: any): PluginManifest {
@ -36,6 +36,13 @@ export default function manifestFromObject(o: any): PluginManifest {
return o.screenshots;
};
const getIcons = (): Icons => {
for (const size of [16, 32, 48, 128]) {
if (o.icons[size as keyof Icons]) return o.icons;
}
return null;
};
const permissions: PluginPermission[] = [];
const manifest: PluginManifest = {
@ -53,6 +60,7 @@ export default function manifestFromObject(o: any): PluginManifest {
categories: getStrings('categories', false),
screenshots: getScreenshots(),
permissions: permissions,
icons: getIcons(),
_recommended: getBoolean('_recommended', false, false),
_built_in: getBoolean('_built_in', false, false),

View File

@ -7,6 +7,13 @@ export interface Screenshot {
label: string;
}
export interface Icons {
16?: string;
32?: string;
48?: string;
128?: string;
}
export interface PluginManifest {
manifest_version: number;
id: string;
@ -21,6 +28,7 @@ export interface PluginManifest {
categories?: string[];
screenshots?: Screenshot[];
permissions?: PluginPermission[];
icons?: Icons;
// Private keys
_package_hash?: string;

View File

@ -15,6 +15,7 @@ Name | Type | Required? | Description
`repository_url` | string | No | Repository URL where the plugin source code is hosted.
`categories` | string[] | No | [Categories](#categories) that describes the functionality of the plugin.
`screenshots` | Screenshot[] | No | [Screenshots](#Screenshot) are used for listing on Joplin Plugin website.
`icons` | Icons | No | If [Icons](#Icons) is not supplied, a standard extension icon will be used by default. You should supply at least a main icon, ideally 48x48 px in size. This is the icon that will be used in various plugin pages. You may, however, supply icons of any size and Joplin will attempt to find the best icon to display in different components. Only PNG icons are allowed.
## Categories
@ -39,6 +40,15 @@ Name | Type | Required? | Description
| src | a relative path to src dir. |
| label | description of the image. |
## Icons
| Properties | Description |
| --- | --- |
| 16 | a relative path to a PNG icon. |
| 32 | a relative path to a PNG icon. |
| 48 | a relative path to a PNG icon. |
| 128 | a relative path to a PNG icon. |
## Manifest example
```json
@ -53,6 +63,12 @@ Name | Type | Required? | Description
"screenshots": [{
"src": "path/to/image.png",
"label": "image description"
}]
}],
"icons": {
"16": "path/to/icon16.png",
"32": "path/to/icon32.png",
"48": "path/to/icon48.png",
"128": "path/to/icon128.png"
}
}
```