1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-27 20:29:45 +02:00

Compare commits

...

26 Commits

Author SHA1 Message Date
Laurent Cozic
a658ef1008 clean up 2020-11-13 17:05:02 +00:00
Laurent Cozic
8fed8fbc1c clean up 2020-11-13 16:03:41 +00:00
Laurent Cozic
9a76fc8193 clean up 2020-11-13 11:06:01 +00:00
Laurent Cozic
2bf143aec4 save and load 2020-11-13 01:00:38 +00:00
Laurent Cozic
79bd4d7b0e Merge branch 'dev' into custom_layout 2020-11-12 19:45:21 +00:00
Laurent Cozic
3118602501 apply eslint 2020-11-12 19:40:17 +00:00
Laurent Cozic
8c710206de Merge branch 'dev' into custom_layout 2020-11-12 19:07:00 +00:00
Laurent Cozic
484ea8c0fb serialize 2020-11-12 18:23:41 +00:00
Laurent Cozic
06d072e435 invisible items 2020-11-12 18:02:34 +00:00
Laurent Cozic
9e3ca8c84e tests 2020-11-12 17:46:12 +00:00
Laurent Cozic
33e94853a2 ui 2020-11-12 16:36:42 +00:00
Laurent Cozic
388ace3444 check if item can be moved 2020-11-12 14:15:38 +00:00
Laurent Cozic
4b36f415ec Fix item size logic 2020-11-12 13:28:00 +00:00
Laurent Cozic
1217ac435c resize 2020-11-12 12:56:17 +00:00
Laurent Cozic
860d927886 resize handle 2020-11-12 12:38:35 +00:00
Laurent Cozic
14d9691309 resize rules 2020-11-11 18:18:19 +00:00
Laurent Cozic
89a2697756 Simplified app layout to make it easier to customize 2020-11-11 18:05:39 +00:00
Laurent Cozic
fbf06c230c Simplified app layout to make it easier to customize 2020-11-11 15:43:57 +00:00
Laurent Cozic
b56b050ec8 Merge branch 'dev' into custom_layout 2020-11-11 14:35:11 +00:00
Laurent Cozic
6bb970ddba UI 2020-11-11 10:14:41 +00:00
Laurent Cozic
95f3dc4e40 vertical move 2020-11-10 17:37:23 +00:00
Laurent Cozic
1c2c3d6631 Move items out of containers 2020-11-10 17:19:18 +00:00
Laurent Cozic
c0a305207e Move tests next to tested unit 2020-11-10 16:11:11 +00:00
Laurent Cozic
071bf6e1a3 Merge branch 'dev' into custom_layout 2020-11-10 16:03:49 +00:00
Laurent Cozic
51f0b35d5a Allow moving item left and right 2020-11-09 22:41:46 +00:00
Laurent Cozic
f74b23b176 Fixed layout logic and added unit tests 2020-11-09 16:59:25 +00:00
222 changed files with 7967 additions and 1810 deletions

View File

@@ -433,6 +433,9 @@ packages/app-desktop/gui/MainScreen/commands/showSpellCheckerMenu.js.map
packages/app-desktop/gui/MainScreen/commands/toggleEditors.d.ts packages/app-desktop/gui/MainScreen/commands/toggleEditors.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleEditors.js packages/app-desktop/gui/MainScreen/commands/toggleEditors.js
packages/app-desktop/gui/MainScreen/commands/toggleEditors.js.map packages/app-desktop/gui/MainScreen/commands/toggleEditors.js.map
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.js
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.js.map
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.d.ts packages/app-desktop/gui/MainScreen/commands/toggleNoteList.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js.map packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js.map
@@ -580,6 +583,9 @@ packages/app-desktop/gui/NoteListControls/commands/focusSearch.js.map
packages/app-desktop/gui/NoteListItem.d.ts packages/app-desktop/gui/NoteListItem.d.ts
packages/app-desktop/gui/NoteListItem.js packages/app-desktop/gui/NoteListItem.js
packages/app-desktop/gui/NoteListItem.js.map packages/app-desktop/gui/NoteListItem.js.map
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.d.ts
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.js
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.js.map
packages/app-desktop/gui/NoteTextViewer.d.ts packages/app-desktop/gui/NoteTextViewer.d.ts
packages/app-desktop/gui/NoteTextViewer.js packages/app-desktop/gui/NoteTextViewer.js
packages/app-desktop/gui/NoteTextViewer.js.map packages/app-desktop/gui/NoteTextViewer.js.map
@@ -589,15 +595,60 @@ packages/app-desktop/gui/NoteToolbar/NoteToolbar.js.map
packages/app-desktop/gui/OneDriveLoginScreen.d.ts packages/app-desktop/gui/OneDriveLoginScreen.d.ts
packages/app-desktop/gui/OneDriveLoginScreen.js packages/app-desktop/gui/OneDriveLoginScreen.js
packages/app-desktop/gui/OneDriveLoginScreen.js.map packages/app-desktop/gui/OneDriveLoginScreen.js.map
packages/app-desktop/gui/ResizableLayout/MoveButtons.d.ts
packages/app-desktop/gui/ResizableLayout/MoveButtons.js
packages/app-desktop/gui/ResizableLayout/MoveButtons.js.map
packages/app-desktop/gui/ResizableLayout/ResizableLayout.d.ts packages/app-desktop/gui/ResizableLayout/ResizableLayout.d.ts
packages/app-desktop/gui/ResizableLayout/ResizableLayout.js packages/app-desktop/gui/ResizableLayout/ResizableLayout.js
packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.d.ts packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.d.ts
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js.map packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js.map
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.d.ts packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.d.ts
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js.map packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js.map
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.d.ts
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.js
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.js.map
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.d.ts
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.js
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.js.map
packages/app-desktop/gui/ResizableLayout/utils/movements.d.ts
packages/app-desktop/gui/ResizableLayout/utils/movements.js
packages/app-desktop/gui/ResizableLayout/utils/movements.js.map
packages/app-desktop/gui/ResizableLayout/utils/movements.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/movements.test.js
packages/app-desktop/gui/ResizableLayout/utils/movements.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/persist.d.ts
packages/app-desktop/gui/ResizableLayout/utils/persist.js
packages/app-desktop/gui/ResizableLayout/utils/persist.js.map
packages/app-desktop/gui/ResizableLayout/utils/persist.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/persist.test.js
packages/app-desktop/gui/ResizableLayout/utils/persist.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/removeItem.d.ts
packages/app-desktop/gui/ResizableLayout/utils/removeItem.js
packages/app-desktop/gui/ResizableLayout/utils/removeItem.js.map
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.d.ts
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.js
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.js.map
packages/app-desktop/gui/ResizableLayout/utils/style.d.ts
packages/app-desktop/gui/ResizableLayout/utils/style.js
packages/app-desktop/gui/ResizableLayout/utils/style.js.map
packages/app-desktop/gui/ResizableLayout/utils/types.d.ts
packages/app-desktop/gui/ResizableLayout/utils/types.js
packages/app-desktop/gui/ResizableLayout/utils/types.js.map
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.js
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.js.map
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.js
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.js
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.js.map
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.d.ts
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.js
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.js.map
packages/app-desktop/gui/ResourceScreen.d.ts packages/app-desktop/gui/ResourceScreen.d.ts
packages/app-desktop/gui/ResourceScreen.js packages/app-desktop/gui/ResourceScreen.js
packages/app-desktop/gui/ResourceScreen.js.map packages/app-desktop/gui/ResourceScreen.js.map
@@ -676,6 +727,9 @@ packages/app-desktop/plugins/GotoAnything.js.map
packages/app-desktop/services/bridge.d.ts packages/app-desktop/services/bridge.d.ts
packages/app-desktop/services/bridge.js packages/app-desktop/services/bridge.js
packages/app-desktop/services/bridge.js.map packages/app-desktop/services/bridge.js.map
packages/app-desktop/services/commands/stateToWhenClauseContext.d.ts
packages/app-desktop/services/commands/stateToWhenClauseContext.js
packages/app-desktop/services/commands/stateToWhenClauseContext.js.map
packages/app-desktop/services/commands/types.d.ts packages/app-desktop/services/commands/types.d.ts
packages/app-desktop/services/commands/types.js packages/app-desktop/services/commands/types.js
packages/app-desktop/services/commands/types.js.map packages/app-desktop/services/commands/types.js.map
@@ -1144,9 +1198,6 @@ packages/lib/services/rest/utils/requestFields.js.map
packages/lib/services/rest/utils/requestPaginationOptions.d.ts packages/lib/services/rest/utils/requestPaginationOptions.d.ts
packages/lib/services/rest/utils/requestPaginationOptions.js packages/lib/services/rest/utils/requestPaginationOptions.js
packages/lib/services/rest/utils/requestPaginationOptions.js.map packages/lib/services/rest/utils/requestPaginationOptions.js.map
packages/lib/services/rest/utils/types.d.ts
packages/lib/services/rest/utils/types.js
packages/lib/services/rest/utils/types.js.map
packages/lib/services/searchengine/filterParser.d.ts packages/lib/services/searchengine/filterParser.d.ts
packages/lib/services/searchengine/filterParser.js packages/lib/services/searchengine/filterParser.js
packages/lib/services/searchengine/filterParser.js.map packages/lib/services/searchengine/filterParser.js.map

View File

@@ -25,6 +25,9 @@ module.exports = {
'afterEach': 'readonly', 'afterEach': 'readonly',
'jasmine': 'readonly', 'jasmine': 'readonly',
// Jest variables
'test': 'readonly',
// React Native variables // React Native variables
'__DEV__': 'readonly', '__DEV__': 'readonly',

69
.gitignore vendored
View File

@@ -425,6 +425,9 @@ packages/app-desktop/gui/MainScreen/commands/showSpellCheckerMenu.js.map
packages/app-desktop/gui/MainScreen/commands/toggleEditors.d.ts packages/app-desktop/gui/MainScreen/commands/toggleEditors.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleEditors.js packages/app-desktop/gui/MainScreen/commands/toggleEditors.js
packages/app-desktop/gui/MainScreen/commands/toggleEditors.js.map packages/app-desktop/gui/MainScreen/commands/toggleEditors.js.map
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.js
packages/app-desktop/gui/MainScreen/commands/toggleLayoutMoveMode.js.map
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.d.ts packages/app-desktop/gui/MainScreen/commands/toggleNoteList.d.ts
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js
packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js.map packages/app-desktop/gui/MainScreen/commands/toggleNoteList.js.map
@@ -572,6 +575,9 @@ packages/app-desktop/gui/NoteListControls/commands/focusSearch.js.map
packages/app-desktop/gui/NoteListItem.d.ts packages/app-desktop/gui/NoteListItem.d.ts
packages/app-desktop/gui/NoteListItem.js packages/app-desktop/gui/NoteListItem.js
packages/app-desktop/gui/NoteListItem.js.map packages/app-desktop/gui/NoteListItem.js.map
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.d.ts
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.js
packages/app-desktop/gui/NoteListWrapper/NoteListWrapper.js.map
packages/app-desktop/gui/NoteTextViewer.d.ts packages/app-desktop/gui/NoteTextViewer.d.ts
packages/app-desktop/gui/NoteTextViewer.js packages/app-desktop/gui/NoteTextViewer.js
packages/app-desktop/gui/NoteTextViewer.js.map packages/app-desktop/gui/NoteTextViewer.js.map
@@ -581,15 +587,60 @@ packages/app-desktop/gui/NoteToolbar/NoteToolbar.js.map
packages/app-desktop/gui/OneDriveLoginScreen.d.ts packages/app-desktop/gui/OneDriveLoginScreen.d.ts
packages/app-desktop/gui/OneDriveLoginScreen.js packages/app-desktop/gui/OneDriveLoginScreen.js
packages/app-desktop/gui/OneDriveLoginScreen.js.map packages/app-desktop/gui/OneDriveLoginScreen.js.map
packages/app-desktop/gui/ResizableLayout/MoveButtons.d.ts
packages/app-desktop/gui/ResizableLayout/MoveButtons.js
packages/app-desktop/gui/ResizableLayout/MoveButtons.js.map
packages/app-desktop/gui/ResizableLayout/ResizableLayout.d.ts packages/app-desktop/gui/ResizableLayout/ResizableLayout.d.ts
packages/app-desktop/gui/ResizableLayout/ResizableLayout.js packages/app-desktop/gui/ResizableLayout/ResizableLayout.js
packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.d.ts packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.d.ts
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js
packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js.map packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js.map
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.d.ts packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.d.ts
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js
packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js.map packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js.map
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.d.ts
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.js
packages/app-desktop/gui/ResizableLayout/utils/iterateItems.js.map
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.d.ts
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.js
packages/app-desktop/gui/ResizableLayout/utils/layoutItemProp.js.map
packages/app-desktop/gui/ResizableLayout/utils/movements.d.ts
packages/app-desktop/gui/ResizableLayout/utils/movements.js
packages/app-desktop/gui/ResizableLayout/utils/movements.js.map
packages/app-desktop/gui/ResizableLayout/utils/movements.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/movements.test.js
packages/app-desktop/gui/ResizableLayout/utils/movements.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/persist.d.ts
packages/app-desktop/gui/ResizableLayout/utils/persist.js
packages/app-desktop/gui/ResizableLayout/utils/persist.js.map
packages/app-desktop/gui/ResizableLayout/utils/persist.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/persist.test.js
packages/app-desktop/gui/ResizableLayout/utils/persist.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/removeItem.d.ts
packages/app-desktop/gui/ResizableLayout/utils/removeItem.js
packages/app-desktop/gui/ResizableLayout/utils/removeItem.js.map
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.d.ts
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.js
packages/app-desktop/gui/ResizableLayout/utils/setLayoutItemProps.js.map
packages/app-desktop/gui/ResizableLayout/utils/style.d.ts
packages/app-desktop/gui/ResizableLayout/utils/style.js
packages/app-desktop/gui/ResizableLayout/utils/style.js.map
packages/app-desktop/gui/ResizableLayout/utils/types.d.ts
packages/app-desktop/gui/ResizableLayout/utils/types.js
packages/app-desktop/gui/ResizableLayout/utils/types.js.map
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.js
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.js.map
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.js
packages/app-desktop/gui/ResizableLayout/utils/useLayoutItemSizes.test.js.map
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.d.ts
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.js
packages/app-desktop/gui/ResizableLayout/utils/useWindowResizeEvent.js.map
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.d.ts
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.js
packages/app-desktop/gui/ResizableLayout/utils/validateLayout.js.map
packages/app-desktop/gui/ResourceScreen.d.ts packages/app-desktop/gui/ResourceScreen.d.ts
packages/app-desktop/gui/ResourceScreen.js packages/app-desktop/gui/ResourceScreen.js
packages/app-desktop/gui/ResourceScreen.js.map packages/app-desktop/gui/ResourceScreen.js.map
@@ -668,6 +719,9 @@ packages/app-desktop/plugins/GotoAnything.js.map
packages/app-desktop/services/bridge.d.ts packages/app-desktop/services/bridge.d.ts
packages/app-desktop/services/bridge.js packages/app-desktop/services/bridge.js
packages/app-desktop/services/bridge.js.map packages/app-desktop/services/bridge.js.map
packages/app-desktop/services/commands/stateToWhenClauseContext.d.ts
packages/app-desktop/services/commands/stateToWhenClauseContext.js
packages/app-desktop/services/commands/stateToWhenClauseContext.js.map
packages/app-desktop/services/commands/types.d.ts packages/app-desktop/services/commands/types.d.ts
packages/app-desktop/services/commands/types.js packages/app-desktop/services/commands/types.js
packages/app-desktop/services/commands/types.js.map packages/app-desktop/services/commands/types.js.map
@@ -1136,9 +1190,6 @@ packages/lib/services/rest/utils/requestFields.js.map
packages/lib/services/rest/utils/requestPaginationOptions.d.ts packages/lib/services/rest/utils/requestPaginationOptions.d.ts
packages/lib/services/rest/utils/requestPaginationOptions.js packages/lib/services/rest/utils/requestPaginationOptions.js
packages/lib/services/rest/utils/requestPaginationOptions.js.map packages/lib/services/rest/utils/requestPaginationOptions.js.map
packages/lib/services/rest/utils/types.d.ts
packages/lib/services/rest/utils/types.js
packages/lib/services/rest/utils/types.js.map
packages/lib/services/searchengine/filterParser.d.ts packages/lib/services/searchengine/filterParser.d.ts
packages/lib/services/searchengine/filterParser.js packages/lib/services/searchengine/filterParser.js
packages/lib/services/searchengine/filterParser.js.map packages/lib/services/searchengine/filterParser.js.map

View File

@@ -8,6 +8,7 @@
"files.exclude": { "files.exclude": {
"lerna-debug.log": true, "lerna-debug.log": true,
"_mydocs/mdtest/": true, "_mydocs/mdtest/": true,
"./packages/lib/plugin_types": true,
"_releases/": true, "_releases/": true,
"_vieux/": true, "_vieux/": true,
".gitignore": true, ".gitignore": true,

View File

@@ -14,7 +14,6 @@
"buildWebsite": "npm run buildApiDoc && node ./packages/tools/build-website.js && npm run buildPluginDoc", "buildWebsite": "npm run buildApiDoc && node ./packages/tools/build-website.js && npm run buildPluginDoc",
"clean": "lerna clean -y && lerna run clean", "clean": "lerna clean -y && lerna run clean",
"generateDatabaseTypes": "node packages/tools/generate-database-types", "generateDatabaseTypes": "node packages/tools/generate-database-types",
"generatePluginTypes": "rm -rf ./plugin_types && node node_modules/typescript/bin/tsc --declaration --declarationDir ./plugin_types --project tsconfig.json",
"linkChecker": "linkchecker https://joplinapp.org", "linkChecker": "linkchecker https://joplinapp.org",
"linter-ci": "./node_modules/.bin/eslint --resolve-plugins-relative-to . --quiet --ext .js --ext .jsx --ext .ts --ext .tsx", "linter-ci": "./node_modules/.bin/eslint --resolve-plugins-relative-to . --quiet --ext .js --ext .jsx --ext .ts --ext .tsx",
"linter-precommit": "./node_modules/.bin/eslint --resolve-plugins-relative-to . --fix --ext .js --ext .jsx --ext .ts --ext .tsx", "linter-precommit": "./node_modules/.bin/eslint --resolve-plugins-relative-to . --fix --ext .js --ext .jsx --ext .ts --ext .tsx",

View File

@@ -1,6 +1,7 @@
import MenuUtils from '@joplin/lib/services/commands/MenuUtils'; import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
import ToolbarButtonUtils from '@joplin/lib/services/commands/ToolbarButtonUtils'; import ToolbarButtonUtils from '@joplin/lib/services/commands/ToolbarButtonUtils';
import CommandService, { CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; import CommandService, { CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
import stateToWhenClauseContext from '@joplin/lib/services/commands/stateToWhenClauseContext';
import KeymapService from '@joplin/lib/services/KeymapService'; import KeymapService from '@joplin/lib/services/KeymapService';
const { asyncTest, setupDatabaseAndSynchronizer, switchClient, expectThrow, expectNotThrow } = require('./test-utils.js'); const { asyncTest, setupDatabaseAndSynchronizer, switchClient, expectThrow, expectNotThrow } = require('./test-utils.js');
@@ -17,7 +18,7 @@ function newService(): CommandService {
return {}; return {};
}, },
}; };
service.initialize(mockStore, true); service.initialize(mockStore, true, stateToWhenClauseContext);
return service; return service;
} }

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -6,7 +6,7 @@ export interface Command {
/** /**
* Name of command - must be globally unique * Name of command - must be globally unique
*/ */
name: string name: string;
/** /**
* Label to be displayed on menu items or keyboard shortcut editor for example. * Label to be displayed on menu items or keyboard shortcut editor for example.
@@ -14,17 +14,17 @@ export interface Command {
* In that case the command will not appear in the shortcut editor or command panel, and logically * In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item. * should not be used as a menu item.
*/ */
label?: string label?: string;
/** /**
* Icon to be used on toolbar buttons for example * Icon to be used on toolbar buttons for example
*/ */
iconName?: string, iconName?: string;
/** /**
* Code to be ran when the command is executed. It may return a result. * Code to be ran when the command is executed. It may return a result.
*/ */
execute(...args:any[]):Promise<any | void> execute(...args: any[]): Promise<any | void>;
/** /**
* Defines whether the command should be enabled or disabled, which in turns affects * Defines whether the command should be enabled or disabled, which in turns affects
@@ -40,13 +40,11 @@ export interface Command {
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder" * And | && | "oneNoteSelected && !inConflictFolder"
* *
* Currently the supported context variables aren't documented, but you can find the list there: * Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts
* *
* Note: Commands are enabled by default unless you use this property. * Note: Commands are enabled by default unless you use this property.
*/ */
enabledCondition?: string enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -64,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -74,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -188,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -196,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -214,22 +212,22 @@ export interface MenuItem {
* Command that should be associated with the menu item. All menu item should * Command that should be associated with the menu item. All menu item should
* have a command associated with them unless they are a sub-menu. * have a command associated with them unless they are a sub-menu.
*/ */
commandName?: string, commandName?: string;
/** /**
* Accelerator associated with the menu item * Accelerator associated with the menu item
*/ */
accelerator?: string, accelerator?: string;
/** /**
* Menu items that should appear below this menu item. Allows creating a menu tree. * Menu items that should appear below this menu item. Allows creating a menu tree.
*/ */
submenu?: MenuItem[], submenu?: MenuItem[];
/** /**
* Menu item label. If not specified, the command label will be used instead. * Menu item label. If not specified, the command label will be used instead.
*/ */
label?: string, label?: string;
} }
// ================================================================= // =================================================================
@@ -237,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -279,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -322,36 +320,30 @@ export type Path = string[];
export enum ContentScriptType { export enum ContentScriptType {
/** /**
* Registers a new Markdown-It plugin, which should follow this template: * Registers a new Markdown-It plugin, which should follow the template below.
* *
* ```javascript * ```javascript
* // The module should export an object as below:
*
* module.exports = { * module.exports = {
*
* // The "context" variable is currently unused but could be used later on to provide
* // access to your own plugin so that the content script and plugin can communicate.
* default: function(context) { * default: function(context) {
* return { * return {
*
* // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information
* // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which
* // contains a number of options, mostly useful for Joplin's internal code.
* plugin: function(markdownIt, options) { * plugin: function(markdownIt, options) {
* // ... * // ...
* }, * },
* * assets: {
* // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. * // ...
* // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to * },
* // see how the data should be structured.
* assets: {},
* } * }
* } * }
* } * }
* ``` * ```
* *
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you * - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
* would simply create a file such as this: *
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
* *
* ```javascript * ```javascript
* module.exports = { * module.exports = {

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -6,7 +6,7 @@ export interface Command {
/** /**
* Name of command - must be globally unique * Name of command - must be globally unique
*/ */
name: string name: string;
/** /**
* Label to be displayed on menu items or keyboard shortcut editor for example. * Label to be displayed on menu items or keyboard shortcut editor for example.
@@ -14,17 +14,17 @@ export interface Command {
* In that case the command will not appear in the shortcut editor or command panel, and logically * In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item. * should not be used as a menu item.
*/ */
label?: string label?: string;
/** /**
* Icon to be used on toolbar buttons for example * Icon to be used on toolbar buttons for example
*/ */
iconName?: string, iconName?: string;
/** /**
* Code to be ran when the command is executed. It may return a result. * Code to be ran when the command is executed. It may return a result.
*/ */
execute(...args:any[]):Promise<any | void> execute(...args: any[]): Promise<any | void>;
/** /**
* Defines whether the command should be enabled or disabled, which in turns affects * Defines whether the command should be enabled or disabled, which in turns affects
@@ -40,13 +40,11 @@ export interface Command {
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder" * And | && | "oneNoteSelected && !inConflictFolder"
* *
* Currently the supported context variables aren't documented, but you can find the list there: * Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts
* *
* Note: Commands are enabled by default unless you use this property. * Note: Commands are enabled by default unless you use this property.
*/ */
enabledCondition?: string enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -64,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -74,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -188,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -196,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -214,22 +212,22 @@ export interface MenuItem {
* Command that should be associated with the menu item. All menu item should * Command that should be associated with the menu item. All menu item should
* have a command associated with them unless they are a sub-menu. * have a command associated with them unless they are a sub-menu.
*/ */
commandName?: string, commandName?: string;
/** /**
* Accelerator associated with the menu item * Accelerator associated with the menu item
*/ */
accelerator?: string, accelerator?: string;
/** /**
* Menu items that should appear below this menu item. Allows creating a menu tree. * Menu items that should appear below this menu item. Allows creating a menu tree.
*/ */
submenu?: MenuItem[], submenu?: MenuItem[];
/** /**
* Menu item label. If not specified, the command label will be used instead. * Menu item label. If not specified, the command label will be used instead.
*/ */
label?: string, label?: string;
} }
// ================================================================= // =================================================================
@@ -237,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -279,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -322,36 +320,30 @@ export type Path = string[];
export enum ContentScriptType { export enum ContentScriptType {
/** /**
* Registers a new Markdown-It plugin, which should follow this template: * Registers a new Markdown-It plugin, which should follow the template below.
* *
* ```javascript * ```javascript
* // The module should export an object as below:
*
* module.exports = { * module.exports = {
*
* // The "context" variable is currently unused but could be used later on to provide
* // access to your own plugin so that the content script and plugin can communicate.
* default: function(context) { * default: function(context) {
* return { * return {
*
* // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information
* // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which
* // contains a number of options, mostly useful for Joplin's internal code.
* plugin: function(markdownIt, options) { * plugin: function(markdownIt, options) {
* // ... * // ...
* }, * },
* * assets: {
* // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. * // ...
* // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to * },
* // see how the data should be structured.
* assets: {},
* } * }
* } * }
* } * }
* ``` * ```
* *
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you * - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
* would simply create a file such as this: *
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
* *
* ```javascript * ```javascript
* module.exports = { * module.exports = {

View File

@@ -4,12 +4,12 @@ joplin.plugins.register({
onStart: async function() { onStart: async function() {
const dialogs = joplin.views.dialogs; const dialogs = joplin.views.dialogs;
const handle = await dialogs.create(); const handle = await dialogs.create('myDialog1');
await dialogs.setHtml(handle, '<p>Testing dialog with default buttons</p><p>Second line</p><p>Third line</p>'); await dialogs.setHtml(handle, '<p>Testing dialog with default buttons</p><p>Second line</p><p>Third line</p>');
const result = await dialogs.open(handle); const result = await dialogs.open(handle);
alert('This button was clicked: ' + result); alert('This button was clicked: ' + result);
const handle2 = await dialogs.create(); const handle2 = await dialogs.create('myDialog2');
await dialogs.setHtml(handle2, '<p>Testing dialog with custom buttons</p><p>Second line</p><p>Third line</p>'); await dialogs.setHtml(handle2, '<p>Testing dialog with custom buttons</p><p>Second line</p><p>Third line</p>');
await dialogs.setButtons(handle2, [ await dialogs.setButtons(handle2, [
{ {

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -6,7 +6,7 @@ export interface Command {
/** /**
* Name of command - must be globally unique * Name of command - must be globally unique
*/ */
name: string name: string;
/** /**
* Label to be displayed on menu items or keyboard shortcut editor for example. * Label to be displayed on menu items or keyboard shortcut editor for example.
@@ -14,17 +14,17 @@ export interface Command {
* In that case the command will not appear in the shortcut editor or command panel, and logically * In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item. * should not be used as a menu item.
*/ */
label?: string label?: string;
/** /**
* Icon to be used on toolbar buttons for example * Icon to be used on toolbar buttons for example
*/ */
iconName?: string, iconName?: string;
/** /**
* Code to be ran when the command is executed. It may return a result. * Code to be ran when the command is executed. It may return a result.
*/ */
execute(...args:any[]):Promise<any | void> execute(...args: any[]): Promise<any | void>;
/** /**
* Defines whether the command should be enabled or disabled, which in turns affects * Defines whether the command should be enabled or disabled, which in turns affects
@@ -40,13 +40,11 @@ export interface Command {
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder" * And | && | "oneNoteSelected && !inConflictFolder"
* *
* Currently the supported context variables aren't documented, but you can find the list there: * Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts
* *
* Note: Commands are enabled by default unless you use this property. * Note: Commands are enabled by default unless you use this property.
*/ */
enabledCondition?: string enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -64,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -74,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -188,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -196,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -214,22 +212,22 @@ export interface MenuItem {
* Command that should be associated with the menu item. All menu item should * Command that should be associated with the menu item. All menu item should
* have a command associated with them unless they are a sub-menu. * have a command associated with them unless they are a sub-menu.
*/ */
commandName?: string, commandName?: string;
/** /**
* Accelerator associated with the menu item * Accelerator associated with the menu item
*/ */
accelerator?: string, accelerator?: string;
/** /**
* Menu items that should appear below this menu item. Allows creating a menu tree. * Menu items that should appear below this menu item. Allows creating a menu tree.
*/ */
submenu?: MenuItem[], submenu?: MenuItem[];
/** /**
* Menu item label. If not specified, the command label will be used instead. * Menu item label. If not specified, the command label will be used instead.
*/ */
label?: string, label?: string;
} }
// ================================================================= // =================================================================
@@ -237,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -279,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -322,36 +320,30 @@ export type Path = string[];
export enum ContentScriptType { export enum ContentScriptType {
/** /**
* Registers a new Markdown-It plugin, which should follow this template: * Registers a new Markdown-It plugin, which should follow the template below.
* *
* ```javascript * ```javascript
* // The module should export an object as below:
*
* module.exports = { * module.exports = {
*
* // The "context" variable is currently unused but could be used later on to provide
* // access to your own plugin so that the content script and plugin can communicate.
* default: function(context) { * default: function(context) {
* return { * return {
*
* // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information
* // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which
* // contains a number of options, mostly useful for Joplin's internal code.
* plugin: function(markdownIt, options) { * plugin: function(markdownIt, options) {
* // ... * // ...
* }, * },
* * assets: {
* // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. * // ...
* // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to * },
* // see how the data should be structured.
* assets: {},
* } * }
* } * }
* } * }
* ``` * ```
* *
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you * - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
* would simply create a file such as this: *
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
* *
* ```javascript * ```javascript
* module.exports = { * module.exports = {

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -6,7 +6,7 @@ export interface Command {
/** /**
* Name of command - must be globally unique * Name of command - must be globally unique
*/ */
name: string name: string;
/** /**
* Label to be displayed on menu items or keyboard shortcut editor for example. * Label to be displayed on menu items or keyboard shortcut editor for example.
@@ -14,17 +14,17 @@ export interface Command {
* In that case the command will not appear in the shortcut editor or command panel, and logically * In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item. * should not be used as a menu item.
*/ */
label?: string label?: string;
/** /**
* Icon to be used on toolbar buttons for example * Icon to be used on toolbar buttons for example
*/ */
iconName?: string, iconName?: string;
/** /**
* Code to be ran when the command is executed. It may return a result. * Code to be ran when the command is executed. It may return a result.
*/ */
execute(...args:any[]):Promise<any | void> execute(...args: any[]): Promise<any | void>;
/** /**
* Defines whether the command should be enabled or disabled, which in turns affects * Defines whether the command should be enabled or disabled, which in turns affects
@@ -40,13 +40,11 @@ export interface Command {
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder" * And | && | "oneNoteSelected && !inConflictFolder"
* *
* Currently the supported context variables aren't documented, but you can find the list there: * Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts
* *
* Note: Commands are enabled by default unless you use this property. * Note: Commands are enabled by default unless you use this property.
*/ */
enabledCondition?: string enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -64,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -74,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -188,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -196,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -214,22 +212,22 @@ export interface MenuItem {
* Command that should be associated with the menu item. All menu item should * Command that should be associated with the menu item. All menu item should
* have a command associated with them unless they are a sub-menu. * have a command associated with them unless they are a sub-menu.
*/ */
commandName?: string, commandName?: string;
/** /**
* Accelerator associated with the menu item * Accelerator associated with the menu item
*/ */
accelerator?: string, accelerator?: string;
/** /**
* Menu items that should appear below this menu item. Allows creating a menu tree. * Menu items that should appear below this menu item. Allows creating a menu tree.
*/ */
submenu?: MenuItem[], submenu?: MenuItem[];
/** /**
* Menu item label. If not specified, the command label will be used instead. * Menu item label. If not specified, the command label will be used instead.
*/ */
label?: string, label?: string;
} }
// ================================================================= // =================================================================
@@ -237,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -279,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -322,36 +320,30 @@ export type Path = string[];
export enum ContentScriptType { export enum ContentScriptType {
/** /**
* Registers a new Markdown-It plugin, which should follow this template: * Registers a new Markdown-It plugin, which should follow the template below.
* *
* ```javascript * ```javascript
* // The module should export an object as below:
*
* module.exports = { * module.exports = {
*
* // The "context" variable is currently unused but could be used later on to provide
* // access to your own plugin so that the content script and plugin can communicate.
* default: function(context) { * default: function(context) {
* return { * return {
*
* // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information
* // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which
* // contains a number of options, mostly useful for Joplin's internal code.
* plugin: function(markdownIt, options) { * plugin: function(markdownIt, options) {
* // ... * // ...
* }, * },
* * assets: {
* // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. * // ...
* // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to * },
* // see how the data should be structured.
* assets: {},
* } * }
* } * }
* } * }
* ``` * ```
* *
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you * - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
* would simply create a file such as this: *
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
* *
* ```javascript * ```javascript
* module.exports = { * module.exports = {

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:
@@ -27,10 +37,10 @@ export default class JoplinCommands {
* *
* // Create a new sub-notebook under the provided notebook * // Create a new sub-notebook under the provided notebook
* // Note: internally, notebooks are called "folders". * // Note: internally, notebooks are called "folders".
* await joplin.commands.execute('newFolder', { parent_id: "SOME_FOLDER_ID" }); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, props?: any): Promise<any>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
*/ */
@@ -21,4 +21,18 @@ export default class JoplinPlugins {
* ``` * ```
*/ */
register(script: Script): Promise<void>; register(script: Script): Promise<void>;
/**
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
*
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
*
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
*
* @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script.
* @param scriptPath Must be a path relative to the plugin main script. For example, if your file content_script.js is next to your index.ts file, you would set `scriptPath` to `"./content_script.js`.
*/
registerContentScript(type: ContentScriptType, id: string, scriptPath: string): Promise<void>;
} }

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -3,12 +3,48 @@
// ================================================================= // =================================================================
export interface Command { export interface Command {
name: string /**
label: string * Name of command - must be globally unique
iconName?: string, */
execute(props:any):Promise<any> name: string;
isEnabled?(props:any):boolean
mapStateToProps?(state:any):any /**
* Label to be displayed on menu items or keyboard shortcut editor for example.
* If it is missing, it's assumed it's a private command, to be called programmatically only.
* In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item.
*/
label?: string;
/**
* Icon to be used on toolbar buttons for example
*/
iconName?: string;
/**
* Code to be ran when the command is executed. It may return a result.
*/
execute(...args: any[]): Promise<any | void>;
/**
* Defines whether the command should be enabled or disabled, which in turns affects
* the enabled state of any associated button or menu item.
*
* The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to
* `true` or `false`. It supports the following operators:
*
* Operator | Symbol | Example
* -- | -- | --
* Equality | == | "editorType == markdown"
* Inequality | != | "currentScreen != config"
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder"
*
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* Note: Commands are enabled by default unless you use this property.
*/
enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -26,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -36,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -150,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -158,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -172,10 +208,26 @@ export enum MenuItemLocation {
} }
export interface MenuItem { export interface MenuItem {
commandName?: string, /**
accelerator?: string, * Command that should be associated with the menu item. All menu item should
submenu?: MenuItem[], * have a command associated with them unless they are a sub-menu.
label?: string, */
commandName?: string;
/**
* Accelerator associated with the menu item
*/
accelerator?: string;
/**
* Menu items that should appear below this menu item. Allows creating a menu tree.
*/
submenu?: MenuItem[];
/**
* Menu item label. If not specified, the command label will be used instead.
*/
label?: string;
} }
// ================================================================= // =================================================================
@@ -183,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -225,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -261,3 +313,48 @@ export interface SettingSection {
* [2]: (Optional) Resource link. * [2]: (Optional) Resource link.
*/ */
export type Path = string[]; export type Path = string[];
// =================================================================
// Plugins type
// =================================================================
export enum ContentScriptType {
/**
* Registers a new Markdown-It plugin, which should follow the template below.
*
* ```javascript
* module.exports = {
* default: function(context) {
* return {
* plugin: function(markdownIt, options) {
* // ...
* },
* assets: {
* // ...
* },
* }
* }
* }
* ```
*
* - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
*
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
*
* ```javascript
* module.exports = {
* default: function(context) {
* return {
* plugin: require('markdown-it-toc-done-right');
* }
* }
* }
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
CodeMirrorPlugin = 'codeMirrorPlugin',
}

View File

@@ -2,7 +2,7 @@ import joplin from 'api';
joplin.plugins.register({ joplin.plugins.register({
onStart: async function() { onStart: async function() {
await joplin.views.menus.create('My Menu', [ await joplin.views.menus.create('myMenu', 'My Menu', [
{ {
commandName: "newNote", commandName: "newNote",
}, },

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing menu items. * Allows creating and managing menu items.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsMenuItems { export default class JoplinViewsMenuItems {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsMenuItems {
/** /**
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter. * Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
*/ */
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
} }

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating menus. * Allows creating menus.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/menu) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
*/ */
export default class JoplinViewsMenus { export default class JoplinViewsMenus {
private store; private store;
@@ -14,5 +14,5 @@ export default class JoplinViewsMenus {
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the * Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
* menu as a sub-menu of the application build-in menus. * menu as a sub-menu of the application build-in menus.
*/ */
create(label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>; create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
} }

View File

@@ -1,10 +1,13 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ViewHandle } from './types'; import { ViewHandle } from './types';
/** /**
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example * Allows creating and managing view panels. View panels currently are
* it could be used to display a table of content for the active note, or display various metadata or graph. * displayed at the right of the sidebar and allows displaying any HTML
* content (within a webview) and update it in real-time. For example it
* could be used to display a table of content for the active note, or
* display various metadata or graph.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/toc) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/toc)
*/ */
export default class JoplinViewsPanels { export default class JoplinViewsPanels {
private store; private store;
@@ -14,7 +17,7 @@ export default class JoplinViewsPanels {
/** /**
* Creates a new panel * Creates a new panel
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Sets the panel webview HTML * Sets the panel webview HTML
*/ */

View File

@@ -3,7 +3,7 @@ import Plugin from '../Plugin';
/** /**
* Allows creating and managing toolbar buttons. * Allows creating and managing toolbar buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
*/ */
export default class JoplinViewsToolbarButtons { export default class JoplinViewsToolbarButtons {
private store; private store;
@@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons {
/** /**
* Creates a new toolbar button and associate it with the given command. * Creates a new toolbar button and associate it with the given command.
*/ */
create(commandName: string, location: ToolbarButtonLocation): Promise<void>; create(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
} }

View File

@@ -2,7 +2,7 @@
* 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 well * 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 well
* as various related events, such as when a new note is selected, or when the note content changes. * as various related events, such as when a new note is selected, or when the note content changes.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
*/ */
export default class JoplinWorkspace { export default class JoplinWorkspace {
private store; private store;

View File

@@ -6,7 +6,7 @@ export interface Command {
/** /**
* Name of command - must be globally unique * Name of command - must be globally unique
*/ */
name: string name: string;
/** /**
* Label to be displayed on menu items or keyboard shortcut editor for example. * Label to be displayed on menu items or keyboard shortcut editor for example.
@@ -14,17 +14,17 @@ export interface Command {
* In that case the command will not appear in the shortcut editor or command panel, and logically * In that case the command will not appear in the shortcut editor or command panel, and logically
* should not be used as a menu item. * should not be used as a menu item.
*/ */
label?: string label?: string;
/** /**
* Icon to be used on toolbar buttons for example * Icon to be used on toolbar buttons for example
*/ */
iconName?: string, iconName?: string;
/** /**
* Code to be ran when the command is executed. It may return a result. * Code to be ran when the command is executed. It may return a result.
*/ */
execute(...args:any[]):Promise<any | void> execute(...args: any[]): Promise<any | void>;
/** /**
* Defines whether the command should be enabled or disabled, which in turns affects * Defines whether the command should be enabled or disabled, which in turns affects
@@ -40,13 +40,11 @@ export interface Command {
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
* And | && | "oneNoteSelected && !inConflictFolder" * And | && | "oneNoteSelected && !inConflictFolder"
* *
* Currently the supported context variables aren't documented, but you can find the list there: * Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
*
* https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts
* *
* Note: Commands are enabled by default unless you use this property. * Note: Commands are enabled by default unless you use this property.
*/ */
enabledCondition?: string enabledCondition?: string;
} }
// ================================================================= // =================================================================
@@ -64,7 +62,7 @@ export enum ImportModuleOutputFormat {
} }
/** /**
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) for an example. * Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export) for an example.
* *
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported. * In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
* *
@@ -74,113 +72,113 @@ export interface ExportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter. * Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
*/ */
target: FileSystemItem, target: FileSystemItem;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module. * The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Called when the export process starts. * Called when the export process starts.
*/ */
onInit(context:ExportContext): Promise<void>; onInit(context: ExportContext): Promise<void>;
/** /**
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc. * Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
*/ */
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>; onProcessItem(context: ExportContext, itemType: number, item: any): Promise<void>;
/** /**
* Called when a resource file needs to be exported. * Called when a resource file needs to be exported.
*/ */
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>; onProcessResource(context: ExportContext, resource: any, filePath: string): Promise<void>;
/** /**
* Called when the export process is done. * Called when the export process is done.
*/ */
onClose(context:ExportContext):Promise<void>; onClose(context: ExportContext): Promise<void>;
} }
export interface ImportModule { export interface ImportModule {
/** /**
* The format to be exported, eg "enex", "jex", "json", etc. * The format to be exported, eg "enex", "jex", "json", etc.
*/ */
format: string, format: string;
/** /**
* The description that will appear in the UI, for example in the menu item. * The description that will appear in the UI, for example in the menu item.
*/ */
description: string, description: string;
/** /**
* Only applies to single file exporters or importers * Only applies to single file exporters or importers
* It tells whether the format can package multiple notes into one file. * It tells whether the format can package multiple notes into one file.
* For example JEX or ENEX can, but HTML cannot. * For example JEX or ENEX can, but HTML cannot.
*/ */
isNoteArchive: boolean, isNoteArchive: boolean;
/** /**
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both. * The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
*/ */
sources: FileSystemItem[], sources: FileSystemItem[];
/** /**
* Tells the file extensions of the exported files. * Tells the file extensions of the exported files.
*/ */
fileExtensions?: string[], fileExtensions?: string[];
/** /**
* Tells the type of notes that will be generated, either HTML or Markdown (default). * Tells the type of notes that will be generated, either HTML or Markdown (default).
*/ */
outputFormat?: ImportModuleOutputFormat, outputFormat?: ImportModuleOutputFormat;
/** /**
* Called when the import process starts. There is only one event handler within which you should import the complete data. * Called when the import process starts. There is only one event handler within which you should import the complete data.
*/ */
onExec(context:ImportContext): Promise<void>; onExec(context: ImportContext): Promise<void>;
} }
export interface ExportOptions { export interface ExportOptions {
format?: string, format?: string;
path?:string, path?: string;
sourceFolderIds?: string[], sourceFolderIds?: string[];
sourceNoteIds?: string[], sourceNoteIds?: string[];
modulePath?:string, modulePath?: string;
target?:FileSystemItem, target?: FileSystemItem;
} }
export interface ExportContext { export interface ExportContext {
destPath: string, destPath: string;
options: ExportOptions, options: ExportOptions;
/** /**
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next. * You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
*/ */
userData?: any, userData?: any;
} }
export interface ImportContext { export interface ImportContext {
sourcePath: string, sourcePath: string;
options: any, options: any;
warnings: string[], warnings: string[];
} }
// ================================================================= // =================================================================
@@ -188,7 +186,7 @@ export interface ImportContext {
// ================================================================= // =================================================================
export interface Script { export interface Script {
onStart?(event:any):Promise<void>, onStart?(event: any): Promise<void>;
} }
// ================================================================= // =================================================================
@@ -196,7 +194,7 @@ export interface Script {
// ================================================================= // =================================================================
export interface CreateMenuItemOptions { export interface CreateMenuItemOptions {
accelerator: string, accelerator: string;
} }
export enum MenuItemLocation { export enum MenuItemLocation {
@@ -214,22 +212,22 @@ export interface MenuItem {
* Command that should be associated with the menu item. All menu item should * Command that should be associated with the menu item. All menu item should
* have a command associated with them unless they are a sub-menu. * have a command associated with them unless they are a sub-menu.
*/ */
commandName?: string, commandName?: string;
/** /**
* Accelerator associated with the menu item * Accelerator associated with the menu item
*/ */
accelerator?: string, accelerator?: string;
/** /**
* Menu items that should appear below this menu item. Allows creating a menu tree. * Menu items that should appear below this menu item. Allows creating a menu tree.
*/ */
submenu?: MenuItem[], submenu?: MenuItem[];
/** /**
* Menu item label. If not specified, the command label will be used instead. * Menu item label. If not specified, the command label will be used instead.
*/ */
label?: string, label?: string;
} }
// ================================================================= // =================================================================
@@ -237,9 +235,9 @@ export interface MenuItem {
// ================================================================= // =================================================================
export interface ButtonSpec { export interface ButtonSpec {
id: ButtonId, id: ButtonId;
title?: string, title?: string;
onClick?():void, onClick?(): void;
} }
export type ButtonId = string; export type ButtonId = string;
@@ -279,28 +277,28 @@ export enum SettingItemType {
// Redefine a simplified interface to mask internal details // Redefine a simplified interface to mask internal details
// and to remove function calls as they would have to be async. // and to remove function calls as they would have to be async.
export interface SettingItem { export interface SettingItem {
value: any, value: any;
type: SettingItemType, type: SettingItemType;
public: boolean, public: boolean;
label:string, label: string;
description?:string, description?: string;
isEnum?: boolean, isEnum?: boolean;
section?: string, section?: string;
options?:any, options?: any;
appTypes?:string[], appTypes?: string[];
secure?: boolean, secure?: boolean;
advanced?: boolean, advanced?: boolean;
minimum?: number, minimum?: number;
maximum?: number, maximum?: number;
step?: number, step?: number;
} }
export interface SettingSection { export interface SettingSection {
label: string, label: string;
iconName?: string, iconName?: string;
description?: string, description?: string;
name?: string, name?: string;
} }
// ================================================================= // =================================================================
@@ -322,36 +320,30 @@ export type Path = string[];
export enum ContentScriptType { export enum ContentScriptType {
/** /**
* Registers a new Markdown-It plugin, which should follow this template: * Registers a new Markdown-It plugin, which should follow the template below.
* *
* ```javascript * ```javascript
* // The module should export an object as below:
*
* module.exports = { * module.exports = {
*
* // The "context" variable is currently unused but could be used later on to provide
* // access to your own plugin so that the content script and plugin can communicate.
* default: function(context) { * default: function(context) {
* return { * return {
*
* // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information
* // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which
* // contains a number of options, mostly useful for Joplin's internal code.
* plugin: function(markdownIt, options) { * plugin: function(markdownIt, options) {
* // ... * // ...
* }, * },
* * assets: {
* // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. * // ...
* // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to * },
* // see how the data should be structured.
* assets: {},
* } * }
* } * }
* } * }
* ``` * ```
* *
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you * - The `context` argument is currently unused but could be used later on to provide access to your own plugin so that the content script and plugin can communicate.
* would simply create a file such as this: *
* - The **required** `plugin` key is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information. The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
*
* - Using the **optional** `assets` key you may specify assets such as JS or CSS that should be loaded in the rendered HTML document. Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
*
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
* *
* ```javascript * ```javascript
* module.exports = { * module.exports = {

View File

@@ -1,6 +1,6 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Joplin from './Joplin'; import Joplin from './Joplin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* @ignore * @ignore
*/ */

View File

@@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews'; import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop'; import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings'; import JoplinSettings from './JoplinSettings';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
/** /**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors. * This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*/ */

View File

@@ -1,25 +1,35 @@
import { Command } from './types'; import { Command } from './types';
/** /**
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with * This class allows executing or registering new Joplin commands. Commands
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. * can be executed or associated with
* {@link JoplinViewsToolbarButtons | toolbar buttons} or
* {@link JoplinViewsMenuItems | menu items}.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/register_command) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/register_command)
* *
* ## Executing Joplin's internal commands * ## Executing Joplin's internal commands
* *
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented. * It is also possible to execute internal Joplin's commands which, as of
* You can find the list directly on GitHub though at the following locations: * now, are not well documented. You can find the list directly on GitHub
* though at the following locations:
* *
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts)
* *
* To view what arguments are supported, you can open any of these files and look at the `execute()` command. * To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given command. * <span class="platform-desktop">desktop</span> Executes the given
* The `props` are the arguments passed to the command, and they vary based on the command * command.
*
* The command can take any number of arguments, and the supported
* arguments will vary based on the command. For custom commands, this
* is the `args` passed to the `execute()` function. For built-in
* commands, you can find the supported arguments by checking the links
* above.
* *
* ```typescript * ```typescript
* // Create a new note in the current notebook: * // Create a new note in the current notebook:

View File

@@ -6,7 +6,7 @@ import { Path } from './types';
* *
* This is also what you would use to search notes, via the `search` endpoint. * This is also what you would use to search notes, via the `search` endpoint.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/simple) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/simple)
* *
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls. * In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
* And each method takes these parameters: * And each method takes these parameters:

View File

@@ -2,7 +2,7 @@ import { ExportModule, ImportModule } from './types';
/** /**
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format. * Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/json_export) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/json_export)
* *
* To implement an import or export module, you would simply define an object with various event handlers that are called * To implement an import or export module, you would simply define an object with various event handlers that are called
* by the application during the import/export process. * by the application during the import/export process.

View File

@@ -1,5 +1,5 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import Logger from 'lib/Logger'; import Logger from '../../../Logger';
import { ContentScriptType, Script } from './types'; import { ContentScriptType, Script } from './types';
/** /**
* This class provides access to plugin-related features. * This class provides access to plugin-related features.
@@ -28,7 +28,7 @@ export default class JoplinPlugins {
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
* *
* @param type Defines how the script will be used. See the type definition for more information about each supported type. * @param type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@@ -7,7 +7,7 @@ import { SettingItem, SettingSection } from './types';
* *
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results * Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/settings) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/settings)
*/ */
export default class JoplinSettings { export default class JoplinSettings {
private plugin_; private plugin_;
@@ -37,7 +37,7 @@ export default class JoplinSettings {
* *
* The list of available settings is not documented yet, but can be found by looking at the source code: * The list of available settings is not documented yet, but can be found by looking at the source code:
* *
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/ReactNativeClient/lib/models/Setting.ts#L142 * https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
*/ */
globalValue(key: string): Promise<any>; globalValue(key: string): Promise<any>;
} }

View File

@@ -5,7 +5,7 @@ import { ButtonSpec, ViewHandle, ButtonId } from './types';
* Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was * Dialogs are hidden by default and you need to call `open()` to open them. Once the user clicks on a button, the `open` call will return and provide the button ID that was
* clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons. * clicked on. There is currently no "close" method since the dialog should be thought as a modal one and thus can only be closed by clicking on one of the buttons.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/dialog) * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/ */
export default class JoplinViewsDialogs { export default class JoplinViewsDialogs {
private store; private store;
@@ -16,7 +16,7 @@ export default class JoplinViewsDialogs {
/** /**
* Creates a new dialog * Creates a new dialog
*/ */
create(): Promise<ViewHandle>; create(id: string): Promise<ViewHandle>;
/** /**
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel" * Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
*/ */

Some files were not shown because too many files have changed in this diff Show More