2020-10-21 01:23:55 +02:00
|
|
|
import Plugin from '../Plugin';
|
2020-10-21 01:35:06 +02:00
|
|
|
import { ContentScriptType, Script } from './types';
|
2020-10-21 01:23:55 +02:00
|
|
|
/**
|
|
|
|
* This class provides access to plugin-related features.
|
|
|
|
*/
|
|
|
|
export default class JoplinPlugins {
|
|
|
|
private plugin;
|
2020-11-23 19:06:52 +02:00
|
|
|
constructor(plugin: Plugin);
|
2020-10-21 01:23:55 +02:00
|
|
|
/**
|
|
|
|
* Registers a new plugin. This is the entry point when creating a plugin. You should pass a simple object with an `onStart` method to it.
|
|
|
|
* That `onStart` method will be executed as soon as the plugin is loaded.
|
|
|
|
*
|
|
|
|
* ```typescript
|
|
|
|
* joplin.plugins.register({
|
|
|
|
* onStart: async function() {
|
|
|
|
* // Run your plugin code here
|
|
|
|
* }
|
|
|
|
* });
|
|
|
|
* ```
|
|
|
|
*/
|
|
|
|
register(script: Script): Promise<void>;
|
2020-10-21 01:35:06 +02:00
|
|
|
/**
|
2021-01-12 01:34:06 +02:00
|
|
|
* @deprecated Use joplin.contentScripts.register()
|
2020-10-21 01:35:06 +02:00
|
|
|
*/
|
|
|
|
registerContentScript(type: ContentScriptType, id: string, scriptPath: string): Promise<void>;
|
2021-01-24 20:03:33 +02:00
|
|
|
/**
|
|
|
|
* Gets the plugin own data directory path. Use this to store any plugin-related data.
|
|
|
|
*/
|
|
|
|
dataDir(): Promise<string>;
|
|
|
|
/**
|
|
|
|
* It is not possible to bundle native packages with a plugin, because they
|
|
|
|
* need to work cross-platforms. Instead access to certain useful native
|
|
|
|
* packages is provided using this function.
|
|
|
|
*
|
|
|
|
* Currently these packages are available:
|
|
|
|
*
|
|
|
|
* - [sqlite3](https://www.npmjs.com/package/sqlite3)
|
|
|
|
* - [fs-extra](https://www.npmjs.com/package/fs-extra)
|
|
|
|
*
|
|
|
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/nativeModule)
|
|
|
|
*/
|
|
|
|
require(_path: string): any;
|
2020-10-21 01:23:55 +02:00
|
|
|
}
|