diff --git a/ReactNativeClient/lib/services/plugins/api/JoplinPlugins.ts b/ReactNativeClient/lib/services/plugins/api/JoplinPlugins.ts index 0ce47f3ca..b5b5143ba 100644 --- a/ReactNativeClient/lib/services/plugins/api/JoplinPlugins.ts +++ b/ReactNativeClient/lib/services/plugins/api/JoplinPlugins.ts @@ -58,6 +58,8 @@ export default class JoplinPlugins { * * [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/CliClient/tests/support/plugins/content_script) * + * @param type Defines how the script will be used. See the type definition for more information about each supported type. + * @param id A unique ID for the content script. * @param scriptPath Must be a path relative to the plugin main script. For example, if your file content_script.js is next to your index.ts file, you would set `scriptPath` to `"./content_script.js`. */ async registerContentScript(type:ContentScriptType, id:string, scriptPath:string) { diff --git a/ReactNativeClient/lib/services/plugins/api/types.ts b/ReactNativeClient/lib/services/plugins/api/types.ts index 229311d0c..34f8be719 100644 --- a/ReactNativeClient/lib/services/plugins/api/types.ts +++ b/ReactNativeClient/lib/services/plugins/api/types.ts @@ -322,22 +322,27 @@ export enum ContentScriptType { * Registers a new Markdown-It plugin, which should follow this template: * * ```javascript - * - * // The module should export an object like below: + * // The module should export an object as below: * * module.exports = { - * default: { - * // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information - * // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which - * // contains a number of options, mostly useful for Joplin's internal code. - * plugin: function(markdownIt, options) { * - * }, + * // The "context" variable is currently unused but could be used later on to provide + * // access to your own plugin so that the content script and plugin can communicate. + * default: function(context) { + * return { * - * // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. - * // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to - * // see how the data should be structured. - * assets: {}, + * // This is the actual Markdown-It plugin - check the [official doc](https://github.com/markdown-it/markdown-it) for more information + * // The `options` parameter is of type [RuleOptions](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml.ts), which + * // contains a number of options, mostly useful for Joplin's internal code. + * plugin: function(markdownIt, options) { + * // ... + * }, + * + * // You may also specify additional assets such as JS or CSS that should be loaded in the rendered HTML document. + * // Check for example the Joplin [Mermaid plugin](https://github.com/laurent22/joplin/blob/dev/ReactNativeClient/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to + * // see how the data should be structured. + * assets: {}, + * } * } * } * ``` @@ -347,8 +352,10 @@ export enum ContentScriptType { * * ```javascript * module.exports = { - * default: { - * plugin: require('markdown-it-toc-done-right'); + * default: function(context) { + * return { + * plugin: require('markdown-it-toc-done-right'); + * } * } * } * ```