You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Desktop: Allow customising application layout
This commit is contained in:
		| @@ -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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| packages/lib/services/searchengine/filterParser.js.map | ||||
|   | ||||
| @@ -25,6 +25,9 @@ module.exports = { | ||||
| 		'afterEach': 'readonly', | ||||
| 		'jasmine': 'readonly', | ||||
|  | ||||
| 		// Jest variables | ||||
| 		'test': 'readonly', | ||||
|  | ||||
| 		// React Native variables | ||||
| 		'__DEV__': 'readonly', | ||||
|  | ||||
|   | ||||
							
								
								
									
										69
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										69
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| packages/app-desktop/gui/ResizableLayout/ResizableLayout.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useLayoutItemSizes.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js | ||||
| packages/app-desktop/gui/ResizableLayout/hooks/useWindowResizeEvent.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js | ||||
| packages/app-desktop/gui/ResizableLayout/utils/findItemByKey.js.map | ||||
| packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.d.ts | ||||
| packages/app-desktop/gui/ResizableLayout/utils/isTempContainer.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| 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.js | ||||
| packages/lib/services/searchengine/filterParser.js.map | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
| 		"files.exclude": { | ||||
| 			"lerna-debug.log": true, | ||||
| 			"_mydocs/mdtest/": true, | ||||
| 			"./packages/lib/plugin_types": true, | ||||
| 			"_releases/": true, | ||||
| 			"_vieux/": true, | ||||
| 			".gitignore": true, | ||||
|   | ||||
| @@ -14,7 +14,6 @@ | ||||
|     "buildWebsite": "npm run buildApiDoc && node ./packages/tools/build-website.js && npm run buildPluginDoc", | ||||
|     "clean": "lerna clean -y && lerna run clean", | ||||
|     "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", | ||||
|     "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", | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import MenuUtils from '@joplin/lib/services/commands/MenuUtils'; | ||||
| import ToolbarButtonUtils from '@joplin/lib/services/commands/ToolbarButtonUtils'; | ||||
| import CommandService, { CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService'; | ||||
| import stateToWhenClauseContext from '@joplin/lib/services/commands/stateToWhenClauseContext'; | ||||
| import KeymapService from '@joplin/lib/services/KeymapService'; | ||||
|  | ||||
| const { asyncTest, setupDatabaseAndSynchronizer, switchClient, expectThrow, expectNotThrow } = require('./test-utils.js'); | ||||
| @@ -17,7 +18,7 @@ function newService(): CommandService { | ||||
| 			return {}; | ||||
| 		}, | ||||
| 	}; | ||||
| 	service.initialize(mockStore, true); | ||||
| 	service.initialize(mockStore, true, stateToWhenClauseContext); | ||||
| 	return service; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ export interface Command { | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * should not be used as a menu item. | ||||
| 	 */ | ||||
| 	label?: string | ||||
| 	label?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 | ||||
| @@ -40,13 +40,11 @@ export interface Command { | ||||
| 	 * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" | ||||
| 	 * And | && | "oneNoteSelected && !inConflictFolder" | ||||
| 	 * | ||||
| 	 * Currently the supported context variables aren't documented, but you can find the list there: | ||||
| 	 * | ||||
| 	 * https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts | ||||
| 	 * 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 | ||||
| 	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. | ||||
|  * | ||||
| @@ -74,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -188,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -196,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -214,22 +212,22 @@ export interface MenuItem { | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	commandName?: string, | ||||
| 	commandName?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Accelerator associated with the menu item | ||||
| 	 */ | ||||
| 	accelerator?: string, | ||||
| 	accelerator?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	label?: string, | ||||
| 	label?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -237,9 +235,9 @@ export interface MenuItem { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface ButtonSpec { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -279,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -322,36 +320,30 @@ export type Path = string[]; | ||||
|  | ||||
| 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 | ||||
| 	 * // The module should export an object as below: | ||||
| 	 * | ||||
| 	 * 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) { | ||||
| 	 *         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) { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 * | ||||
| 	 *             // 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: {}, | ||||
| 	 *             assets: { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 *         } | ||||
| 	 *     } | ||||
| 	 * } | ||||
| 	 * ``` | ||||
| 	 * | ||||
| 	 * To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you | ||||
| 	 * would simply create a file such as this: | ||||
| 	 * - 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 = { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ export interface Command { | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * should not be used as a menu item. | ||||
| 	 */ | ||||
| 	label?: string | ||||
| 	label?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 | ||||
| @@ -40,13 +40,11 @@ export interface Command { | ||||
| 	 * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" | ||||
| 	 * And | && | "oneNoteSelected && !inConflictFolder" | ||||
| 	 * | ||||
| 	 * Currently the supported context variables aren't documented, but you can find the list there: | ||||
| 	 * | ||||
| 	 * https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts | ||||
| 	 * 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 | ||||
| 	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. | ||||
|  * | ||||
| @@ -74,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -188,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -196,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -214,22 +212,22 @@ export interface MenuItem { | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	commandName?: string, | ||||
| 	commandName?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Accelerator associated with the menu item | ||||
| 	 */ | ||||
| 	accelerator?: string, | ||||
| 	accelerator?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	label?: string, | ||||
| 	label?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -237,9 +235,9 @@ export interface MenuItem { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface ButtonSpec { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -279,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -322,36 +320,30 @@ export type Path = string[]; | ||||
|  | ||||
| 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 | ||||
| 	 * // The module should export an object as below: | ||||
| 	 * | ||||
| 	 * 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) { | ||||
| 	 *         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) { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 * | ||||
| 	 *             // 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: {}, | ||||
| 	 *             assets: { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 *         } | ||||
| 	 *     } | ||||
| 	 * } | ||||
| 	 * ``` | ||||
| 	 * | ||||
| 	 * To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you | ||||
| 	 * would simply create a file such as this: | ||||
| 	 * - 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 = { | ||||
|   | ||||
| @@ -4,12 +4,12 @@ joplin.plugins.register({ | ||||
| 	onStart: async function() { | ||||
| 		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>'); | ||||
| 		const result = await dialogs.open(handle); | ||||
| 		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.setButtons(handle2, [ | ||||
| 			{ | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ export interface Command { | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * should not be used as a menu item. | ||||
| 	 */ | ||||
| 	label?: string | ||||
| 	label?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 | ||||
| @@ -40,13 +40,11 @@ export interface Command { | ||||
| 	 * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" | ||||
| 	 * And | && | "oneNoteSelected && !inConflictFolder" | ||||
| 	 * | ||||
| 	 * Currently the supported context variables aren't documented, but you can find the list there: | ||||
| 	 * | ||||
| 	 * https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts | ||||
| 	 * 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 | ||||
| 	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. | ||||
|  * | ||||
| @@ -74,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -188,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -196,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -214,22 +212,22 @@ export interface MenuItem { | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	commandName?: string, | ||||
| 	commandName?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Accelerator associated with the menu item | ||||
| 	 */ | ||||
| 	accelerator?: string, | ||||
| 	accelerator?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	label?: string, | ||||
| 	label?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -237,9 +235,9 @@ export interface MenuItem { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface ButtonSpec { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -279,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -322,36 +320,30 @@ export type Path = string[]; | ||||
|  | ||||
| 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 | ||||
| 	 * // The module should export an object as below: | ||||
| 	 * | ||||
| 	 * 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) { | ||||
| 	 *         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) { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 * | ||||
| 	 *             // 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: {}, | ||||
| 	 *             assets: { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 *         } | ||||
| 	 *     } | ||||
| 	 * } | ||||
| 	 * ``` | ||||
| 	 * | ||||
| 	 * To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you | ||||
| 	 * would simply create a file such as this: | ||||
| 	 * - 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 = { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ export interface Command { | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * should not be used as a menu item. | ||||
| 	 */ | ||||
| 	label?: string | ||||
| 	label?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 | ||||
| @@ -40,13 +40,11 @@ export interface Command { | ||||
| 	 * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" | ||||
| 	 * And | && | "oneNoteSelected && !inConflictFolder" | ||||
| 	 * | ||||
| 	 * Currently the supported context variables aren't documented, but you can find the list there: | ||||
| 	 * | ||||
| 	 * https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts | ||||
| 	 * 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 | ||||
| 	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. | ||||
|  * | ||||
| @@ -74,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -188,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -196,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -214,22 +212,22 @@ export interface MenuItem { | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	commandName?: string, | ||||
| 	commandName?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Accelerator associated with the menu item | ||||
| 	 */ | ||||
| 	accelerator?: string, | ||||
| 	accelerator?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	label?: string, | ||||
| 	label?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -237,9 +235,9 @@ export interface MenuItem { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface ButtonSpec { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -279,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -322,36 +320,30 @@ export type Path = string[]; | ||||
|  | ||||
| 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 | ||||
| 	 * // The module should export an object as below: | ||||
| 	 * | ||||
| 	 * 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) { | ||||
| 	 *         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) { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 * | ||||
| 	 *             // 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: {}, | ||||
| 	 *             assets: { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 *         } | ||||
| 	 *     } | ||||
| 	 * } | ||||
| 	 * ``` | ||||
| 	 * | ||||
| 	 * To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you | ||||
| 	 * would simply create a file such as this: | ||||
| 	 * - 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 = { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // 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 | ||||
|      * // 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. | ||||
|      * | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import { Script } from './types'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * This class provides access to plugin-related features. | ||||
|  */ | ||||
| @@ -21,4 +21,18 @@ export default class JoplinPlugins { | ||||
|      * ``` | ||||
|      */ | ||||
|     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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -3,12 +3,48 @@ | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Command { | ||||
| 	name: string | ||||
| 	label: string | ||||
| 	iconName?: string, | ||||
| 	execute(props:any):Promise<any> | ||||
| 	isEnabled?(props:any):boolean | ||||
| 	mapStateToProps?(state:any):any | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
|  * | ||||
| @@ -36,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -150,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -158,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -172,10 +208,26 @@ export enum MenuItemLocation { | ||||
| } | ||||
|  | ||||
| export interface MenuItem { | ||||
| 	commandName?: string, | ||||
| 	accelerator?: string, | ||||
| 	submenu?: MenuItem[], | ||||
| 	label?: string, | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -225,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -261,3 +313,48 @@ export interface SettingSection { | ||||
|  * [2]: (Optional) Resource link. | ||||
|  */ | ||||
| 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', | ||||
| } | ||||
|   | ||||
| @@ -2,7 +2,7 @@ import joplin from 'api'; | ||||
|  | ||||
| joplin.plugins.register({ | ||||
| 	onStart: async function() { | ||||
| 		await joplin.views.menus.create('My Menu', [ | ||||
| 		await joplin.views.menus.create('myMenu', 'My Menu', [ | ||||
| 			{ | ||||
| 				commandName: "newNote", | ||||
| 			}, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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. | ||||
|      */ | ||||
|     create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
|     create(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>; | ||||
| } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     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 | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -1,10 +1,13 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| 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 | ||||
|  * it could be used to display a table of content for the active note, or display various metadata or graph. | ||||
|  * 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 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 { | ||||
|     private store; | ||||
| @@ -14,7 +17,7 @@ export default class JoplinViewsPanels { | ||||
|     /** | ||||
|      * Creates a new panel | ||||
|      */ | ||||
|     create(): Promise<ViewHandle>; | ||||
|     create(id: string): Promise<ViewHandle>; | ||||
|     /** | ||||
|      * Sets the panel webview HTML | ||||
|      */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import Plugin from '../Plugin'; | ||||
| /** | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -12,5 +12,5 @@ export default class JoplinViewsToolbarButtons { | ||||
|     /** | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
|   | ||||
| @@ -6,7 +6,7 @@ export interface Command { | ||||
| 	/** | ||||
| 	 * Name of command - must be globally unique | ||||
| 	 */ | ||||
| 	name: string | ||||
| 	name: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 * should not be used as a menu item. | ||||
| 	 */ | ||||
| 	label?: string | ||||
| 	label?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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 | ||||
| @@ -40,13 +40,11 @@ export interface Command { | ||||
| 	 * Or | \|\| | "noteIsTodo \|\| noteTodoCompleted" | ||||
| 	 * And | && | "oneNoteSelected && !inConflictFolder" | ||||
| 	 * | ||||
| 	 * Currently the supported context variables aren't documented, but you can find the list there: | ||||
| 	 * | ||||
| 	 * https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/services/commands/stateToWhenClauseContext.ts | ||||
| 	 * 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 | ||||
| 	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. | ||||
|  * | ||||
| @@ -74,113 +72,113 @@ export interface ExportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	target: FileSystemItem, | ||||
| 	target: FileSystemItem; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	fileExtensions?: string[], | ||||
| 	fileExtensions?: string[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	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. | ||||
| 	 */ | ||||
| 	onClose(context:ExportContext):Promise<void>; | ||||
| 	onClose(context: ExportContext): Promise<void>; | ||||
| } | ||||
|  | ||||
| export interface ImportModule { | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	description: string, | ||||
| 	description: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Only applies to single file exporters or importers | ||||
| 	 * It tells whether the format can package multiple notes into one file. | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	sources: FileSystemItem[], | ||||
| 	sources: FileSystemItem[]; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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). | ||||
| 	 */ | ||||
| 	outputFormat?: ImportModuleOutputFormat, | ||||
| 	outputFormat?: ImportModuleOutputFormat; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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 { | ||||
| 	format?: string, | ||||
| 	path?:string, | ||||
| 	sourceFolderIds?: string[], | ||||
| 	sourceNoteIds?: string[], | ||||
| 	modulePath?:string, | ||||
| 	target?:FileSystemItem, | ||||
| 	format?: string; | ||||
| 	path?: string; | ||||
| 	sourceFolderIds?: string[]; | ||||
| 	sourceNoteIds?: string[]; | ||||
| 	modulePath?: string; | ||||
| 	target?: FileSystemItem; | ||||
| } | ||||
|  | ||||
| export interface ExportContext { | ||||
| 	destPath: string, | ||||
| 	options: ExportOptions, | ||||
| 	destPath: string; | ||||
| 	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. | ||||
| 	 */ | ||||
| 	userData?: any, | ||||
| 	userData?: any; | ||||
| } | ||||
|  | ||||
| export interface ImportContext { | ||||
| 	sourcePath: string, | ||||
| 	options: any, | ||||
| 	warnings: string[], | ||||
| 	sourcePath: string; | ||||
| 	options: any; | ||||
| 	warnings: string[]; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -188,7 +186,7 @@ export interface ImportContext { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface Script { | ||||
| 	onStart?(event:any):Promise<void>, | ||||
| 	onStart?(event: any): Promise<void>; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -196,7 +194,7 @@ export interface Script { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface CreateMenuItemOptions { | ||||
| 	accelerator: string, | ||||
| 	accelerator: string; | ||||
| } | ||||
|  | ||||
| export enum MenuItemLocation { | ||||
| @@ -214,22 +212,22 @@ export interface MenuItem { | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	commandName?: string, | ||||
| 	commandName?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * Accelerator associated with the menu item | ||||
| 	 */ | ||||
| 	accelerator?: string, | ||||
| 	accelerator?: string; | ||||
|  | ||||
| 	/** | ||||
| 	 * 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. | ||||
| 	 */ | ||||
| 	label?: string, | ||||
| 	label?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -237,9 +235,9 @@ export interface MenuItem { | ||||
| // ================================================================= | ||||
|  | ||||
| export interface ButtonSpec { | ||||
| 	id: ButtonId, | ||||
| 	title?: string, | ||||
| 	onClick?():void, | ||||
| 	id: ButtonId; | ||||
| 	title?: string; | ||||
| 	onClick?(): void; | ||||
| } | ||||
|  | ||||
| export type ButtonId = string; | ||||
| @@ -279,28 +277,28 @@ export enum SettingItemType { | ||||
| // Redefine a simplified interface to mask internal details | ||||
| // and to remove function calls as they would have to be async. | ||||
| export interface SettingItem { | ||||
| 	value: any, | ||||
| 	type: SettingItemType, | ||||
| 	public: boolean, | ||||
| 	label:string, | ||||
| 	value: any; | ||||
| 	type: SettingItemType; | ||||
| 	public: boolean; | ||||
| 	label: string; | ||||
|  | ||||
| 	description?:string, | ||||
| 	isEnum?: boolean, | ||||
| 	section?: string, | ||||
| 	options?:any, | ||||
| 	appTypes?:string[], | ||||
| 	secure?: boolean, | ||||
| 	advanced?: boolean, | ||||
| 	minimum?: number, | ||||
| 	maximum?: number, | ||||
| 	step?: number, | ||||
| 	description?: string; | ||||
| 	isEnum?: boolean; | ||||
| 	section?: string; | ||||
| 	options?: any; | ||||
| 	appTypes?: string[]; | ||||
| 	secure?: boolean; | ||||
| 	advanced?: boolean; | ||||
| 	minimum?: number; | ||||
| 	maximum?: number; | ||||
| 	step?: number; | ||||
| } | ||||
|  | ||||
| export interface SettingSection { | ||||
| 	label: string, | ||||
| 	iconName?: string, | ||||
| 	description?: string, | ||||
| 	name?: string, | ||||
| 	label: string; | ||||
| 	iconName?: string; | ||||
| 	description?: string; | ||||
| 	name?: string; | ||||
| } | ||||
|  | ||||
| // ================================================================= | ||||
| @@ -322,36 +320,30 @@ export type Path = string[]; | ||||
|  | ||||
| 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 | ||||
| 	 * // The module should export an object as below: | ||||
| 	 * | ||||
| 	 * 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) { | ||||
| 	 *         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) { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 * | ||||
| 	 *             // 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: {}, | ||||
| 	 *             assets: { | ||||
| 	 *                 // ... | ||||
| 	 *             }, | ||||
| 	 *         } | ||||
| 	 *     } | ||||
| 	 * } | ||||
| 	 * ``` | ||||
| 	 * | ||||
| 	 * To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific feature, you | ||||
| 	 * would simply create a file such as this: | ||||
| 	 * - 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 = { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Joplin from './Joplin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| /** | ||||
|  * @ignore | ||||
|  */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import JoplinCommands from './JoplinCommands'; | ||||
| import JoplinViews from './JoplinViews'; | ||||
| import JoplinInterop from './JoplinInterop'; | ||||
| 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. | ||||
|  */ | ||||
|   | ||||
| @@ -1,25 +1,35 @@ | ||||
| import { Command } from './types'; | ||||
| /** | ||||
|  * This class allows executing or registering new Joplin commands. Commands can be executed or associated with | ||||
|  * {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}. | ||||
|  * This class allows executing or registering new Joplin commands. Commands | ||||
|  * 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 | ||||
|  * | ||||
|  * It is also possible to execute internal Joplin's commands which, as of now, are not well documented. | ||||
|  * You can find the list directly on GitHub though at the following locations: | ||||
|  * It is also possible to execute internal Joplin's commands which, as of | ||||
|  * 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 | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands | ||||
|  * https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts | ||||
|  * * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands) | ||||
|  * * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands) | ||||
|  * * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/NoteEditor/commands/editorCommandDeclarations.ts) | ||||
|  * | ||||
|  * 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 { | ||||
|     /** | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given command. | ||||
|      * The `props` are the arguments passed to the command, and they vary based on the command | ||||
|      * <span class="platform-desktop">desktop</span> Executes the given | ||||
|      * 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 | ||||
|      * // Create a new note in the current notebook: | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import { Path } from './types'; | ||||
|  * | ||||
|  * 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. | ||||
|  * And each method takes these parameters: | ||||
|   | ||||
| @@ -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. | ||||
|  * | ||||
|  * [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 | ||||
|  * by the application during the import/export process. | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import Plugin from '../Plugin'; | ||||
| import Logger from 'lib/Logger'; | ||||
| import Logger from '../../../Logger'; | ||||
| import { ContentScriptType, Script } from './types'; | ||||
| /** | ||||
|  * 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 | ||||
|      * (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 id A unique ID for the content script. | ||||
|   | ||||
| @@ -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 | ||||
|  * | ||||
|  * [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 { | ||||
|     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: | ||||
|      * | ||||
|      * 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>; | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|  * 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 { | ||||
|     private store; | ||||
| @@ -16,7 +16,7 @@ export default class JoplinViewsDialogs { | ||||
|     /** | ||||
|      * 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" | ||||
|      */ | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user