Showing with 14,194 additions and 478 deletions.
  1. +8 −2 .eslintignore
  2. +1 −1 .eslintrc.js
  3. +8 −2 .gitignore
  4. +3 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/.gitignore
  5. +8 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/.npmignore
  6. +78 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/GENERATOR_DOC.md
  7. +5 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/README.md
  8. +14 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/Global.d.ts
  9. +74 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/Joplin.d.ts
  10. +23 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinClipboard.d.ts
  11. +89 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinCommands.d.ts
  12. +40 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinContentScripts.d.ts
  13. +73 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinData.d.ts
  14. +10 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinFilters.d.ts
  15. +61 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinImaging.d.ts
  16. +17 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinInterop.d.ts
  17. +43 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinPlugins.d.ts
  18. +63 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinSettings.d.ts
  19. +31 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViews.d.ts
  20. +74 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsDialogs.d.ts
  21. +16 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsMenuItems.d.ts
  22. +18 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsMenus.d.ts
  23. +24 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsNoteList.d.ts
  24. +78 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsPanels.d.ts
  25. +16 −0 ...ages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinViewsToolbarButtons.d.ts
  26. +24 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinWindow.d.ts
  27. +87 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/JoplinWorkspace.d.ts
  28. +5 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/index.ts
  29. +156 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/noteListType.d.ts
  30. +181 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/noteListType.ts
  31. +711 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/api/types.ts
  32. +10,184 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/package-lock.json
  33. +31 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/package.json
  34. +6 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/plugin.config.json
  35. +25 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/src/contentScripts/codeMirror5.ts
  36. +21 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/src/contentScripts/codeMirror6.ts
  37. +6 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/src/contentScripts/style.css
  38. +59 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/src/index.ts
  39. +15 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/src/manifest.json
  40. +10 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/tsconfig.json
  41. +398 −0 packages/app-cli/tests/support/plugins/codemirror5-and-codemirror6/webpack.config.js
  42. +37 −0 packages/app-cli/tests/support/plugins/codemirror6/api/types.ts
  43. +71 −3 packages/app-cli/tests/support/plugins/codemirror6/package-lock.json
  44. +2 −1 packages/app-cli/tests/support/plugins/codemirror6/package.json
  45. +41 −4 packages/app-cli/tests/support/plugins/codemirror6/src/contentScript.ts
  46. +12 −0 packages/app-cli/tests/support/plugins/codemirror6/src/index.ts
  47. +5 −1 packages/app-desktop/app.ts
  48. +42 −6 packages/app-desktop/bridge.ts
  49. +3 −3 packages/app-desktop/gui/MainScreen/commands/openItem.ts
  50. +2 −2 packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/useEditorCommands.ts
  51. +1 −0 packages/app-desktop/gui/NoteList/NoteList2.tsx
  52. +5 −1 packages/app-desktop/gui/NoteListItem/NoteListItem.tsx
  53. +1 −6 packages/app-desktop/gui/NoteRevisionViewer.tsx
  54. +2 −2 packages/app-desktop/gui/ResourceScreen.tsx
  55. +2 −2 packages/app-desktop/main.js
  56. +1 −1 packages/app-desktop/package.json
  57. +2 −2 packages/app-desktop/utils/restartInSafeModeFromMain.ts
  58. +2 −2 packages/app-mobile/android/app/build.gradle
  59. +2 −0 packages/app-mobile/components/note-item.js
  60. +8 −8 packages/app-mobile/ios/Joplin.xcodeproj/project.pbxproj
  61. +1 −1 packages/default-plugins/pluginRepositories.json
  62. +1 −14 packages/editor/CodeMirror/CodeMirrorControl.test.ts
  63. +21 −5 packages/editor/CodeMirror/CodeMirrorControl.ts
  64. +2 −2 packages/editor/CodeMirror/configFromSettings.ts
  65. +2 −0 packages/editor/CodeMirror/createEditor.test.ts
  66. +4 −8 .../editor/CodeMirror/markdown/{syntaxHighlightingLanguages.ts → codeBlockLanguages/allLanguages.ts}
  67. +18 −0 packages/editor/CodeMirror/markdown/codeBlockLanguages/defaultLanguage.ts
  68. +10 −0 packages/editor/CodeMirror/markdown/codeBlockLanguages/lookUpLanguage.ts
  69. +2 −2 packages/editor/CodeMirror/pluginApi/PluginLoader.ts
  70. +6 −0 packages/editor/CodeMirror/pluginApi/codeMirrorRequire.ts
  71. +87 −0 packages/editor/CodeMirror/pluginApi/customEditorCompletion.test.ts
  72. +63 −0 packages/editor/CodeMirror/pluginApi/customEditorCompletion.ts
  73. +16 −0 packages/editor/CodeMirror/testUtil/createEditorControl.ts
  74. +1 −3 packages/editor/CodeMirror/testUtil/loadLanguages.ts
  75. +16 −0 packages/editor/CodeMirror/testUtil/typeText.ts
  76. +3 −2 packages/lib/BaseApplication.ts
  77. +23 −0 packages/lib/determineBaseAppDirs.ts
  78. +0 −16 packages/lib/determineProfileDir.ts
  79. +2 −0 packages/lib/models/Setting.ts
  80. +1 −1 packages/lib/services/ExternalEditWatcher/utils.ts
  81. +1 −1 packages/lib/services/plugins/PluginService.ts
  82. +37 −0 packages/lib/services/plugins/api/types.ts
  83. +2 −1 packages/lib/services/plugins/defaultPlugins/desktopDefaultPluginsInfo.ts
  84. +46 −1 packages/tools/postPreReleasesToForum.json
  85. +103 −18 packages/tools/postPreReleasesToForum.ts
  86. +19 −1 packages/utils/path.test.ts
  87. +7 −0 packages/utils/path.ts
  88. +5 −0 readme/about/changelog/android.md
  89. +10 −0 readme/about/changelog/desktop.md
  90. +5 −0 readme/about/changelog/ios.md
  91. +640 −0 readme/api/tutorials/cm6_plugin.md
  92. +3 −0 readme/api/tutorials/toc_plugin.md
  93. +0 −160 readme/dev/gsoc/gsoc2024/ideas.md
  94. +2 −162 readme/dev/gsoc/gsoc2024/index.md
  95. +0 −31 readme/dev/gsoc/gsoc2024/pull_request_guidelines.md
10 changes: 8 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ packages/editor/CodeMirror/editorCommands/insertLineAfter.js
packages/editor/CodeMirror/editorCommands/supportsCommand.js
packages/editor/CodeMirror/editorCommands/swapLine.js
packages/editor/CodeMirror/getScrollFraction.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/allLanguages.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/defaultLanguage.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/lookUpLanguage.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.test.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.js
packages/editor/CodeMirror/markdown/decoratorExtension.test.js
Expand All @@ -600,13 +603,16 @@ packages/editor/CodeMirror/markdown/markdownMathParser.test.js
packages/editor/CodeMirror/markdown/markdownMathParser.js
packages/editor/CodeMirror/markdown/markdownReformatter.test.js
packages/editor/CodeMirror/markdown/markdownReformatter.js
packages/editor/CodeMirror/markdown/syntaxHighlightingLanguages.js
packages/editor/CodeMirror/pluginApi/PluginLoader.js
packages/editor/CodeMirror/pluginApi/codeMirrorRequire.js
packages/editor/CodeMirror/pluginApi/customEditorCompletion.test.js
packages/editor/CodeMirror/pluginApi/customEditorCompletion.js
packages/editor/CodeMirror/testUtil/createEditorControl.js
packages/editor/CodeMirror/testUtil/createEditorSettings.js
packages/editor/CodeMirror/testUtil/createTestEditor.js
packages/editor/CodeMirror/testUtil/forceFullParse.js
packages/editor/CodeMirror/testUtil/loadLanguages.js
packages/editor/CodeMirror/testUtil/typeText.js
packages/editor/CodeMirror/theme.js
packages/editor/CodeMirror/util/isInSyntaxNode.js
packages/editor/CodeMirror/util/setupVim.js
Expand Down Expand Up @@ -679,7 +685,7 @@ packages/lib/components/shared/side-menu-shared.js
packages/lib/database-driver-better-sqlite.js
packages/lib/database.js
packages/lib/debug/DebugService.js
packages/lib/determineProfileDir.js
packages/lib/determineBaseAppDirs.js
packages/lib/dom.js
packages/lib/errorUtils.js
packages/lib/errors.js
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module.exports = {
selector: 'enumMember',
format: null,
'filter': {
'regex': '^(GET|POST|PUT|DELETE|PATCH|HEAD|SQLite|PostgreSQL|ASC|DESC|E2EE|OR|AND|UNION|INTERSECT|EXCLUSION|INCLUSION|EUR|GBP|USD|SJCL.*)$',
'regex': '^(GET|POST|PUT|DELETE|PATCH|HEAD|SQLite|PostgreSQL|ASC|DESC|E2EE|OR|AND|UNION|INTERSECT|EXCLUSION|INCLUSION|EUR|GBP|USD|SJCL.*|iOS)$',
'match': true,
},
},
Expand Down
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ packages/editor/CodeMirror/editorCommands/insertLineAfter.js
packages/editor/CodeMirror/editorCommands/supportsCommand.js
packages/editor/CodeMirror/editorCommands/swapLine.js
packages/editor/CodeMirror/getScrollFraction.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/allLanguages.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/defaultLanguage.js
packages/editor/CodeMirror/markdown/codeBlockLanguages/lookUpLanguage.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.test.js
packages/editor/CodeMirror/markdown/computeSelectionFormatting.js
packages/editor/CodeMirror/markdown/decoratorExtension.test.js
Expand All @@ -580,13 +583,16 @@ packages/editor/CodeMirror/markdown/markdownMathParser.test.js
packages/editor/CodeMirror/markdown/markdownMathParser.js
packages/editor/CodeMirror/markdown/markdownReformatter.test.js
packages/editor/CodeMirror/markdown/markdownReformatter.js
packages/editor/CodeMirror/markdown/syntaxHighlightingLanguages.js
packages/editor/CodeMirror/pluginApi/PluginLoader.js
packages/editor/CodeMirror/pluginApi/codeMirrorRequire.js
packages/editor/CodeMirror/pluginApi/customEditorCompletion.test.js
packages/editor/CodeMirror/pluginApi/customEditorCompletion.js
packages/editor/CodeMirror/testUtil/createEditorControl.js
packages/editor/CodeMirror/testUtil/createEditorSettings.js
packages/editor/CodeMirror/testUtil/createTestEditor.js
packages/editor/CodeMirror/testUtil/forceFullParse.js
packages/editor/CodeMirror/testUtil/loadLanguages.js
packages/editor/CodeMirror/testUtil/typeText.js
packages/editor/CodeMirror/theme.js
packages/editor/CodeMirror/util/isInSyntaxNode.js
packages/editor/CodeMirror/util/setupVim.js
Expand Down Expand Up @@ -659,7 +665,7 @@ packages/lib/components/shared/side-menu-shared.js
packages/lib/database-driver-better-sqlite.js
packages/lib/database.js
packages/lib/debug/DebugService.js
packages/lib/determineProfileDir.js
packages/lib/determineBaseAppDirs.js
packages/lib/dom.js
packages/lib/errorUtils.js
packages/lib/errors.js
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
publish/
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.md
!README.md
/*.jpl
/api
/src
/dist
tsconfig.json
webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Plugin development

This documentation describes how to create a plugin, and how to work with the plugin builder framework and API.

## Installation

First, install [Yeoman](http://yeoman.io) and generator-joplin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo@4.3.1
npm install -g generator-joplin
```

Then generate your new project:

```bash
yo --node-package-manager npm joplin
```

## Structure

The main two files you will want to look at are:

- `/src/index.ts`, which contains the entry point for the plugin source code.
- `/src/manifest.json`, which is the plugin manifest. It contains information such as the plugin a name, version, etc.

The file `/plugin.config.json` could also be useful if you intend to use [external scripts](#external-script-files), such as content scripts or webview scripts.

## Building the plugin

The plugin is built using Webpack, which creates the compiled code in `/dist`. A JPL archive will also be created at the root, which can use to distribute the plugin.

To build the plugin, simply run `npm run dist`.

The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.

## Updating the manifest version number

You can run `npm run updateVersion` to bump the patch part of the version number, so for example 1.0.3 will become 1.0.4. This script will update both the package.json and manifest.json version numbers so as to keep them in sync.

## Publishing the plugin

To publish the plugin, add it to npmjs.com by running `npm publish`. Later on, a script will pick up your plugin and add it automatically to the Joplin plugin repository as long as the package satisfies these conditions:

- In `package.json`, the name starts with "joplin-plugin-". For example, "joplin-plugin-toc".
- In `package.json`, the keywords include "joplin-plugin".
- In the `publish/` directory, there should be a .jpl and .json file (which are built by `npm run dist`)

In general all this is done automatically by the plugin generator, which will set the name and keywords of package.json, and will put the right files in the "publish" directory. But if something doesn't work and your plugin doesn't appear in the repository, double-check the above conditions.

## Updating the plugin framework

To update the plugin framework, run `npm run update`.

In general this command tries to do the right thing - in particular it's going to merge the changes in package.json and .gitignore instead of overwriting. It will also leave "/src" as well as README.md untouched.

The file that may cause problem is "webpack.config.js" because it's going to be overwritten. For that reason, if you want to change it, consider creating a separate JavaScript file and include it in webpack.config.js. That way, when you update, you only have to restore the line that include your file.

## External script files

By default, the compiler (webpack) is going to compile `src/index.ts` only (as well as any file it imports), and any other file will simply be copied to the plugin package. In some cases this is sufficient, however if you have [content scripts](https://joplinapp.org/api/references/plugin_api/classes/joplincontentscripts.html) or [webview scripts](https://joplinapp.org/api/references/plugin_api/classes/joplinviewspanels.html#addscript) you might want to compile them too, in particular in these two cases:

- The script is a TypeScript file - in which case it has to be compiled to JavaScript.

- The script requires modules you've added to package.json. In that case, the script, whether JS or TS, must be compiled so that the dependencies are bundled with the JPL file.

To get such an external script file to compile, you need to add it to the `extraScripts` array in `plugin.config.json`. The path you add should be relative to /src. For example, if you have a file in "/src/webviews/index.ts", the path should be set to "webviews/index.ts". Once compiled, the file will always be named with a .js extension. So you will get "webviews/index.js" in the plugin package, and that's the path you should use to reference the file.

## More information

- [Joplin Plugin API](https://joplinapp.org/api/references/plugin_api/classes/joplin.html)
- [Joplin Data API](https://joplinapp.org/help/api/references/rest_api)
- [Joplin Plugin Manifest](https://joplinapp.org/api/references/plugin_manifest/)
- Ask for help on the [forum](https://discourse.joplinapp.org/) or our [Discord channel](https://discord.gg/VSj7AFHvpq)

## License

MIT © Laurent Cozic
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Joplin Plugin

This is an example plugin that supports **both** CodeMirror5 and CodeMirror6.

See https://joplinapp.org/help/api/tutorials/cm6_plugin for the relevant tutorial.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Plugin from '../Plugin';
import Joplin from './Joplin';
/**
* @ignore
*/
/**
* @ignore
*/
export default class Global {
private joplin_;
constructor(implementation: any, plugin: Plugin, store: any);
get joplin(): Joplin;
get process(): any;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import Plugin from '../Plugin';
import JoplinData from './JoplinData';
import JoplinPlugins from './JoplinPlugins';
import JoplinWorkspace from './JoplinWorkspace';
import JoplinFilters from './JoplinFilters';
import JoplinCommands from './JoplinCommands';
import JoplinViews from './JoplinViews';
import JoplinInterop from './JoplinInterop';
import JoplinSettings from './JoplinSettings';
import JoplinContentScripts from './JoplinContentScripts';
import JoplinClipboard from './JoplinClipboard';
import JoplinWindow from './JoplinWindow';
import BasePlatformImplementation from '../BasePlatformImplementation';
import JoplinImaging from './JoplinImaging';
/**
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
*
* The API is now relatively stable and in general maintaining backward compatibility is a top priority, so you shouldn't except much breakages.
*
* If a breaking change ever becomes needed, best effort will be done to:
*
* - Deprecate features instead of removing them, so as to give you time to fix the issue;
* - Document breaking changes in the changelog;
*
* So if you are developing a plugin, please keep an eye on the changelog as everything will be in there with information about how to update your code.
*/
export default class Joplin {
private data_;
private plugins_;
private imaging_;
private workspace_;
private filters_;
private commands_;
private views_;
private interop_;
private settings_;
private contentScripts_;
private clipboard_;
private window_;
private implementation_;
constructor(implementation: BasePlatformImplementation, plugin: Plugin, store: any);
get data(): JoplinData;
get clipboard(): JoplinClipboard;
get imaging(): JoplinImaging;
get window(): JoplinWindow;
get plugins(): JoplinPlugins;
get workspace(): JoplinWorkspace;
get contentScripts(): JoplinContentScripts;
/**
* @ignore
*
* Not sure if it's the best way to hook into the app
* so for now disable filters.
*/
get filters(): JoplinFilters;
get commands(): JoplinCommands;
get views(): JoplinViews;
get interop(): JoplinInterop;
get settings(): JoplinSettings;
/**
* It is not possible to bundle native packages with a plugin, because they
* need to work cross-platforms. Instead access to certain useful native
* packages is provided using this function.
*
* Currently these packages are available:
*
* - [sqlite3](https://www.npmjs.com/package/sqlite3)
* - [fs-extra](https://www.npmjs.com/package/fs-extra)
*
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/nativeModule)
*/
require(_path: string): any;
versionInfo(): Promise<import("./types").VersionInfo>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default class JoplinClipboard {
private electronClipboard_;
private electronNativeImage_;
constructor(electronClipboard: any, electronNativeImage: any);
readText(): Promise<string>;
writeText(text: string): Promise<void>;
readHtml(): Promise<string>;
writeHtml(html: string): Promise<void>;
/**
* Returns the image in [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) format.
*/
readImage(): Promise<string>;
/**
* Takes an image in [data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) format.
*/
writeImage(dataUrl: string): Promise<void>;
/**
* Returns the list available formats (mime types).
*
* For example [ 'text/plain', 'text/html' ]
*/
availableFormats(): Promise<string[]>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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}.
*
* [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:
*
* * [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/editorCommandDeclarations.ts)
*
* To view what arguments are supported, you can open any of these files
* and look at the `execute()` command.
*
* ## Executing editor commands
*
* There might be a situation where you want to invoke editor commands
* without using a {@link JoplinContentScripts | contentScript}. For this
* reason Joplin provides the built in `editor.execCommand` command.
*
* `editor.execCommand` should work with any core command in both the
* [CodeMirror](https://codemirror.net/doc/manual.html#execCommand) and
* [TinyMCE](https://www.tiny.cloud/docs/api/tinymce/tinymce.editorcommands/#execcommand) editors,
* as well as most functions calls directly on a CodeMirror editor object (extensions).
*
* * [CodeMirror commands](https://codemirror.net/doc/manual.html#commands)
* * [TinyMCE core editor commands](https://www.tiny.cloud/docs/advanced/editor-command-identifiers/#coreeditorcommands)
*
* `editor.execCommand` supports adding arguments for the commands.
*
* ```typescript
* await joplin.commands.execute('editor.execCommand', {
* name: 'madeUpCommand', // CodeMirror and TinyMCE
* args: [], // CodeMirror and TinyMCE
* ui: false, // TinyMCE only
* value: '', // TinyMCE only
* });
* ```
*
* [View the example using the CodeMirror editor](https://github.com/laurent22/joplin/blob/dev/packages/app-cli/tests/support/plugins/codemirror_content_script/src/index.ts)
*
*/
export default class JoplinCommands {
/**
* <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:
* await joplin.commands.execute('newNote');
*
* // Create a new sub-notebook under the provided notebook
* // Note: internally, notebooks are called "folders".
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
execute(commandName: string, ...args: any[]): Promise<any | void>;
/**
* <span class="platform-desktop">desktop</span> Registers a new command.
*
* ```typescript
* // Register a new commmand called "testCommand1"
*
* await joplin.commands.register({
* name: 'testCommand1',
* label: 'My Test Command 1',
* iconName: 'fas fa-music',
* execute: () => {
* alert('Testing plugin command 1');
* },
* });
* ```
*/
register(command: Command): Promise<void>;
}
Loading