2023-06-30 10:55:56 +02:00
|
|
|
/* eslint-disable multiline-comment-style */
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
import Plugin from '../Plugin';
|
|
|
|
import JoplinData from './JoplinData';
|
|
|
|
import JoplinPlugins from './JoplinPlugins';
|
|
|
|
import JoplinWorkspace from './JoplinWorkspace';
|
|
|
|
import JoplinFilters from './JoplinFilters';
|
|
|
|
import JoplinCommands from './JoplinCommands';
|
|
|
|
import JoplinViews from './JoplinViews';
|
|
|
|
import JoplinInterop from './JoplinInterop';
|
|
|
|
import JoplinSettings from './JoplinSettings';
|
2021-01-12 01:33:10 +02:00
|
|
|
import JoplinContentScripts from './JoplinContentScripts';
|
2021-06-20 13:03:18 +02:00
|
|
|
import JoplinClipboard from './JoplinClipboard';
|
2021-07-23 12:05:21 +02:00
|
|
|
import JoplinWindow from './JoplinWindow';
|
2022-07-03 15:32:29 +02:00
|
|
|
import BasePlatformImplementation from '../BasePlatformImplementation';
|
2023-09-17 12:40:50 +02:00
|
|
|
import JoplinImaging from './JoplinImaging';
|
2020-10-09 19:35:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
2020-11-13 21:12:49 +02:00
|
|
|
*
|
2021-08-10 13:17:03 +02:00
|
|
|
* The API is now relatively stable and in general maintaining backward compatibility is a top priority, so you shouldn't except much breakages.
|
2020-11-13 21:12:49 +02:00
|
|
|
*
|
2021-08-10 13:17:03 +02:00
|
|
|
* If a breaking change ever becomes needed, best effort will be done to:
|
2020-11-13 21:12:49 +02:00
|
|
|
*
|
2021-08-10 13:17:03 +02:00
|
|
|
* - Deprecate features instead of removing them, so as to give you time to fix the issue;
|
2020-11-13 21:12:49 +02:00
|
|
|
* - Document breaking changes in the changelog;
|
|
|
|
*
|
2021-08-10 13:17:03 +02:00
|
|
|
* So if you are developing a plugin, please keep an eye on the changelog as everything will be in there with information about how to update your code.
|
2020-10-09 19:35:46 +02:00
|
|
|
*/
|
|
|
|
export default class Joplin {
|
|
|
|
|
|
|
|
private data_: JoplinData = null;
|
|
|
|
private plugins_: JoplinPlugins = null;
|
2023-09-17 12:40:50 +02:00
|
|
|
private imaging_: JoplinImaging = null;
|
2020-10-09 19:35:46 +02:00
|
|
|
private workspace_: JoplinWorkspace = null;
|
|
|
|
private filters_: JoplinFilters = null;
|
|
|
|
private commands_: JoplinCommands = null;
|
|
|
|
private views_: JoplinViews = null;
|
|
|
|
private interop_: JoplinInterop = null;
|
|
|
|
private settings_: JoplinSettings = null;
|
2021-01-12 01:33:10 +02:00
|
|
|
private contentScripts_: JoplinContentScripts = null;
|
2021-06-20 13:03:18 +02:00
|
|
|
private clipboard_: JoplinClipboard = null;
|
2021-07-23 12:05:21 +02:00
|
|
|
private window_: JoplinWindow = null;
|
2022-07-03 15:32:29 +02:00
|
|
|
private implementation_: BasePlatformImplementation = null;
|
2020-10-09 19:35:46 +02:00
|
|
|
|
2022-07-03 15:32:29 +02:00
|
|
|
public constructor(implementation: BasePlatformImplementation, plugin: Plugin, store: any) {
|
|
|
|
this.implementation_ = implementation;
|
2023-06-13 19:06:16 +02:00
|
|
|
this.data_ = new JoplinData(plugin);
|
2020-11-19 17:25:02 +02:00
|
|
|
this.plugins_ = new JoplinPlugins(plugin);
|
2023-09-17 12:40:50 +02:00
|
|
|
this.imaging_ = new JoplinImaging(implementation.imaging);
|
2020-12-01 16:08:41 +02:00
|
|
|
this.workspace_ = new JoplinWorkspace(store);
|
2020-10-09 19:35:46 +02:00
|
|
|
this.filters_ = new JoplinFilters();
|
|
|
|
this.commands_ = new JoplinCommands();
|
2021-06-20 14:46:50 +02:00
|
|
|
this.views_ = new JoplinViews(implementation.joplin.views, plugin, store);
|
2020-10-09 19:35:46 +02:00
|
|
|
this.interop_ = new JoplinInterop();
|
|
|
|
this.settings_ = new JoplinSettings(plugin);
|
2021-01-12 01:33:10 +02:00
|
|
|
this.contentScripts_ = new JoplinContentScripts(plugin);
|
2021-06-20 14:46:50 +02:00
|
|
|
this.clipboard_ = new JoplinClipboard(implementation.clipboard, implementation.nativeImage);
|
2021-07-23 12:05:21 +02:00
|
|
|
this.window_ = new JoplinWindow(implementation.window, plugin, store);
|
2020-10-09 19:35:46 +02:00
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get data(): JoplinData {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.data_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get clipboard(): JoplinClipboard {
|
2021-06-20 13:03:18 +02:00
|
|
|
return this.clipboard_;
|
|
|
|
}
|
|
|
|
|
2023-09-17 12:40:50 +02:00
|
|
|
public get imaging(): JoplinImaging {
|
|
|
|
return this.imaging_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get window(): JoplinWindow {
|
|
|
|
return this.window_;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get plugins(): JoplinPlugins {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.plugins_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get workspace(): JoplinWorkspace {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.workspace_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get contentScripts(): JoplinContentScripts {
|
2021-01-12 01:33:10 +02:00
|
|
|
return this.contentScripts_;
|
|
|
|
}
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*
|
|
|
|
* Not sure if it's the best way to hook into the app
|
|
|
|
* so for now disable filters.
|
|
|
|
*/
|
2021-07-23 12:05:21 +02:00
|
|
|
public get filters(): JoplinFilters {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.filters_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get commands(): JoplinCommands {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.commands_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get views(): JoplinViews {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.views_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get interop(): JoplinInterop {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.interop_;
|
|
|
|
}
|
|
|
|
|
2021-07-23 12:05:21 +02:00
|
|
|
public get settings(): JoplinSettings {
|
2020-10-09 19:35:46 +02:00
|
|
|
return this.settings_;
|
|
|
|
}
|
2021-01-27 14:48:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
2024-03-26 13:36:15 +02:00
|
|
|
*
|
|
|
|
* <span class="platform-desktop">desktop</span>
|
2021-01-27 14:48:47 +02:00
|
|
|
*/
|
|
|
|
public require(_path: string): any {
|
|
|
|
// Just a stub. Implementation has to be done within plugin process, in plugin_index.js
|
|
|
|
}
|
|
|
|
|
2022-07-03 15:32:29 +02:00
|
|
|
public async versionInfo() {
|
|
|
|
return this.implementation_.versionInfo;
|
|
|
|
}
|
|
|
|
|
2020-10-09 19:35:46 +02:00
|
|
|
}
|