From 9f7ea7d865a990b3a21cc8c59093390d9db61653 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 20 Oct 2020 20:05:31 +0100 Subject: [PATCH] Updated doc --- .../lib/services/plugins/api/JoplinPlugins.ts | 2 ++ .../lib/services/plugins/api/types.ts | 35 +++++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) 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'); + * } * } * } * ```