diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/README.md b/packages/app-cli/tests/support/plugins/codemirror_content_script/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/README.md
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror_content_script/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/content_script/README.md b/packages/app-cli/tests/support/plugins/content_script/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/content_script/README.md
+++ b/packages/app-cli/tests/support/plugins/content_script/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/content_script/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/content_script/api/types.ts b/packages/app-cli/tests/support/plugins/content_script/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/content_script/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/content_script/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/dialog/README.md b/packages/app-cli/tests/support/plugins/dialog/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/dialog/README.md
+++ b/packages/app-cli/tests/support/plugins/dialog/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/dialog/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/dialog/api/types.ts b/packages/app-cli/tests/support/plugins/dialog/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/dialog/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/dialog/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/README.md b/packages/app-cli/tests/support/plugins/editor_context_menu/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/README.md
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts b/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/editor_context_menu/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/events/README.md b/packages/app-cli/tests/support/plugins/events/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/events/README.md
+++ b/packages/app-cli/tests/support/plugins/events/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/events/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/events/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/events/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/events/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/events/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/events/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/events/api/types.ts b/packages/app-cli/tests/support/plugins/events/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/events/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/events/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/README.md b/packages/app-cli/tests/support/plugins/jpl_test/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/README.md
+++ b/packages/app-cli/tests/support/plugins/jpl_test/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts b/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/jpl_test/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/json_export/README.md b/packages/app-cli/tests/support/plugins/json_export/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/json_export/README.md
+++ b/packages/app-cli/tests/support/plugins/json_export/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/json_export/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/json_export/api/types.ts b/packages/app-cli/tests/support/plugins/json_export/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/json_export/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/json_export/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/menu/README.md b/packages/app-cli/tests/support/plugins/menu/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/menu/README.md
+++ b/packages/app-cli/tests/support/plugins/menu/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/menu/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/menu/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/menu/api/types.ts b/packages/app-cli/tests/support/plugins/menu/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/menu/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/menu/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/README.md b/packages/app-cli/tests/support/plugins/multi_selection/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/README.md
+++ b/packages/app-cli/tests/support/plugins/multi_selection/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts b/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/multi_selection/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/register_command/README.md b/packages/app-cli/tests/support/plugins/register_command/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/register_command/README.md
+++ b/packages/app-cli/tests/support/plugins/register_command/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/register_command/api/types.ts b/packages/app-cli/tests/support/plugins/register_command/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/register_command/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/register_command/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/selected_text/README.md b/packages/app-cli/tests/support/plugins/selected_text/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/README.md
+++ b/packages/app-cli/tests/support/plugins/selected_text/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/selected_text/api/types.ts b/packages/app-cli/tests/support/plugins/selected_text/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/selected_text/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/selected_text/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/settings/README.md b/packages/app-cli/tests/support/plugins/settings/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/settings/README.md
+++ b/packages/app-cli/tests/support/plugins/settings/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/settings/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/settings/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/settings/api/types.ts b/packages/app-cli/tests/support/plugins/settings/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/settings/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/settings/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/toc/README.md b/packages/app-cli/tests/support/plugins/toc/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/toc/README.md
+++ b/packages/app-cli/tests/support/plugins/toc/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/toc/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/toc/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/toc/api/types.ts b/packages/app-cli/tests/support/plugins/toc/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/toc/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/toc/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/README.md b/packages/app-cli/tests/support/plugins/withExternalModules/README.md
index 4618fa796..884120872 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/README.md
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/README.md
@@ -7,12 +7,14 @@ 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 plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
-
## 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 plugin framework
To update the plugin framework, run `yo joplin --update`
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts
index e175d2e14..8a9f30451 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinCommands.d.ts
@@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command.
*/
export default class JoplinCommands {
- /**
+ /**
* desktop Executes the given
* command.
*
@@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ```
*/
- execute(commandName: string, ...args: any[]): Promise;
- /**
+ execute(commandName: string, ...args: any[]): Promise;
+ /**
* desktop Registers a new command.
*
* ```typescript
@@ -57,5 +57,5 @@ export default class JoplinCommands {
* });
* ```
*/
- register(command: Command): Promise;
+ register(command: Command): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinFilters.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinFilters.d.ts
index e086a720e..43bc1b2b7 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinFilters.d.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinFilters.d.ts
@@ -5,6 +5,6 @@
* so for now disable filters.
*/
export default class JoplinFilters {
- on(name: string, callback: Function): Promise;
- off(name: string, callback: Function): Promise;
+ on(name: string, callback: Function): Promise;
+ off(name: string, callback: Function): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinInterop.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinInterop.d.ts
index 1304c7512..8de655c83 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinInterop.d.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinInterop.d.ts
@@ -12,6 +12,6 @@ import { ExportModule, ImportModule } from './types';
* You may also want to refer to the Joplin API documentation to see the list of properties for each item (note, notebook, etc.) - https://joplinapp.org/api/references/rest_api/
*/
export default class JoplinInterop {
- registerExportModule(module: ExportModule): Promise;
- registerImportModule(module: ImportModule): Promise;
+ registerExportModule(module: ExportModule): Promise;
+ registerImportModule(module: ImportModule): Promise;
}
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinPlugins.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinPlugins.d.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinViewsDialogs.d.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinViewsDialogs.d.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts b/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts
+++ b/packages/app-cli/tests/support/plugins/withExternalModules/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}
diff --git a/packages/generator-joplin/generators/app/templates/api/JoplinPlugins.d.ts b/packages/generator-joplin/generators/app/templates/api/JoplinPlugins.d.ts
index fc9fda6a3..2a2bfd93a 100644
--- a/packages/generator-joplin/generators/app/templates/api/JoplinPlugins.d.ts
+++ b/packages/generator-joplin/generators/app/templates/api/JoplinPlugins.d.ts
@@ -28,7 +28,8 @@ 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/packages/app-cli/tests/support/plugins/content_script)
+ * [View the renderer demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/content_script)
+ * [View the editor demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_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.
diff --git a/packages/generator-joplin/generators/app/templates/api/JoplinViewsDialogs.d.ts b/packages/generator-joplin/generators/app/templates/api/JoplinViewsDialogs.d.ts
index 5956c0eca..4ab87c587 100644
--- a/packages/generator-joplin/generators/app/templates/api/JoplinViewsDialogs.d.ts
+++ b/packages/generator-joplin/generators/app/templates/api/JoplinViewsDialogs.d.ts
@@ -1,12 +1,33 @@
import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types';
/**
- * Allows creating and managing dialogs. A dialog is modal window that contains a webview and a row of buttons. You can update the update the webview using the `setHtml` method.
- * 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 an object indicating what button was clicked
- * on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
- * 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.
+ * Allows creating and managing dialogs. A dialog is modal window that
+ * contains a webview and a row of buttons. You can update the update the
+ * webview using the `setHtml` method. 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 an object indicating what button was
+ * clicked on.
*
- * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
+ * ## Retrieving form values
+ *
+ * If your HTML content included one or more forms, a `formData` object
+ * will also be included with the key/value for each form.
+ *
+ * ## Special button IDs
+ *
+ * The following buttons IDs have a special meaning:
+ *
+ * - `ok`, `yes`, `submit`, `confirm`: They are considered "submit" buttons
+ * - `cancel`, `no`, `reject`: They are considered "dismiss" buttons
+ *
+ * This information is used by the application to determine what action
+ * should be done when the user presses "Enter" or "Escape" within the
+ * dialog. If they press "Enter", the first "submit" button will be
+ * automatically clicked. If they press "Escape" the first "dismiss" button
+ * will be automatically clicked.
+ *
+ * [View the demo
+ * plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
*/
export default class JoplinViewsDialogs {
private store;
diff --git a/packages/generator-joplin/generators/app/templates/api/types.ts b/packages/generator-joplin/generators/app/templates/api/types.ts
index d58bca6c3..f81bc1038 100644
--- a/packages/generator-joplin/generators/app/templates/api/types.ts
+++ b/packages/generator-joplin/generators/app/templates/api/types.ts
@@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string;
sourceFolderIds?: string[];
sourceNoteIds?: string[];
- modulePath?: string;
+ // modulePath?: string;
target?: FileSystemItem;
}
@@ -366,5 +366,41 @@ export enum ContentScriptType {
* ```
*/
MarkdownItPlugin = 'markdownItPlugin',
+ /**
+ * Registers a new CodeMirror plugin, which should follow the template below.
+ *
+ * ```javascript
+ * module.exports = {
+ * default: function(context) {
+ * return {
+ * plugin: function(CodeMirror) {
+ * // ...
+ * },
+ * codeMirrorResources: [],
+ * codeMirrorOptions: {
+ * // ...
+ * },
+ * 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 `plugin` key is your CodeMirror plugin. This is where you can register new commands with CodeMirror or interact with the CodeMirror instance as needed.
+ *
+ * - The `codeMirrorResources` key is an array of CodeMirror resources that will be loaded and attached to the CodeMirror module. These are made up of addons, keymaps, and modes. For example, for a plugin that want's to enable clojure highlighting in code blocks. `codeMirrorResources` would be set to `['mode/clojure/clojure']`.
+ *
+ * - The `codeMirrorOptions` key contains all the [CodeMirror](https://codemirror.net/doc/manual.html#config) options that will be set or changed by this plugin. New options can alse be declared via [`CodeMirror.defineOption`](https://codemirror.net/doc/manual.html#defineOption), and then have their value set here. For example, a plugin that enables line numbers would set `codeMirrorOptions` to `{'lineNumbers': true}`.
+ *
+ * - Using the **optional** `assets` key you may specify **only** CSS assets 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.
+ *
+ * One of the `plugin`, `codeMirrorResources`, or `codeMirrorOptions` keys must be provided for the plugin to be valid. Having multiple or all provided is also okay.
+ *
+ * See the [demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/codemirror_content_script) for an example of all these keys being used in one plugin.
+ */
CodeMirrorPlugin = 'codeMirrorPlugin',
}