1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Plugins: Updated types

This commit is contained in:
Laurent Cozic 2020-11-18 10:38:48 +00:00
parent 7188eb9db4
commit 98a75e67d8
101 changed files with 1143 additions and 245 deletions

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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/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. - `/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 ## 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`. 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 ## Updating the plugin framework
To update the plugin framework, run `yo joplin --update` To update the plugin framework, run `yo joplin --update`

View File

@ -21,7 +21,7 @@ import { Command } from './types';
* and look at the `execute()` command. * and look at the `execute()` command.
*/ */
export default class JoplinCommands { export default class JoplinCommands {
/** /**
* <span class="platform-desktop">desktop</span> Executes the given * <span class="platform-desktop">desktop</span> Executes the given
* command. * command.
* *
@ -40,8 +40,8 @@ export default class JoplinCommands {
* await joplin.commands.execute('newFolder', "SOME_FOLDER_ID"); * await joplin.commands.execute('newFolder', "SOME_FOLDER_ID");
* ``` * ```
*/ */
execute(commandName: string, ...args: any[]): Promise<any | void>; execute(commandName: string, ...args: any[]): Promise<any | void>;
/** /**
* <span class="platform-desktop">desktop</span> Registers a new command. * <span class="platform-desktop">desktop</span> Registers a new command.
* *
* ```typescript * ```typescript
@ -57,5 +57,5 @@ export default class JoplinCommands {
* }); * });
* ``` * ```
*/ */
register(command: Command): Promise<void>; register(command: Command): Promise<void>;
} }

View File

@ -5,6 +5,6 @@
* so for now disable filters. * so for now disable filters.
*/ */
export default class JoplinFilters { export default class JoplinFilters {
on(name: string, callback: Function): Promise<void>; on(name: string, callback: Function): Promise<void>;
off(name: string, callback: Function): Promise<void>; off(name: string, callback: Function): Promise<void>;
} }

View File

@ -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/ * 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 { export default class JoplinInterop {
registerExportModule(module: ExportModule): Promise<void>; registerExportModule(module: ExportModule): Promise<void>;
registerImportModule(module: ImportModule): Promise<void>; registerImportModule(module: ImportModule): Promise<void>;
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

View File

@ -161,7 +161,7 @@ export interface ExportOptions {
path?: string; path?: string;
sourceFolderIds?: string[]; sourceFolderIds?: string[];
sourceNoteIds?: string[]; sourceNoteIds?: string[];
modulePath?: string; // modulePath?: string;
target?: FileSystemItem; target?: FileSystemItem;
} }
@ -366,5 +366,41 @@ export enum ContentScriptType {
* ``` * ```
*/ */
MarkdownItPlugin = 'markdownItPlugin', 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', CodeMirrorPlugin = 'codeMirrorPlugin',
} }

View File

@ -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 * Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported. * (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
* *
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/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 type Defines how the script will be used. See the type definition for more information about each supported type.
* @param id A unique ID for the content script. * @param id A unique ID for the content script.

View File

@ -1,12 +1,33 @@
import Plugin from '../Plugin'; import Plugin from '../Plugin';
import { ButtonSpec, ViewHandle, DialogResult } from './types'; 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. * Allows creating and managing dialogs. A dialog is modal window that
* 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 * contains a webview and a row of buttons. You can update the update the
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form. * webview using the `setHtml` method. Dialogs are hidden by default and
* 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. * 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 { export default class JoplinViewsDialogs {
private store; private store;

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