mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
This commit is contained in:
parent
034e568d26
commit
03617eb8a7
@ -1071,6 +1071,7 @@ packages/lib/services/plugins/utils/getPluginIssueReportUrl.js
|
||||
packages/lib/services/plugins/utils/getPluginNamespacedSettingKey.js
|
||||
packages/lib/services/plugins/utils/getPluginSettingKeyPrefix.js
|
||||
packages/lib/services/plugins/utils/getPluginSettingValue.js
|
||||
packages/lib/services/plugins/utils/isCompatible/getDefaultPlatforms.js
|
||||
packages/lib/services/plugins/utils/isCompatible/index.test.js
|
||||
packages/lib/services/plugins/utils/isCompatible/index.js
|
||||
packages/lib/services/plugins/utils/isCompatible/minVersionForPlatform.js
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1051,6 +1051,7 @@ packages/lib/services/plugins/utils/getPluginIssueReportUrl.js
|
||||
packages/lib/services/plugins/utils/getPluginNamespacedSettingKey.js
|
||||
packages/lib/services/plugins/utils/getPluginSettingKeyPrefix.js
|
||||
packages/lib/services/plugins/utils/getPluginSettingValue.js
|
||||
packages/lib/services/plugins/utils/isCompatible/getDefaultPlatforms.js
|
||||
packages/lib/services/plugins/utils/isCompatible/index.test.js
|
||||
packages/lib/services/plugins/utils/isCompatible/index.js
|
||||
packages/lib/services/plugins/utils/isCompatible/minVersionForPlatform.js
|
||||
|
@ -283,10 +283,11 @@ describe('services_PluginService', () => {
|
||||
shouldRun: true,
|
||||
},
|
||||
{
|
||||
// Should default to desktop-only
|
||||
manifestPlatforms: [],
|
||||
isDesktop: false,
|
||||
appVersion: '3.0.8',
|
||||
shouldRun: true,
|
||||
shouldRun: false,
|
||||
},
|
||||
])('should enable and disable plugins depending on what platform(s) they support (case %#: %j)', async ({ manifestPlatforms, isDesktop, appVersion, shouldRun }) => {
|
||||
const pluginScript = `
|
||||
|
@ -0,0 +1,43 @@
|
||||
|
||||
// Although `platforms: ['desktop', 'mobile']` is required to support both mobile
|
||||
// and desktop, no plugin authors have done this as of 04/25/2024. As such, we include
|
||||
// a list of plugins that have "platforms" default to ['desktop', 'mobile'] rather
|
||||
// than just ['desktop'].
|
||||
// cSpell:disable
|
||||
const defaultSupportMobile = [
|
||||
'com.github.joplin.kanban',
|
||||
'com.hieuthi.joplin.function-plot',
|
||||
'com.hieuthi.joplin.markdown-table-colorize',
|
||||
'com.joplin.copy.codeBlocks',
|
||||
'com.whatever.inline-tags',
|
||||
'com.whatever.quick-links',
|
||||
'cx.evermeet.tessus.menu-shortcut-toolbar',
|
||||
'io.github.personalizedrefrigerator.codemirror6-settings',
|
||||
'io.github.personalizedrefrigerator.revealjs-integration',
|
||||
'io.treymo.LinkGraph',
|
||||
'jl15988.JoplinAlertsPerfectPlugin',
|
||||
'jl15988.JoplinCodePerfectPlugin',
|
||||
'joplin.plugin.alondmnt.history-panel',
|
||||
'joplin.plugin.ambrt.backlinksToNote',
|
||||
'joplin.plugin.ambrt.embedSearch',
|
||||
'joplin.plugin.note.tabs',
|
||||
'joplin.plugin.spoiler.cards',
|
||||
'net.cwesson.joplin-plugin-typograms',
|
||||
'org.joplinapp.plugins.AbcSheetMusic',
|
||||
'org.joplinapp.plugins.admonition',
|
||||
'org.joplinapp.plugins.joplin-calendar',
|
||||
'outline',
|
||||
'plugin.calebjohn.MathMode',
|
||||
'plugin.calebjohn.rich-markdown',
|
||||
];
|
||||
// cSpell:enable
|
||||
|
||||
const getDefaultPluginPlatforms = (id: string) => {
|
||||
if (defaultSupportMobile.includes(id)) {
|
||||
return ['desktop', 'mobile'];
|
||||
} else {
|
||||
return ['desktop'];
|
||||
}
|
||||
};
|
||||
|
||||
export default getDefaultPluginPlatforms;
|
@ -8,7 +8,7 @@ describe('isCompatible', () => {
|
||||
manifest: { app_min_version: '2.0' },
|
||||
appVersion: '2.1.0',
|
||||
shouldSupportDesktop: true,
|
||||
shouldSupportMobile: true,
|
||||
shouldSupportMobile: false,
|
||||
},
|
||||
{
|
||||
manifest: { app_min_version: '2.0' },
|
||||
@ -20,7 +20,7 @@ describe('isCompatible', () => {
|
||||
manifest: { app_min_version: '3.0.2' },
|
||||
appVersion: '3.0.2',
|
||||
shouldSupportDesktop: true,
|
||||
shouldSupportMobile: true,
|
||||
shouldSupportMobile: false,
|
||||
},
|
||||
|
||||
// Should support the case where only one platform is provided, with no version
|
||||
@ -83,9 +83,13 @@ describe('isCompatible', () => {
|
||||
shouldSupportMobile: true,
|
||||
},
|
||||
])('should correctly return whether a plugin is compatible with a given version of Joplin (case %#: %j)', ({ manifest, appVersion, shouldSupportDesktop, shouldSupportMobile }) => {
|
||||
const mobileCompatible = isCompatible(appVersion, AppType.Mobile, manifest);
|
||||
const fullManifest = {
|
||||
id: 'com.example.id',
|
||||
...manifest,
|
||||
};
|
||||
const mobileCompatible = isCompatible(appVersion, AppType.Mobile, fullManifest);
|
||||
expect(mobileCompatible).toBe(shouldSupportMobile);
|
||||
const desktopCompatible = isCompatible(appVersion, AppType.Desktop, manifest);
|
||||
const desktopCompatible = isCompatible(appVersion, AppType.Desktop, fullManifest);
|
||||
expect(desktopCompatible).toBe(shouldSupportDesktop);
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,15 @@
|
||||
import { AppType } from '../../../../models/Setting';
|
||||
import getDefaultPlatforms from './getDefaultPlatforms';
|
||||
import { ManifestSlice } from './types';
|
||||
|
||||
// Returns false if the platform isn't supported at all,
|
||||
const minVersionForPlatform = (appPlatform: AppType, manifest: ManifestSlice): string|false => {
|
||||
const platforms = manifest.platforms ?? [];
|
||||
// If platforms is not specified (or empty), default to supporting all platforms.
|
||||
let platforms = manifest.platforms;
|
||||
|
||||
if (!platforms || platforms.length === 0) {
|
||||
platforms = getDefaultPlatforms(manifest.id);
|
||||
}
|
||||
|
||||
const supported = platforms.length === 0 || platforms.includes(appPlatform);
|
||||
if (!supported) {
|
||||
return false;
|
||||
|
@ -1,3 +1,3 @@
|
||||
import { PluginManifest } from '../types';
|
||||
|
||||
export type ManifestSlice = Pick<PluginManifest, 'app_min_version'|'app_min_version_mobile'|'platforms'>;
|
||||
export type ManifestSlice = Pick<PluginManifest, 'id'|'app_min_version'|'app_min_version_mobile'|'platforms'>;
|
||||
|
@ -22,7 +22,7 @@ Name | Type | Required? | Description
|
||||
|
||||
## Platforms
|
||||
|
||||
A list that can contain `"desktop"` and/or `"mobile"`.
|
||||
A list that can contain `"desktop"` and/or `"mobile"`. If not given, it defaults to `[ "desktop" ]` for most plugins.
|
||||
|
||||
## Categories
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user