You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
All: Add support for application plugins (#3257)
This commit is contained in:
15
CliClient/tests/support/plugins/register_command/api/Global.d.ts
vendored
Normal file
15
CliClient/tests/support/plugins/register_command/api/Global.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
import Plugin from '../Plugin';
|
||||
import Joplin from './Joplin';
|
||||
import Logger from 'lib/Logger';
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
export default class Global {
|
||||
private joplin_;
|
||||
private requireWhiteList_;
|
||||
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
|
||||
get joplin(): Joplin;
|
||||
private requireWhiteList;
|
||||
require(filePath: string): any;
|
||||
get process(): any;
|
||||
}
|
38
CliClient/tests/support/plugins/register_command/api/Joplin.d.ts
vendored
Normal file
38
CliClient/tests/support/plugins/register_command/api/Joplin.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
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';
|
||||
import Logger from 'lib/Logger';
|
||||
/**
|
||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||
*/
|
||||
export default class Joplin {
|
||||
private data_;
|
||||
private plugins_;
|
||||
private workspace_;
|
||||
private filters_;
|
||||
private commands_;
|
||||
private views_;
|
||||
private interop_;
|
||||
private settings_;
|
||||
constructor(logger: Logger, implementation: any, plugin: Plugin, store: any);
|
||||
get data(): JoplinData;
|
||||
get plugins(): JoplinPlugins;
|
||||
get workspace(): JoplinWorkspace;
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* Not sure if it's the best way to hook into the app
|
||||
* so for now disable filters.
|
||||
*/
|
||||
get filters(): JoplinFilters;
|
||||
get commands(): JoplinCommands;
|
||||
get views(): JoplinViews;
|
||||
get interop(): JoplinInterop;
|
||||
get settings(): JoplinSettings;
|
||||
}
|
51
CliClient/tests/support/plugins/register_command/api/JoplinCommands.d.ts
vendored
Normal file
51
CliClient/tests/support/plugins/register_command/api/JoplinCommands.d.ts
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
import { Command } from './types';
|
||||
/**
|
||||
* This class allows executing or registering new Joplin commands. Commands can be executed or associated with
|
||||
* {@link JoplinViewsToolbarButtons | toolbar buttons} or {@link JoplinViewsMenuItems | menu items}.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/register_command)
|
||||
*
|
||||
* ## Executing Joplin's internal commands
|
||||
*
|
||||
* It is also possible to execute internal Joplin's commands which, as of now, are not well documented.
|
||||
* You can find the list directly on GitHub though at the following locations:
|
||||
*
|
||||
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/MainScreen/commands
|
||||
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/commands
|
||||
* https://github.com/laurent22/joplin/tree/dev/ElectronClient/gui/NoteEditor/commands/editorCommandDeclarations.ts
|
||||
*
|
||||
* To view what arguments are supported, you can open any of these files and look at the `execute()` command.
|
||||
*/
|
||||
export default class JoplinCommands {
|
||||
/**
|
||||
* <span class="platform-desktop">desktop</span> Executes the given command.
|
||||
* The `props` are the arguments passed to the command, and they vary based on the command
|
||||
*
|
||||
* ```typescript
|
||||
* // Create a new note in the current notebook:
|
||||
* await joplin.commands.execute('newNote');
|
||||
*
|
||||
* // Create a new sub-notebook under the provided notebook
|
||||
* // Note: internally, notebooks are called "folders".
|
||||
* await joplin.commands.execute('newFolder', { parent_id: "SOME_FOLDER_ID" });
|
||||
* ```
|
||||
*/
|
||||
execute(commandName: string, props?: any): Promise<any>;
|
||||
/**
|
||||
* <span class="platform-desktop">desktop</span> Registers a new command.
|
||||
*
|
||||
* ```typescript
|
||||
* // Register a new commmand called "testCommand1"
|
||||
*
|
||||
* await joplin.commands.register({
|
||||
* name: 'testCommand1',
|
||||
* label: 'My Test Command 1',
|
||||
* iconName: 'fas fa-music',
|
||||
* execute: () => {
|
||||
* alert('Testing plugin command 1');
|
||||
* },
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
register(command: Command): Promise<void>;
|
||||
}
|
47
CliClient/tests/support/plugins/register_command/api/JoplinData.d.ts
vendored
Normal file
47
CliClient/tests/support/plugins/register_command/api/JoplinData.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import { Path } from './types';
|
||||
/**
|
||||
* This module provides access to the Joplin data API: https://joplinapp.org/api/
|
||||
* This is the main way to retrieve data, such as notes, notebooks, tags, etc.
|
||||
* or to update them or delete them.
|
||||
*
|
||||
* This is also what you would use to search notes, via the `search` endpoint.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/simple)
|
||||
*
|
||||
* In general you would use the methods in this class as if you were using a REST API. There are four methods that map to GET, POST, PUT and DELETE calls.
|
||||
* And each method takes these parameters:
|
||||
*
|
||||
* * `path`: This is an array that represents the path to the resource in the form `["resouceName", "resourceId", "resourceLink"]` (eg. ["tags", ":id", "notes"]). The "resources" segment is the name of the resources you want to access (eg. "notes", "folders", etc.). If not followed by anything, it will refer to all the resources in that collection. The optional "resourceId" points to a particular resources within the collection. Finally, an optional "link" can be present, which links the resource to a collection of resources. This can be used in the API for example to retrieve all the notes associated with a tag.
|
||||
* * `query`: (Optional) The query parameters. In a URL, this is the part after the question mark "?". In this case, it should be an object with key/value pairs.
|
||||
* * `data`: (Optional) Applies to PUT and POST calls only. The request body contains the data you want to create or modify, for example the content of a note or folder.
|
||||
* * `files`: (Optional) Used to create new resources and associate them with files.
|
||||
*
|
||||
* Please refer to the [Joplin API documentation](https://joplinapp.org/api/) for complete details about each call. As the plugin runs within the Joplin application **you do not need an authorisation token** to use this API.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```typescript
|
||||
* // Get a note ID, title and body
|
||||
* const noteId = 'some_note_id';
|
||||
* const note = await joplin.data.get(['notes', noteId], { fields: ['id', 'title', 'body'] });
|
||||
*
|
||||
* // Get all folders
|
||||
* const folders = await joplin.data.get(['folders']);
|
||||
*
|
||||
* // Set the note body
|
||||
* await joplin.data.put(['notes', noteId], null, { body: "New note body" });
|
||||
*
|
||||
* // Create a new note under one of the folders
|
||||
* await joplin.data.post(['notes'], null, { body: "my new note", title: "some title", parent_id: folders[0].id });
|
||||
* ```
|
||||
*/
|
||||
export default class JoplinData {
|
||||
private api_;
|
||||
private pathSegmentRegex_;
|
||||
private serializeApiBody;
|
||||
private pathToString;
|
||||
get(path: Path, query?: any): Promise<any>;
|
||||
post(path: Path, query?: any, body?: any, files?: any[]): Promise<any>;
|
||||
put(path: Path, query?: any, body?: any, files?: any[]): Promise<any>;
|
||||
delete(path: Path, query?: any): Promise<any>;
|
||||
}
|
10
CliClient/tests/support/plugins/register_command/api/JoplinFilters.d.ts
vendored
Normal file
10
CliClient/tests/support/plugins/register_command/api/JoplinFilters.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @ignore
|
||||
*
|
||||
* Not sure if it's the best way to hook into the app
|
||||
* so for now disable filters.
|
||||
*/
|
||||
export default class JoplinFilters {
|
||||
on(name: string, callback: Function): Promise<void>;
|
||||
off(name: string, callback: Function): Promise<void>;
|
||||
}
|
17
CliClient/tests/support/plugins/register_command/api/JoplinInterop.d.ts
vendored
Normal file
17
CliClient/tests/support/plugins/register_command/api/JoplinInterop.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { ExportModule, ImportModule } from './types';
|
||||
/**
|
||||
* Provides a way to create modules to import external data into Joplin or to export notes into any arbitrary format.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/json_export)
|
||||
*
|
||||
* To implement an import or export module, you would simply define an object with various event handlers that are called
|
||||
* by the application during the import/export process.
|
||||
*
|
||||
* See the documentation of the [[ExportModule]] and [[ImportModule]] for more information.
|
||||
*
|
||||
* 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/
|
||||
*/
|
||||
export default class JoplinInterop {
|
||||
registerExportModule(module: ExportModule): Promise<void>;
|
||||
registerImportModule(module: ImportModule): Promise<void>;
|
||||
}
|
24
CliClient/tests/support/plugins/register_command/api/JoplinPlugins.d.ts
vendored
Normal file
24
CliClient/tests/support/plugins/register_command/api/JoplinPlugins.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import Plugin from '../Plugin';
|
||||
import Logger from 'lib/Logger';
|
||||
import { Script } from './types';
|
||||
/**
|
||||
* This class provides access to plugin-related features.
|
||||
*/
|
||||
export default class JoplinPlugins {
|
||||
private logger;
|
||||
private plugin;
|
||||
constructor(logger: Logger, plugin: Plugin);
|
||||
/**
|
||||
* 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>;
|
||||
}
|
35
CliClient/tests/support/plugins/register_command/api/JoplinSettings.d.ts
vendored
Normal file
35
CliClient/tests/support/plugins/register_command/api/JoplinSettings.d.ts
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
import Plugin from '../Plugin';
|
||||
import { SettingItem, SettingSection } from './types';
|
||||
/**
|
||||
* This API allows registering new settings and setting sections, as well as getting and setting settings. Once a setting has been registered it will appear in the config screen and be editable by the user.
|
||||
*
|
||||
* Settings are essentially key/value pairs.
|
||||
*
|
||||
* Note: Currently this API does **not** provide access to Joplin's built-in settings. This is by design as plugins that modify user settings could give unexpected results
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/settings)
|
||||
*/
|
||||
export default class JoplinSettings {
|
||||
private plugin_;
|
||||
constructor(plugin: Plugin);
|
||||
private namespacedKey;
|
||||
/**
|
||||
* Registers a new setting. Note that registering a setting item is dynamic and will be gone next time Joplin starts.
|
||||
* What it means is that you need to register the setting every time the plugin starts (for example in the onStart event).
|
||||
* The setting value however will be preserved from one launch to the next so there is no risk that it will be lost even if for some
|
||||
* reason the plugin fails to start at some point.
|
||||
*/
|
||||
registerSetting(key: string, settingItem: SettingItem): Promise<void>;
|
||||
/**
|
||||
* Registers a new setting section. Like for registerSetting, it is dynamic and needs to be done every time the plugin starts.
|
||||
*/
|
||||
registerSection(name: string, section: SettingSection): Promise<void>;
|
||||
/**
|
||||
* Gets a setting value (only applies to setting you registered from your plugin)
|
||||
*/
|
||||
value(key: string): Promise<any>;
|
||||
/**
|
||||
* Sets a setting value (only applies to setting you registered from your plugin)
|
||||
*/
|
||||
setValue(key: string, value: any): Promise<void>;
|
||||
}
|
24
CliClient/tests/support/plugins/register_command/api/JoplinViews.d.ts
vendored
Normal file
24
CliClient/tests/support/plugins/register_command/api/JoplinViews.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import Plugin from '../Plugin';
|
||||
import JoplinViewsDialogs from './JoplinViewsDialogs';
|
||||
import JoplinViewsMenuItems from './JoplinViewsMenuItems';
|
||||
import JoplinViewsToolbarButtons from './JoplinViewsToolbarButtons';
|
||||
import JoplinViewsPanels from './JoplinViewsPanels';
|
||||
/**
|
||||
* This namespace provides access to view-related services.
|
||||
*
|
||||
* All view services provide a `create()` method which you would use to create the view object, whether it's a dialog, a toolbar button or a menu item.
|
||||
* In some cases, the `create()` method will return a [[ViewHandle]], which you would use to act on the view, for example to set certain properties or call some methods.
|
||||
*/
|
||||
export default class JoplinViews {
|
||||
private store;
|
||||
private plugin;
|
||||
private dialogs_;
|
||||
private panels_;
|
||||
private menuItems_;
|
||||
private toolbarButtons_;
|
||||
constructor(plugin: Plugin, store: any);
|
||||
get dialogs(): JoplinViewsDialogs;
|
||||
get panels(): JoplinViewsPanels;
|
||||
get menuItems(): JoplinViewsMenuItems;
|
||||
get toolbarButtons(): JoplinViewsToolbarButtons;
|
||||
}
|
31
CliClient/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts
vendored
Normal file
31
CliClient/tests/support/plugins/register_command/api/JoplinViewsDialogs.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import Plugin from '../Plugin';
|
||||
import { ButtonSpec, ViewHandle, ButtonId } 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.
|
||||
* 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 and provide the button ID that was
|
||||
* clicked on. 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.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/dialog)
|
||||
*/
|
||||
export default class JoplinViewsDialogs {
|
||||
private store;
|
||||
private plugin;
|
||||
constructor(plugin: Plugin, store: any);
|
||||
private controller;
|
||||
/**
|
||||
* Creates a new dialog
|
||||
*/
|
||||
create(): Promise<ViewHandle>;
|
||||
/**
|
||||
* Sets the dialog HTML content
|
||||
*/
|
||||
setHtml(handle: ViewHandle, html: string): Promise<string>;
|
||||
/**
|
||||
* Sets the dialog buttons.
|
||||
*/
|
||||
setButtons(handle: ViewHandle, buttons: ButtonSpec[]): Promise<ButtonSpec[]>;
|
||||
/**
|
||||
* Opens the dialog
|
||||
*/
|
||||
open(handle: ViewHandle): Promise<ButtonId>;
|
||||
}
|
16
CliClient/tests/support/plugins/register_command/api/JoplinViewsMenuItems.d.ts
vendored
Normal file
16
CliClient/tests/support/plugins/register_command/api/JoplinViewsMenuItems.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import { CreateMenuItemOptions, MenuItemLocation } from './types';
|
||||
import Plugin from '../Plugin';
|
||||
/**
|
||||
* Allows creating and managing menu items.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/register_command)
|
||||
*/
|
||||
export default class JoplinViewsMenuItems {
|
||||
private store;
|
||||
private plugin;
|
||||
constructor(plugin: Plugin, store: any);
|
||||
/**
|
||||
* Creates a new menu item and associate it with the given command. You can specify under which menu the item should appear using the `location` parameter.
|
||||
*/
|
||||
create(commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
|
||||
}
|
30
CliClient/tests/support/plugins/register_command/api/JoplinViewsPanels.d.ts
vendored
Normal file
30
CliClient/tests/support/plugins/register_command/api/JoplinViewsPanels.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
import Plugin from '../Plugin';
|
||||
import { ViewHandle } from './types';
|
||||
/**
|
||||
* Allows creating and managing view panels. View panels currently are displayed at the right of the sidebar and allows displaying any HTML content (within a webview) and update it in real-time. For example
|
||||
* it could be used to display a table of content for the active note, or display various metadata or graph.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/toc)
|
||||
*/
|
||||
export default class JoplinViewsPanels {
|
||||
private store;
|
||||
private plugin;
|
||||
constructor(plugin: Plugin, store: any);
|
||||
private controller;
|
||||
/**
|
||||
* Creates a new panel
|
||||
*/
|
||||
create(): Promise<ViewHandle>;
|
||||
/**
|
||||
* Sets the panel webview HTML
|
||||
*/
|
||||
setHtml(handle: ViewHandle, html: string): Promise<string>;
|
||||
/**
|
||||
* Adds and loads a new JS or CSS files into the panel.
|
||||
*/
|
||||
addScript(handle: ViewHandle, scriptPath: string): Promise<void>;
|
||||
/**
|
||||
* Called when a message is sent from the webview (using postMessage).
|
||||
*/
|
||||
onMessage(handle: ViewHandle, callback: Function): Promise<void>;
|
||||
}
|
16
CliClient/tests/support/plugins/register_command/api/JoplinViewsToolbarButtons.d.ts
vendored
Normal file
16
CliClient/tests/support/plugins/register_command/api/JoplinViewsToolbarButtons.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import { ToolbarButtonLocation } from './types';
|
||||
import Plugin from '../Plugin';
|
||||
/**
|
||||
* Allows creating and managing toolbar buttons.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/register_command)
|
||||
*/
|
||||
export default class JoplinViewsToolbarButtons {
|
||||
private store;
|
||||
private plugin;
|
||||
constructor(plugin: Plugin, store: any);
|
||||
/**
|
||||
* Creates a new toolbar button and associate it with the given command.
|
||||
*/
|
||||
create(commandName: string, location: ToolbarButtonLocation): Promise<void>;
|
||||
}
|
34
CliClient/tests/support/plugins/register_command/api/JoplinWorkspace.d.ts
vendored
Normal file
34
CliClient/tests/support/plugins/register_command/api/JoplinWorkspace.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* The workspace service provides access to all the parts of Joplin that are being worked on - i.e. the currently selected notes or notebooks as well
|
||||
* as various related events, such as when a new note is selected, or when the note content changes.
|
||||
*
|
||||
* [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins)
|
||||
*/
|
||||
export default class JoplinWorkspace {
|
||||
private store;
|
||||
constructor(_implementation: any, store: any);
|
||||
/**
|
||||
* Called when a new note or notes are selected.
|
||||
*/
|
||||
onNoteSelectionChange(callback: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the content of a note changes.
|
||||
*/
|
||||
onNoteContentChange(callback: Function): Promise<void>;
|
||||
/**
|
||||
* Called when an alarm associated with a to-do is triggered.
|
||||
*/
|
||||
onNoteAlarmTrigger(callback: Function): Promise<void>;
|
||||
/**
|
||||
* Called when the synchronisation process has finished.
|
||||
*/
|
||||
onSyncComplete(callback: Function): Promise<void>;
|
||||
/**
|
||||
* Gets the currently selected note
|
||||
*/
|
||||
selectedNote(): Promise<any>;
|
||||
/**
|
||||
* Gets the IDs of the selected notes (can be zero, one, or many). Use the data API to retrieve information about these notes.
|
||||
*/
|
||||
selectedNoteIds(): Promise<string[]>;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
import type Joplin from './Joplin';
|
||||
|
||||
declare const joplin:Joplin;
|
||||
|
||||
export default joplin;
|
252
CliClient/tests/support/plugins/register_command/api/types.ts
Normal file
252
CliClient/tests/support/plugins/register_command/api/types.ts
Normal file
@ -0,0 +1,252 @@
|
||||
// =================================================================
|
||||
// Command API types
|
||||
// =================================================================
|
||||
|
||||
export interface Command {
|
||||
name: string
|
||||
label: string
|
||||
iconName?: string,
|
||||
execute(props:any):Promise<any>
|
||||
isEnabled?(props:any):boolean
|
||||
mapStateToProps?(state:any):any
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Interop API types
|
||||
// =================================================================
|
||||
|
||||
export enum FileSystemItem {
|
||||
File = 'file',
|
||||
Directory = 'directory',
|
||||
}
|
||||
|
||||
export enum ImportModuleOutputFormat {
|
||||
Markdown = 'md',
|
||||
Html = 'html',
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to implement a module to export data from Joplin. [View the demo plugin](https://github.com/laurent22/joplin/CliClient/tests/support/plugins/json_export) for an example.
|
||||
*
|
||||
* In general, all the event handlers you'll need to implement take a `context` object as a first argument. This object will contain the export or import path as well as various optional properties, such as which notes or notebooks need to be exported.
|
||||
*
|
||||
* To get a better sense of what it will contain it can be useful to print it using `console.info(context)`.
|
||||
*/
|
||||
export interface ExportModule {
|
||||
/**
|
||||
* The format to be exported, eg "enex", "jex", "json", etc.
|
||||
*/
|
||||
format: string,
|
||||
|
||||
/**
|
||||
* The description that will appear in the UI, for example in the menu item.
|
||||
*/
|
||||
description: string,
|
||||
|
||||
/**
|
||||
* Whether the module will export a single file or multiple files in a directory. It affects the open dialog that will be presented to the user when using your exporter.
|
||||
*/
|
||||
target: FileSystemItem,
|
||||
|
||||
/**
|
||||
* Only applies to single file exporters or importers
|
||||
* It tells whether the format can package multiple notes into one file.
|
||||
* For example JEX or ENEX can, but HTML cannot.
|
||||
*/
|
||||
isNoteArchive: boolean,
|
||||
|
||||
/**
|
||||
* The extensions of the files exported by your module. For example, it is `["htm", "html"]` for the HTML module, and just `["jex"]` for the JEX module.
|
||||
*/
|
||||
fileExtensions?: string[],
|
||||
|
||||
/**
|
||||
* Called when the export process starts.
|
||||
*/
|
||||
onInit(context:ExportContext): Promise<void>;
|
||||
|
||||
/**
|
||||
* Called when an item needs to be processed. An "item" can be any Joplin object, such as a note, a folder, a notebook, etc.
|
||||
*/
|
||||
onProcessItem(context:ExportContext, itemType:number, item:any):Promise<void>;
|
||||
|
||||
/**
|
||||
* Called when a resource file needs to be exported.
|
||||
*/
|
||||
onProcessResource(context:ExportContext, resource:any, filePath:string):Promise<void>;
|
||||
|
||||
/**
|
||||
* Called when the export process is done.
|
||||
*/
|
||||
onClose(context:ExportContext):Promise<void>;
|
||||
}
|
||||
|
||||
export interface ImportModule {
|
||||
/**
|
||||
* The format to be exported, eg "enex", "jex", "json", etc.
|
||||
*/
|
||||
format: string,
|
||||
|
||||
/**
|
||||
* The description that will appear in the UI, for example in the menu item.
|
||||
*/
|
||||
description: string,
|
||||
|
||||
/**
|
||||
* Only applies to single file exporters or importers
|
||||
* It tells whether the format can package multiple notes into one file.
|
||||
* For example JEX or ENEX can, but HTML cannot.
|
||||
*/
|
||||
isNoteArchive: boolean,
|
||||
|
||||
/**
|
||||
* The type of sources that are supported by the module. Tells whether the module can import files or directories or both.
|
||||
*/
|
||||
sources: FileSystemItem[],
|
||||
|
||||
/**
|
||||
* Tells the file extensions of the exported files.
|
||||
*/
|
||||
fileExtensions?: string[],
|
||||
|
||||
/**
|
||||
* Tells the type of notes that will be generated, either HTML or Markdown (default).
|
||||
*/
|
||||
outputFormat?: ImportModuleOutputFormat,
|
||||
|
||||
/**
|
||||
* Called when the import process starts. There is only one event handler within which you should import the complete data.
|
||||
*/
|
||||
onExec(context:ImportContext): Promise<void>;
|
||||
}
|
||||
|
||||
export interface ExportOptions {
|
||||
format?: string,
|
||||
path?:string,
|
||||
sourceFolderIds?: string[],
|
||||
sourceNoteIds?: string[],
|
||||
modulePath?:string,
|
||||
target?:FileSystemItem,
|
||||
}
|
||||
|
||||
export interface ExportContext {
|
||||
destPath: string,
|
||||
options: ExportOptions,
|
||||
|
||||
/**
|
||||
* You can attach your own custom data using this propery - it will then be passed to each event handler, allowing you to keep state from one event to the next.
|
||||
*/
|
||||
userData?: any,
|
||||
}
|
||||
|
||||
export interface ImportContext {
|
||||
sourcePath: string,
|
||||
options: any,
|
||||
warnings: string[],
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Misc types
|
||||
// =================================================================
|
||||
|
||||
export interface Script {
|
||||
onStart?(event:any):Promise<void>,
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// View API types
|
||||
// =================================================================
|
||||
|
||||
export type ButtonId = string;
|
||||
|
||||
export interface ButtonSpec {
|
||||
id: ButtonId,
|
||||
title?: string,
|
||||
onClick?():void,
|
||||
}
|
||||
|
||||
export interface CreateMenuItemOptions {
|
||||
accelerator: string,
|
||||
}
|
||||
|
||||
export enum MenuItemLocation {
|
||||
File = 'file',
|
||||
Edit = 'edit',
|
||||
View = 'view',
|
||||
Note = 'note',
|
||||
Tools = 'tools',
|
||||
Help = 'help',
|
||||
Context = 'context',
|
||||
}
|
||||
|
||||
export enum ToolbarButtonLocation {
|
||||
/**
|
||||
* This toolbar in the top right corner of the application. It applies to the note as a whole, including its metadata.
|
||||
*/
|
||||
NoteToolbar = 'noteToolbar',
|
||||
|
||||
/**
|
||||
* This toolbar is right above the text editor. It applies to the note body only.
|
||||
*/
|
||||
EditorToolbar = 'editorToolbar',
|
||||
}
|
||||
|
||||
export type ViewHandle = string;
|
||||
|
||||
export interface EditorCommand {
|
||||
name: string;
|
||||
value?: any;
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Settings types
|
||||
// =================================================================
|
||||
|
||||
export enum SettingItemType {
|
||||
Int = 1,
|
||||
String = 2,
|
||||
Bool = 3,
|
||||
Array = 4,
|
||||
Object = 5,
|
||||
Button = 6,
|
||||
}
|
||||
|
||||
// Redefine a simplified interface to mask internal details
|
||||
// and to remove function calls as they would have to be async.
|
||||
export interface SettingItem {
|
||||
value: any,
|
||||
type: SettingItemType,
|
||||
public: boolean,
|
||||
label:string,
|
||||
|
||||
description?:string,
|
||||
isEnum?: boolean,
|
||||
section?: string,
|
||||
options?:any,
|
||||
appTypes?:string[],
|
||||
secure?: boolean,
|
||||
advanced?: boolean,
|
||||
minimum?: number,
|
||||
maximum?: number,
|
||||
step?: number,
|
||||
}
|
||||
|
||||
export interface SettingSection {
|
||||
label: string,
|
||||
iconName?: string,
|
||||
description?: string,
|
||||
name?: string,
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
// Data API types
|
||||
// =================================================================
|
||||
|
||||
/**
|
||||
* An array of at least one element and at most three elements.
|
||||
*
|
||||
* [0]: Resource name (eg. "notes", "folders", "tags", etc.)
|
||||
* [1]: (Optional) Resource ID.
|
||||
* [2]: (Optional) Resource link.
|
||||
*/
|
||||
export type Path = string[];
|
Reference in New Issue
Block a user