mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Plugins: Add support for editor context menu
This commit is contained in:
parent
7151a48138
commit
4f41fb7b54
@ -208,6 +208,15 @@ packages/app-cli/tests/support/plugins/dialog/api/types.js.map
|
|||||||
packages/app-cli/tests/support/plugins/dialog/src/index.d.ts
|
packages/app-cli/tests/support/plugins/dialog/src/index.d.ts
|
||||||
packages/app-cli/tests/support/plugins/dialog/src/index.js
|
packages/app-cli/tests/support/plugins/dialog/src/index.js
|
||||||
packages/app-cli/tests/support/plugins/dialog/src/index.js.map
|
packages/app-cli/tests/support/plugins/dialog/src/index.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.js.map
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.d.ts
|
packages/app-cli/tests/support/plugins/events/api/index.d.ts
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.js
|
packages/app-cli/tests/support/plugins/events/api/index.js
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.js.map
|
packages/app-cli/tests/support/plugins/events/api/index.js.map
|
||||||
@ -499,9 +508,9 @@ packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.js.map
|
|||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js.map
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.js.map
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js.map
|
||||||
|
15
.gitignore
vendored
15
.gitignore
vendored
@ -200,6 +200,15 @@ packages/app-cli/tests/support/plugins/dialog/api/types.js.map
|
|||||||
packages/app-cli/tests/support/plugins/dialog/src/index.d.ts
|
packages/app-cli/tests/support/plugins/dialog/src/index.d.ts
|
||||||
packages/app-cli/tests/support/plugins/dialog/src/index.js
|
packages/app-cli/tests/support/plugins/dialog/src/index.js
|
||||||
packages/app-cli/tests/support/plugins/dialog/src/index.js.map
|
packages/app-cli/tests/support/plugins/dialog/src/index.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/index.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/api/types.js.map
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.d.ts
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.js
|
||||||
|
packages/app-cli/tests/support/plugins/editor_context_menu/src/index.js.map
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.d.ts
|
packages/app-cli/tests/support/plugins/events/api/index.d.ts
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.js
|
packages/app-cli/tests/support/plugins/events/api/index.js
|
||||||
packages/app-cli/tests/support/plugins/events/api/index.js.map
|
packages/app-cli/tests/support/plugins/events/api/index.js.map
|
||||||
@ -491,9 +500,9 @@ packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.js.map
|
|||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/styles/index.js.map
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/setupContextMenu.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useContextMenu.js.map
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.d.ts
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.d.ts
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js
|
||||||
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js.map
|
packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/utils/useScroll.js.map
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
2
packages/app-cli/tests/support/plugins/editor_context_menu/.gitignore
vendored
Normal file
2
packages/app-cli/tests/support/plugins/editor_context_menu/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dist/*
|
||||||
|
node_modules/
|
@ -0,0 +1,14 @@
|
|||||||
|
# Joplin Plugin
|
||||||
|
|
||||||
|
This is a template to create a new Joplin plugin.
|
||||||
|
|
||||||
|
The main two files you will want to look at are:
|
||||||
|
|
||||||
|
- `/src/index.ts`, which contains the entry point for the plugin source code.
|
||||||
|
- `/src/manifest.json`, which is the plugin manifest. It contains information such as the plugin a name, version, etc.
|
||||||
|
|
||||||
|
The plugin is built using webpack, which create the compiled code in `/dist`. The project is setup to use TypeScript, although you can change the configuration to use plain JavaScript.
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
To build the plugin, simply run `npm run dist`.
|
15
packages/app-cli/tests/support/plugins/editor_context_menu/api/Global.d.ts
vendored
Normal file
15
packages/app-cli/tests/support/plugins/editor_context_menu/api/Global.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import Plugin from '../Plugin';
|
||||||
|
import Joplin from './Joplin';
|
||||||
|
import Logger from '../../../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;
|
||||||
|
}
|
50
packages/app-cli/tests/support/plugins/editor_context_menu/api/Joplin.d.ts
vendored
Normal file
50
packages/app-cli/tests/support/plugins/editor_context_menu/api/Joplin.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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 '../../../Logger';
|
||||||
|
/**
|
||||||
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
61
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts
vendored
Normal file
61
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinCommands.d.ts
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
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/tree/dev/packages/app-cli/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:
|
||||||
|
*
|
||||||
|
* * [Main screen commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/gui/MainScreen/commands)
|
||||||
|
* * [Global commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/commands)
|
||||||
|
* * [Editor commands](https://github.com/laurent22/joplin/tree/dev/packages/app-desktop/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 command can take any number of arguments, and the supported
|
||||||
|
* arguments will vary based on the command. For custom commands, this
|
||||||
|
* is the `args` passed to the `execute()` function. For built-in
|
||||||
|
* commands, you can find the supported arguments by checking the links
|
||||||
|
* above.
|
||||||
|
*
|
||||||
|
* ```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', "SOME_FOLDER_ID");
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
execute(commandName: string, ...args: any[]): Promise<any | void>;
|
||||||
|
/**
|
||||||
|
* <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
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinData.d.ts
vendored
Normal file
47
packages/app-cli/tests/support/plugins/editor_context_menu/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/references/rest_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/tree/dev/packages/app-cli/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/references/rest_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
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinFilters.d.ts
vendored
Normal file
10
packages/app-cli/tests/support/plugins/editor_context_menu/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
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinInterop.d.ts
vendored
Normal file
17
packages/app-cli/tests/support/plugins/editor_context_menu/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/tree/dev/packages/app-cli/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/references/rest_api/
|
||||||
|
*/
|
||||||
|
export default class JoplinInterop {
|
||||||
|
registerExportModule(module: ExportModule): Promise<void>;
|
||||||
|
registerImportModule(module: ImportModule): Promise<void>;
|
||||||
|
}
|
38
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts
vendored
Normal file
38
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinPlugins.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import Plugin from '../Plugin';
|
||||||
|
import Logger from '../../../Logger';
|
||||||
|
import { ContentScriptType, 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>;
|
||||||
|
/**
|
||||||
|
* Registers a new content script. Unlike regular plugin code, which runs in a separate process, content scripts run within the main process code
|
||||||
|
* and thus allow improved performances and more customisations in specific cases. It can be used for example to load a Markdown or editor plugin.
|
||||||
|
*
|
||||||
|
* Note that registering a content script in itself will do nothing - it will only be loaded in specific cases by the relevant app modules
|
||||||
|
* (eg. the Markdown renderer or the code editor). So it is not a way to inject and run arbitrary code in the app, which for safety and performance reasons is not supported.
|
||||||
|
*
|
||||||
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/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`.
|
||||||
|
*/
|
||||||
|
registerContentScript(type: ContentScriptType, id: string, scriptPath: string): Promise<void>;
|
||||||
|
}
|
43
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinSettings.d.ts
vendored
Normal file
43
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinSettings.d.ts
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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/tree/dev/packages/app-cli/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>;
|
||||||
|
/**
|
||||||
|
* Gets a global setting value, including app-specific settings and those set by other plugins.
|
||||||
|
*
|
||||||
|
* The list of available settings is not documented yet, but can be found by looking at the source code:
|
||||||
|
*
|
||||||
|
* https://github.com/laurent22/joplin/blob/3539a452a359162c461d2849829d2d42973eab50/packages/app-mobile/lib/models/Setting.ts#L142
|
||||||
|
*/
|
||||||
|
globalValue(key: string): Promise<any>;
|
||||||
|
}
|
28
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViews.d.ts
vendored
Normal file
28
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViews.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import Plugin from '../Plugin';
|
||||||
|
import JoplinViewsDialogs from './JoplinViewsDialogs';
|
||||||
|
import JoplinViewsMenuItems from './JoplinViewsMenuItems';
|
||||||
|
import JoplinViewsMenus from './JoplinViewsMenus';
|
||||||
|
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 menus_;
|
||||||
|
private toolbarButtons_;
|
||||||
|
private implementation_;
|
||||||
|
constructor(implementation: any, plugin: Plugin, store: any);
|
||||||
|
get dialogs(): JoplinViewsDialogs;
|
||||||
|
get panels(): JoplinViewsPanels;
|
||||||
|
get menuItems(): JoplinViewsMenuItems;
|
||||||
|
get menus(): JoplinViewsMenus;
|
||||||
|
get toolbarButtons(): JoplinViewsToolbarButtons;
|
||||||
|
}
|
37
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts
vendored
Normal file
37
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsDialogs.d.ts
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import Plugin from '../Plugin';
|
||||||
|
import { ButtonSpec, ViewHandle, DialogResult } 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 an object indicating what button was clicked
|
||||||
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
|
*/
|
||||||
|
export default class JoplinViewsDialogs {
|
||||||
|
private store;
|
||||||
|
private plugin;
|
||||||
|
private implementation_;
|
||||||
|
constructor(implementation: any, plugin: Plugin, store: any);
|
||||||
|
private controller;
|
||||||
|
/**
|
||||||
|
* Creates a new dialog
|
||||||
|
*/
|
||||||
|
create(id: string): Promise<ViewHandle>;
|
||||||
|
/**
|
||||||
|
* Displays a message box with OK/Cancel buttons. Returns the button index that was clicked - "0" for OK and "1" for "Cancel"
|
||||||
|
*/
|
||||||
|
showMessageBox(message: string): Promise<number>;
|
||||||
|
/**
|
||||||
|
* 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<DialogResult>;
|
||||||
|
}
|
16
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsMenuItems.d.ts
vendored
Normal file
16
packages/app-cli/tests/support/plugins/editor_context_menu/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/tree/dev/packages/app-cli/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(id: string, commandName: string, location?: MenuItemLocation, options?: CreateMenuItemOptions): Promise<void>;
|
||||||
|
}
|
18
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsMenus.d.ts
vendored
Normal file
18
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsMenus.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { MenuItem, MenuItemLocation } from './types';
|
||||||
|
import Plugin from '../Plugin';
|
||||||
|
/**
|
||||||
|
* Allows creating menus.
|
||||||
|
*
|
||||||
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/menu)
|
||||||
|
*/
|
||||||
|
export default class JoplinViewsMenus {
|
||||||
|
private store;
|
||||||
|
private plugin;
|
||||||
|
constructor(plugin: Plugin, store: any);
|
||||||
|
private registerCommandAccelerators;
|
||||||
|
/**
|
||||||
|
* Creates a new menu from the provided menu items and place it at the given location. As of now, it is only possible to place the
|
||||||
|
* menu as a sub-menu of the application build-in menus.
|
||||||
|
*/
|
||||||
|
create(id: string, label: string, menuItems: MenuItem[], location?: MenuItemLocation): Promise<void>;
|
||||||
|
}
|
33
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsPanels.d.ts
vendored
Normal file
33
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsPanels.d.ts
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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/tree/dev/packages/app-cli/tests/support/plugins/toc)
|
||||||
|
*/
|
||||||
|
export default class JoplinViewsPanels {
|
||||||
|
private store;
|
||||||
|
private plugin;
|
||||||
|
constructor(plugin: Plugin, store: any);
|
||||||
|
private controller;
|
||||||
|
/**
|
||||||
|
* Creates a new panel
|
||||||
|
*/
|
||||||
|
create(id: string): 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
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinViewsToolbarButtons.d.ts
vendored
Normal file
16
packages/app-cli/tests/support/plugins/editor_context_menu/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/tree/dev/packages/app-cli/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(id: string, commandName: string, location: ToolbarButtonLocation): Promise<void>;
|
||||||
|
}
|
34
packages/app-cli/tests/support/plugins/editor_context_menu/api/JoplinWorkspace.d.ts
vendored
Normal file
34
packages/app-cli/tests/support/plugins/editor_context_menu/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/tree/dev/packages/app-cli/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;
|
@ -0,0 +1,370 @@
|
|||||||
|
// =================================================================
|
||||||
|
// Command API types
|
||||||
|
// =================================================================
|
||||||
|
|
||||||
|
export interface Command {
|
||||||
|
/**
|
||||||
|
* Name of command - must be globally unique
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Label to be displayed on menu items or keyboard shortcut editor for example.
|
||||||
|
* If it is missing, it's assumed it's a private command, to be called programmatically only.
|
||||||
|
* In that case the command will not appear in the shortcut editor or command panel, and logically
|
||||||
|
* should not be used as a menu item.
|
||||||
|
*/
|
||||||
|
label?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Icon to be used on toolbar buttons for example
|
||||||
|
*/
|
||||||
|
iconName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code to be ran when the command is executed. It may return a result.
|
||||||
|
*/
|
||||||
|
execute(...args: any[]): Promise<any | void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines whether the command should be enabled or disabled, which in turns affects
|
||||||
|
* the enabled state of any associated button or menu item.
|
||||||
|
*
|
||||||
|
* The condition should be expressed as a "when-clause" (as in Visual Studio Code). It's a simple boolean expression that evaluates to
|
||||||
|
* `true` or `false`. It supports the following operators:
|
||||||
|
*
|
||||||
|
* Operator | Symbol | Example
|
||||||
|
* -- | -- | --
|
||||||
|
* Equality | == | "editorType == markdown"
|
||||||
|
* Inequality | != | "currentScreen != config"
|
||||||
|
* Or | \|\| | "noteIsTodo \|\| noteTodoCompleted"
|
||||||
|
* And | && | "oneNoteSelected && !inConflictFolder"
|
||||||
|
*
|
||||||
|
* Currently the supported context variables aren't documented, but you can [find the list here](https://github.com/laurent22/joplin/blob/dev/packages/app-mobile/lib/services/commands/stateToWhenClauseContext.ts).
|
||||||
|
*
|
||||||
|
* Note: Commands are enabled by default unless you use this property.
|
||||||
|
*/
|
||||||
|
enabledCondition?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
// 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/tree/dev/packages/app-cli/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>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
// Menu types
|
||||||
|
// =================================================================
|
||||||
|
|
||||||
|
export interface CreateMenuItemOptions {
|
||||||
|
accelerator: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum MenuItemLocation {
|
||||||
|
File = 'file',
|
||||||
|
Edit = 'edit',
|
||||||
|
View = 'view',
|
||||||
|
Note = 'note',
|
||||||
|
Tools = 'tools',
|
||||||
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MenuItem {
|
||||||
|
/**
|
||||||
|
* Command that should be associated with the menu item. All menu item should
|
||||||
|
* have a command associated with them unless they are a sub-menu.
|
||||||
|
*/
|
||||||
|
commandName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accelerator associated with the menu item
|
||||||
|
*/
|
||||||
|
accelerator?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu items that should appear below this menu item. Allows creating a menu tree.
|
||||||
|
*/
|
||||||
|
submenu?: MenuItem[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu item label. If not specified, the command label will be used instead.
|
||||||
|
*/
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
// View API types
|
||||||
|
// =================================================================
|
||||||
|
|
||||||
|
export interface ButtonSpec {
|
||||||
|
id: ButtonId;
|
||||||
|
title?: string;
|
||||||
|
onClick?(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ButtonId = string;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: 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[];
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
// Plugins type
|
||||||
|
// =================================================================
|
||||||
|
|
||||||
|
export enum ContentScriptType {
|
||||||
|
/**
|
||||||
|
* Registers a new Markdown-It plugin, which should follow the template below.
|
||||||
|
*
|
||||||
|
* ```javascript
|
||||||
|
* module.exports = {
|
||||||
|
* default: function(context) {
|
||||||
|
* return {
|
||||||
|
* plugin: function(markdownIt, options) {
|
||||||
|
* // ...
|
||||||
|
* },
|
||||||
|
* assets: {
|
||||||
|
* // ...
|
||||||
|
* },
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* - The `context` argument 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.
|
||||||
|
*
|
||||||
|
* - The **required** `plugin` key 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/packages/app-mobile/lib/joplin-renderer/MdToHtml.ts), which contains a number of options, mostly useful for Joplin's internal code.
|
||||||
|
*
|
||||||
|
* - Using the **optional** `assets` key you may specify 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/packages/app-mobile/lib/joplin-renderer/MdToHtml/rules/mermaid.ts) to see how the data should be structured.
|
||||||
|
*
|
||||||
|
* To include a regular Markdown-It plugin, that doesn't make use of any Joplin-specific features, you would simply create a file such as this:
|
||||||
|
*
|
||||||
|
* ```javascript
|
||||||
|
* module.exports = {
|
||||||
|
* default: function(context) {
|
||||||
|
* return {
|
||||||
|
* plugin: require('markdown-it-toc-done-right');
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
MarkdownItPlugin = 'markdownItPlugin',
|
||||||
|
CodeMirrorPlugin = 'codeMirrorPlugin',
|
||||||
|
}
|
4544
packages/app-cli/tests/support/plugins/editor_context_menu/package-lock.json
generated
Normal file
4544
packages/app-cli/tests/support/plugins/editor_context_menu/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "joplin_plugin",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {
|
||||||
|
"dist": "webpack",
|
||||||
|
"postinstall": "npm run dist"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^14.0.14",
|
||||||
|
"copy-webpack-plugin": "^6.1.0",
|
||||||
|
"ts-loader": "^7.0.5",
|
||||||
|
"typescript": "^3.9.3",
|
||||||
|
"webpack": "^4.43.0",
|
||||||
|
"webpack-cli": "^3.3.11"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
import joplin from 'api';
|
||||||
|
import { MenuItemLocation } from 'api/types';
|
||||||
|
|
||||||
|
joplin.plugins.register({
|
||||||
|
onStart: async function() {
|
||||||
|
await joplin.commands.register({
|
||||||
|
name: 'sayHi',
|
||||||
|
label: 'Say Hi',
|
||||||
|
execute: async () => {
|
||||||
|
await joplin.commands.execute('replaceSelection', 'hi!');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await joplin.views.menuItems.create('myContextMenuItem', 'sayHi', MenuItemLocation.EditorContextMenu);
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"manifest_version": 1,
|
||||||
|
"name": "Editor Context Menu Demo",
|
||||||
|
"description": "",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "",
|
||||||
|
"homepage_url": ""
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./dist/",
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es2015",
|
||||||
|
"jsx": "react",
|
||||||
|
"allowJs": true,
|
||||||
|
"baseUrl": "."
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const CopyPlugin = require('copy-webpack-plugin');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
mode: 'production',
|
||||||
|
entry: './src/index.ts',
|
||||||
|
target: 'node',
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: 'ts-loader',
|
||||||
|
exclude: /node_modules/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
api: path.resolve(__dirname, 'api')
|
||||||
|
},
|
||||||
|
extensions: [ '.tsx', '.ts', '.js' ],
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: 'index.js',
|
||||||
|
path: path.resolve(__dirname, 'dist'),
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CopyPlugin({
|
||||||
|
patterns: [
|
||||||
|
{
|
||||||
|
from: "**/*",
|
||||||
|
context: path.resolve(__dirname, 'src'),
|
||||||
|
to: path.resolve(__dirname, 'dist'),
|
||||||
|
globOptions: {
|
||||||
|
ignore: [
|
||||||
|
'**/*.ts',
|
||||||
|
'**/*.tsx',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
19
packages/app-cli/tests/support/plugins/package.json
Normal file
19
packages/app-cli/tests/support/plugins/package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "test_plugin",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {
|
||||||
|
"dist": "webpack"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^14.0.14",
|
||||||
|
"copy-webpack-plugin": "^6.0.3",
|
||||||
|
"ts-loader": "^7.0.5",
|
||||||
|
"typescript": "^3.9.3",
|
||||||
|
"webpack": "^4.43.0",
|
||||||
|
"webpack-cli": "^3.3.11"
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -15,6 +15,7 @@ rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-l
|
|||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/multi_selection/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/multi_selection/"
|
||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/register_command/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/register_command/"
|
||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/selected_text/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/selected_text/"
|
||||||
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/editor_context_menu/"
|
||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/settings/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/settings/"
|
||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/toc/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/toc/"
|
||||||
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/withExternalModules/"
|
rsync -a --delete --exclude "src/" --exclude "package.json" --exclude "package-lock.json" --exclude "node_modules/" --exclude "dist/" "$TEMP_DIR/" "$SCRIPT_DIR/withExternalModules/"
|
||||||
|
@ -10,6 +10,18 @@ import JoplinSettings from './JoplinSettings';
|
|||||||
import Logger from '../../../Logger';
|
import Logger from '../../../Logger';
|
||||||
/**
|
/**
|
||||||
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
* This is the main entry point to the Joplin API. You can access various services using the provided accessors.
|
||||||
|
*
|
||||||
|
* **This is a beta API**
|
||||||
|
*
|
||||||
|
* Please note that the plugin API is relatively new and should be considered Beta state. Besides possible bugs, what it means is that there might be necessary breaking changes from one version to the next. Whenever such change is needed, best effort will be done to:
|
||||||
|
*
|
||||||
|
* - Maintain backward compatibility;
|
||||||
|
* - When possible, deprecate features instead of removing them;
|
||||||
|
* - Document breaking changes in the changelog;
|
||||||
|
*
|
||||||
|
* 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. There won't be any major API rewrite or architecture changes, but possibly small tweaks like function signature change, type change, etc.
|
||||||
|
*
|
||||||
|
* Eventually, the plugin API will be versioned to make this process smoother.
|
||||||
*/
|
*/
|
||||||
export default class Joplin {
|
export default class Joplin {
|
||||||
private data_;
|
private data_;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import Plugin from '../Plugin';
|
import Plugin from '../Plugin';
|
||||||
import { ButtonSpec, ViewHandle, ButtonId } from './types';
|
import { ButtonSpec, ViewHandle, DialogResult } 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.
|
* 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
|
* 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 an object indicating what button was clicked
|
||||||
* 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.
|
* on. If your HTML content included one or more form, a `formData` object will also be included with the key/value for each form.
|
||||||
|
* 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/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
* [View the demo plugin](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/dialog)
|
||||||
*/
|
*/
|
||||||
@ -32,5 +33,5 @@ export default class JoplinViewsDialogs {
|
|||||||
/**
|
/**
|
||||||
* Opens the dialog
|
* Opens the dialog
|
||||||
*/
|
*/
|
||||||
open(handle: ViewHandle): Promise<ButtonId>;
|
open(handle: ViewHandle): Promise<DialogResult>;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,12 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
/*
|
||||||
|
* Deprecated - do not use - same as NoteListContext
|
||||||
|
*/
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
@ -261,6 +266,11 @@ export interface EditorCommand {
|
|||||||
value?: any;
|
value?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DialogResult {
|
||||||
|
id: ButtonId;
|
||||||
|
formData?: any;
|
||||||
|
}
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
// Settings types
|
// Settings types
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -697,7 +697,7 @@ function useMenu(props: Props) {
|
|||||||
|
|
||||||
for (const view of props.pluginMenuItems) {
|
for (const view of props.pluginMenuItems) {
|
||||||
const location: MenuItemLocation = view.location;
|
const location: MenuItemLocation = view.location;
|
||||||
if (location === MenuItemLocation.Context) continue;
|
if ([MenuItemLocation.Context, MenuItemLocation.EditorContextMenu, MenuItemLocation.NoteListContextMenu].includes(location)) continue;
|
||||||
|
|
||||||
const itemParent = rootMenus[location];
|
const itemParent = rootMenus[location];
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ function useMenu(props: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const view of props.pluginMenus) {
|
for (const view of props.pluginMenus) {
|
||||||
if (view.location === MenuItemLocation.Context) continue;
|
if ([MenuItemLocation.Context, MenuItemLocation.EditorContextMenu, MenuItemLocation.NoteListContextMenu].includes(view.location)) continue;
|
||||||
const itemParent = rootMenus[view.location];
|
const itemParent = rootMenus[view.location];
|
||||||
|
|
||||||
if (!itemParent) {
|
if (!itemParent) {
|
||||||
|
@ -17,6 +17,10 @@ import { _ } from '@joplin/lib/locale';
|
|||||||
import bridge from '../../../../services/bridge';
|
import bridge from '../../../../services/bridge';
|
||||||
import markdownUtils from '@joplin/lib/markdownUtils';
|
import markdownUtils from '@joplin/lib/markdownUtils';
|
||||||
import shim from '@joplin/lib/shim';
|
import shim from '@joplin/lib/shim';
|
||||||
|
import { MenuItemLocation } from '@joplin/lib/services/plugins/api/types';
|
||||||
|
import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
|
||||||
|
import CommandService from '@joplin/lib/services/CommandService';
|
||||||
|
import { themeStyle } from '@joplin/lib/theme';
|
||||||
|
|
||||||
const Note = require('@joplin/lib/models/Note.js');
|
const Note = require('@joplin/lib/models/Note.js');
|
||||||
const { clipboard } = require('electron');
|
const { clipboard } = require('electron');
|
||||||
@ -25,7 +29,8 @@ const Menu = bridge().Menu;
|
|||||||
const MenuItem = bridge().MenuItem;
|
const MenuItem = bridge().MenuItem;
|
||||||
const { reg } = require('@joplin/lib/registry.js');
|
const { reg } = require('@joplin/lib/registry.js');
|
||||||
const dialogs = require('../../../dialogs');
|
const dialogs = require('../../../dialogs');
|
||||||
const { themeStyle } = require('@joplin/lib/theme');
|
|
||||||
|
const menuUtils = new MenuUtils(CommandService.instance());
|
||||||
|
|
||||||
function markupRenderOptions(override: any = null) {
|
function markupRenderOptions(override: any = null) {
|
||||||
return { ...override };
|
return { ...override };
|
||||||
@ -290,8 +295,12 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
menuUtils.pluginContextMenuItems(props.plugins, MenuItemLocation.EditorContextMenu).forEach((item: any) => {
|
||||||
|
menu.append(new MenuItem(item));
|
||||||
|
});
|
||||||
|
|
||||||
menu.popup(bridge().window());
|
menu.popup(bridge().window());
|
||||||
}, [props.content, editorCutText, editorPasteText, editorCopyText, onEditorPaste]);
|
}, [props.content, editorCutText, editorPasteText, editorCopyText, onEditorPaste, props.plugins]);
|
||||||
|
|
||||||
const loadScript = async (script: any) => {
|
const loadScript = async (script: any) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -643,11 +652,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
|
|||||||
return (
|
return (
|
||||||
<div style={styles.root} ref={rootRef}>
|
<div style={styles.root} ref={rootRef}>
|
||||||
<div style={styles.rowToolbar}>
|
<div style={styles.rowToolbar}>
|
||||||
<Toolbar
|
<Toolbar themeId={props.themeId} />
|
||||||
themeId={props.themeId}
|
|
||||||
// dispatch={props.dispatch}
|
|
||||||
// plugins={props.plugins}
|
|
||||||
/>
|
|
||||||
{props.noteToolbar}
|
{props.noteToolbar}
|
||||||
</div>
|
</div>
|
||||||
<div style={styles.rowEditorViewer}>
|
<div style={styles.rowEditorViewer}>
|
||||||
|
@ -11,13 +11,13 @@ import ToolbarButton from '../../../../gui/ToolbarButton/ToolbarButton';
|
|||||||
import usePluginServiceRegistration from '../../utils/usePluginServiceRegistration';
|
import usePluginServiceRegistration from '../../utils/usePluginServiceRegistration';
|
||||||
import { utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
|
import { utils as pluginUtils } from '@joplin/lib/services/plugins/reducer';
|
||||||
import { _, closestSupportedLocale } from '@joplin/lib/locale';
|
import { _, closestSupportedLocale } from '@joplin/lib/locale';
|
||||||
import setupContextMenu from './utils/setupContextMenu';
|
import useContextMenu from './utils/useContextMenu';
|
||||||
|
import shim from '@joplin/lib/shim';
|
||||||
|
|
||||||
const { MarkupToHtml } = require('@joplin/renderer');
|
const { MarkupToHtml } = require('@joplin/renderer');
|
||||||
const taboverride = require('taboverride');
|
const taboverride = require('taboverride');
|
||||||
const { reg } = require('@joplin/lib/registry.js');
|
const { reg } = require('@joplin/lib/registry.js');
|
||||||
const BaseItem = require('@joplin/lib/models/BaseItem');
|
const BaseItem = require('@joplin/lib/models/BaseItem');
|
||||||
const shim = require('@joplin/lib/shim').default;
|
|
||||||
const { themeStyle } = require('@joplin/lib/theme');
|
const { themeStyle } = require('@joplin/lib/theme');
|
||||||
const { clipboard } = require('electron');
|
const { clipboard } = require('electron');
|
||||||
const supportedLocales = require('./supportedLocales');
|
const supportedLocales = require('./supportedLocales');
|
||||||
@ -161,6 +161,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
|||||||
const { scrollToPercent } = useScroll({ editor, onScroll: props.onScroll });
|
const { scrollToPercent } = useScroll({ editor, onScroll: props.onScroll });
|
||||||
|
|
||||||
usePluginServiceRegistration(ref);
|
usePluginServiceRegistration(ref);
|
||||||
|
useContextMenu(editor, props.plugins);
|
||||||
|
|
||||||
const dispatchDidUpdate = (editor: any) => {
|
const dispatchDidUpdate = (editor: any) => {
|
||||||
if (dispatchDidUpdateIID_) shim.clearTimeout(dispatchDidUpdateIID_);
|
if (dispatchDidUpdateIID_) shim.clearTimeout(dispatchDidUpdateIID_);
|
||||||
@ -668,7 +669,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setupContextMenu(editor);
|
// setupContextMenu(editor);
|
||||||
|
|
||||||
// TODO: remove event on unmount?
|
// TODO: remove event on unmount?
|
||||||
editor.on('DblClick', (event: any) => {
|
editor.on('DblClick', (event: any) => {
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
import SpellCheckerService from '@joplin/lib/services/spellChecker/SpellCheckerService';
|
|
||||||
import bridge from '../../../../../services/bridge';
|
|
||||||
import { menuItems, ContextMenuOptions, ContextMenuItemType } from '../../../utils/contextMenu';
|
|
||||||
const Resource = require('@joplin/lib/models/Resource');
|
|
||||||
|
|
||||||
// x and y are the absolute coordinates, as returned by the context-menu event
|
|
||||||
// handler on the webContent. This function will return null if the point is
|
|
||||||
// not within the TinyMCE editor.
|
|
||||||
function contextMenuElement(editor: any, x: number, y: number) {
|
|
||||||
if (!editor || !editor.getDoc()) return null;
|
|
||||||
|
|
||||||
const iframes = document.getElementsByClassName('tox-edit-area__iframe');
|
|
||||||
if (!iframes.length) return null;
|
|
||||||
|
|
||||||
const iframeRect = iframes[0].getBoundingClientRect();
|
|
||||||
|
|
||||||
if (iframeRect.x < x && iframeRect.y < y && iframeRect.right > x && iframeRect.bottom > y) {
|
|
||||||
const relativeX = x - iframeRect.x;
|
|
||||||
const relativeY = y - iframeRect.y;
|
|
||||||
return editor.getDoc().elementFromPoint(relativeX, relativeY);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ContextMenuActionOptions {
|
|
||||||
current: ContextMenuOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
const contextMenuActionOptions: ContextMenuActionOptions = { current: null };
|
|
||||||
|
|
||||||
export default function(editor: any) {
|
|
||||||
const contextMenuItems = menuItems();
|
|
||||||
|
|
||||||
bridge().window().webContents.on('context-menu', (_event: any, params: any) => {
|
|
||||||
const element = contextMenuElement(editor, params.x, params.y);
|
|
||||||
if (!element) return;
|
|
||||||
|
|
||||||
let itemType: ContextMenuItemType = ContextMenuItemType.None;
|
|
||||||
let resourceId = '';
|
|
||||||
let linkToCopy = null;
|
|
||||||
|
|
||||||
if (element.nodeName === 'IMG') {
|
|
||||||
itemType = ContextMenuItemType.Image;
|
|
||||||
resourceId = Resource.pathToId(element.src);
|
|
||||||
} else if (element.nodeName === 'A') {
|
|
||||||
resourceId = Resource.pathToId(element.href);
|
|
||||||
itemType = resourceId ? ContextMenuItemType.Resource : ContextMenuItemType.Link;
|
|
||||||
linkToCopy = element.getAttribute('href') || '';
|
|
||||||
} else {
|
|
||||||
itemType = ContextMenuItemType.Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMenuActionOptions.current = {
|
|
||||||
itemType,
|
|
||||||
resourceId,
|
|
||||||
linkToCopy,
|
|
||||||
textToCopy: null,
|
|
||||||
htmlToCopy: editor.selection ? editor.selection.getContent() : '',
|
|
||||||
insertContent: (content: string) => {
|
|
||||||
editor.insertContent(content);
|
|
||||||
},
|
|
||||||
isReadOnly: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const template = [];
|
|
||||||
|
|
||||||
for (const itemName in contextMenuItems) {
|
|
||||||
const item = contextMenuItems[itemName];
|
|
||||||
|
|
||||||
if (!item.isActive(itemType, contextMenuActionOptions.current)) continue;
|
|
||||||
|
|
||||||
template.push({
|
|
||||||
label: item.label,
|
|
||||||
click: () => {
|
|
||||||
item.onAction(contextMenuActionOptions.current);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const spellCheckerMenuItems = SpellCheckerService.instance().contextMenuItems(params.misspelledWord, params.dictionarySuggestions);
|
|
||||||
|
|
||||||
for (const item of spellCheckerMenuItems) {
|
|
||||||
template.push(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
const menu = bridge().Menu.buildFromTemplate(template);
|
|
||||||
menu.popup(bridge().window());
|
|
||||||
});
|
|
||||||
}
|
|
@ -0,0 +1,112 @@
|
|||||||
|
import { MenuItemLocation } from '@joplin/lib/services/plugins/api/types';
|
||||||
|
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
||||||
|
import SpellCheckerService from '@joplin/lib/services/spellChecker/SpellCheckerService';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import bridge from '../../../../../services/bridge';
|
||||||
|
import { menuItems, ContextMenuOptions, ContextMenuItemType } from '../../../utils/contextMenu';
|
||||||
|
import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
|
||||||
|
import CommandService from '@joplin/lib/services/CommandService';
|
||||||
|
|
||||||
|
const Resource = require('@joplin/lib/models/Resource');
|
||||||
|
|
||||||
|
const menuUtils = new MenuUtils(CommandService.instance());
|
||||||
|
|
||||||
|
// x and y are the absolute coordinates, as returned by the context-menu event
|
||||||
|
// handler on the webContent. This function will return null if the point is
|
||||||
|
// not within the TinyMCE editor.
|
||||||
|
function contextMenuElement(editor: any, x: number, y: number) {
|
||||||
|
if (!editor || !editor.getDoc()) return null;
|
||||||
|
|
||||||
|
const iframes = document.getElementsByClassName('tox-edit-area__iframe');
|
||||||
|
if (!iframes.length) return null;
|
||||||
|
|
||||||
|
const iframeRect = iframes[0].getBoundingClientRect();
|
||||||
|
|
||||||
|
if (iframeRect.x < x && iframeRect.y < y && iframeRect.right > x && iframeRect.bottom > y) {
|
||||||
|
const relativeX = x - iframeRect.x;
|
||||||
|
const relativeY = y - iframeRect.y;
|
||||||
|
return editor.getDoc().elementFromPoint(relativeX, relativeY);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ContextMenuActionOptions {
|
||||||
|
current: ContextMenuOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
const contextMenuActionOptions: ContextMenuActionOptions = { current: null };
|
||||||
|
|
||||||
|
export default function(editor: any, plugins: PluginStates) {
|
||||||
|
useEffect(() => {
|
||||||
|
if (!editor) return () => {};
|
||||||
|
|
||||||
|
const contextMenuItems = menuItems();
|
||||||
|
|
||||||
|
function onContextMenu(_event: any, params: any) {
|
||||||
|
const element = contextMenuElement(editor, params.x, params.y);
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
let itemType: ContextMenuItemType = ContextMenuItemType.None;
|
||||||
|
let resourceId = '';
|
||||||
|
let linkToCopy = null;
|
||||||
|
|
||||||
|
if (element.nodeName === 'IMG') {
|
||||||
|
itemType = ContextMenuItemType.Image;
|
||||||
|
resourceId = Resource.pathToId(element.src);
|
||||||
|
} else if (element.nodeName === 'A') {
|
||||||
|
resourceId = Resource.pathToId(element.href);
|
||||||
|
itemType = resourceId ? ContextMenuItemType.Resource : ContextMenuItemType.Link;
|
||||||
|
linkToCopy = element.getAttribute('href') || '';
|
||||||
|
} else {
|
||||||
|
itemType = ContextMenuItemType.Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMenuActionOptions.current = {
|
||||||
|
itemType,
|
||||||
|
resourceId,
|
||||||
|
linkToCopy,
|
||||||
|
textToCopy: null,
|
||||||
|
htmlToCopy: editor.selection ? editor.selection.getContent() : '',
|
||||||
|
insertContent: (content: string) => {
|
||||||
|
editor.insertContent(content);
|
||||||
|
},
|
||||||
|
isReadOnly: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
let template = [];
|
||||||
|
|
||||||
|
for (const itemName in contextMenuItems) {
|
||||||
|
const item = contextMenuItems[itemName];
|
||||||
|
|
||||||
|
if (!item.isActive(itemType, contextMenuActionOptions.current)) continue;
|
||||||
|
|
||||||
|
template.push({
|
||||||
|
label: item.label,
|
||||||
|
click: () => {
|
||||||
|
item.onAction(contextMenuActionOptions.current);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const spellCheckerMenuItems = SpellCheckerService.instance().contextMenuItems(params.misspelledWord, params.dictionarySuggestions);
|
||||||
|
|
||||||
|
for (const item of spellCheckerMenuItems) {
|
||||||
|
template.push(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
template = template.concat(menuUtils.pluginContextMenuItems(plugins, MenuItemLocation.EditorContextMenu));
|
||||||
|
|
||||||
|
const menu = bridge().Menu.buildFromTemplate(template);
|
||||||
|
menu.popup(bridge().window());
|
||||||
|
}
|
||||||
|
|
||||||
|
bridge().window().webContents.on('context-menu', onContextMenu);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (bridge().window()?.webContents?.off) {
|
||||||
|
bridge().window().webContents.off('context-menu', onContextMenu);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [editor, plugins]);
|
||||||
|
}
|
@ -230,7 +230,16 @@ function NoteEditor(props: NoteEditorProps) {
|
|||||||
}
|
}
|
||||||
}, [handleProvisionalFlag, formNote, isNewNote, titleHasBeenManuallyChanged]);
|
}, [handleProvisionalFlag, formNote, isNewNote, titleHasBeenManuallyChanged]);
|
||||||
|
|
||||||
useWindowCommandHandler({ dispatch: props.dispatch, formNote, setShowLocalSearch, noteSearchBarRef, editorRef, titleInputRef, saveNoteAndWait });
|
useWindowCommandHandler({
|
||||||
|
dispatch: props.dispatch,
|
||||||
|
formNote,
|
||||||
|
setShowLocalSearch,
|
||||||
|
noteSearchBarRef,
|
||||||
|
editorRef,
|
||||||
|
titleInputRef,
|
||||||
|
saveNoteAndWait,
|
||||||
|
setFormNote,
|
||||||
|
});
|
||||||
|
|
||||||
const onDrop = useDropHandler({ editorRef });
|
const onDrop = useDropHandler({ editorRef });
|
||||||
|
|
||||||
|
@ -89,6 +89,9 @@ const declarations: CommandDeclaration[] = [
|
|||||||
{
|
{
|
||||||
name: 'replaceSelection',
|
name: 'replaceSelection',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'editorSetText',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default declarations;
|
export default declarations;
|
||||||
|
@ -19,9 +19,10 @@ interface HookDependencies {
|
|||||||
editorRef: any;
|
editorRef: any;
|
||||||
titleInputRef: any;
|
titleInputRef: any;
|
||||||
saveNoteAndWait: Function;
|
saveNoteAndWait: Function;
|
||||||
|
setFormNote: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any): CommandRuntime {
|
function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any, setFormNote: Function): CommandRuntime {
|
||||||
return {
|
return {
|
||||||
execute: async (_context: CommandContext, ...args: any[]) => {
|
execute: async (_context: CommandContext, ...args: any[]) => {
|
||||||
if (!editorRef.current.execCommand) {
|
if (!editorRef.current.execCommand) {
|
||||||
@ -39,6 +40,10 @@ function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any):
|
|||||||
type: ScrollOptionTypes.Hash,
|
type: ScrollOptionTypes.Hash,
|
||||||
value: args[0],
|
value: args[0],
|
||||||
});
|
});
|
||||||
|
} else if (declaration.name === 'editorSetText') {
|
||||||
|
setFormNote((prev: FormNote) => {
|
||||||
|
return { ...prev, body: args[0] };
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return editorRef.current.execCommand({
|
return editorRef.current.execCommand({
|
||||||
name: declaration.name,
|
name: declaration.name,
|
||||||
@ -51,11 +56,11 @@ function editorCommandRuntime(declaration: CommandDeclaration, editorRef: any):
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function useWindowCommandHandler(dependencies: HookDependencies) {
|
export default function useWindowCommandHandler(dependencies: HookDependencies) {
|
||||||
const { setShowLocalSearch, noteSearchBarRef, editorRef, titleInputRef } = dependencies;
|
const { setShowLocalSearch, noteSearchBarRef, editorRef, titleInputRef, setFormNote } = dependencies;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
for (const declaration of editorCommandDeclarations) {
|
for (const declaration of editorCommandDeclarations) {
|
||||||
CommandService.instance().registerRuntime(declaration.name, editorCommandRuntime(declaration, editorRef));
|
CommandService.instance().registerRuntime(declaration.name, editorCommandRuntime(declaration, editorRef, setFormNote));
|
||||||
}
|
}
|
||||||
|
|
||||||
const dependencies = {
|
const dependencies = {
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
'use strict';
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
exports.itemSize = void 0;
|
||||||
|
const react_1 = require('react');
|
||||||
|
const ResizableLayout_1 = require('../ResizableLayout');
|
||||||
|
function itemSize(item, sizes) {
|
||||||
|
return {
|
||||||
|
width: 'width' in item ? item.width : sizes[item.key].width,
|
||||||
|
height: 'height' in item ? item.height : sizes[item.key].height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.itemSize = itemSize;
|
||||||
|
function calculateChildrenSizes(item, sizes) {
|
||||||
|
if (!item.children) { return sizes; }
|
||||||
|
const parentSize = itemSize(item, sizes);
|
||||||
|
const remainingSize = {
|
||||||
|
width: parentSize.width,
|
||||||
|
height: parentSize.height,
|
||||||
|
};
|
||||||
|
const noWidthChildren = [];
|
||||||
|
const noHeightChildren = [];
|
||||||
|
for (const child of item.children) {
|
||||||
|
let w = 'width' in child ? child.width : null;
|
||||||
|
let h = 'height' in child ? child.height : null;
|
||||||
|
if (child.visible === false) {
|
||||||
|
w = 0;
|
||||||
|
h = 0;
|
||||||
|
}
|
||||||
|
if (item.resizableRight) { w -= ResizableLayout_1.dragBarThickness; }
|
||||||
|
if (item.resizableBottom) { h -= ResizableLayout_1.dragBarThickness; }
|
||||||
|
sizes[child.key] = { width: w, height: h };
|
||||||
|
if (w !== null) { remainingSize.width -= w; }
|
||||||
|
if (h !== null) { remainingSize.height -= h; }
|
||||||
|
if (w === null) { noWidthChildren.push(child); }
|
||||||
|
if (h === null) { noHeightChildren.push(child); }
|
||||||
|
}
|
||||||
|
if (noWidthChildren.length) {
|
||||||
|
const w = item.direction === 'row' ? remainingSize.width / noWidthChildren.length : parentSize.width;
|
||||||
|
for (const child of noWidthChildren) {
|
||||||
|
sizes[child.key].width = w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noHeightChildren.length) {
|
||||||
|
const h = item.direction === 'column' ? remainingSize.height / noHeightChildren.length : parentSize.height;
|
||||||
|
for (const child of noHeightChildren) {
|
||||||
|
sizes[child.key].height = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const child of item.children) {
|
||||||
|
const childrenSizes = calculateChildrenSizes(child, sizes);
|
||||||
|
sizes = Object.assign(Object.assign({}, sizes), childrenSizes);
|
||||||
|
}
|
||||||
|
return sizes;
|
||||||
|
}
|
||||||
|
function useLayoutItemSizes(layout) {
|
||||||
|
return react_1.useMemo(() => {
|
||||||
|
let sizes = {};
|
||||||
|
if (!('width' in layout) || !('height' in layout)) { throw new Error('width and height are required on layout root'); }
|
||||||
|
sizes[layout.key] = {
|
||||||
|
width: layout.width,
|
||||||
|
height: layout.height,
|
||||||
|
};
|
||||||
|
sizes = calculateChildrenSizes(layout, sizes);
|
||||||
|
return sizes;
|
||||||
|
}, [layout]);
|
||||||
|
}
|
||||||
|
exports.default = useLayoutItemSizes;
|
||||||
|
// # sourceMappingURL=useLayoutItemSizes.js.map
|
@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
const react_1 = require('react');
|
||||||
|
const debounce = require('debounce');
|
||||||
|
function useWindowResizeEvent(eventEmitter) {
|
||||||
|
react_1.useEffect(() => {
|
||||||
|
const window_resize = debounce(() => {
|
||||||
|
eventEmitter.current.emit('resize');
|
||||||
|
}, 500);
|
||||||
|
window.addEventListener('resize', window_resize);
|
||||||
|
return () => {
|
||||||
|
window_resize.clear();
|
||||||
|
window.removeEventListener('resize', window_resize);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
exports.default = useWindowResizeEvent;
|
||||||
|
// # sourceMappingURL=useWindowResizeEvent.js.map
|
@ -179,7 +179,7 @@ export default class NoteListUtils {
|
|||||||
|
|
||||||
for (const info of pluginViewInfos) {
|
for (const info of pluginViewInfos) {
|
||||||
const location = info.view.location;
|
const location = info.view.location;
|
||||||
if (location !== MenuItemLocation.Context) continue;
|
if (location !== MenuItemLocation.Context && location !== MenuItemLocation.NoteListContextMenu) continue;
|
||||||
|
|
||||||
menu.append(
|
menu.append(
|
||||||
new MenuItem(menuUtils.commandToStatefulMenuItem(info.view.commandName))
|
new MenuItem(menuUtils.commandToStatefulMenuItem(info.view.commandName))
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
# It could be used to develop plugins too.
|
# It could be used to develop plugins too.
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
PLUGIN_PATH="$SCRIPT_DIR/../app-cli/tests/support/plugins/dialog"
|
PLUGIN_PATH="$SCRIPT_DIR/../app-cli/tests/support/plugins/editor_context_menu"
|
||||||
npm i --prefix="$PLUGIN_PATH" && npm start -- --dev-plugins "$PLUGIN_PATH"
|
npm i --prefix="$PLUGIN_PATH" && npm start -- --dev-plugins "$PLUGIN_PATH"
|
@ -1,5 +1,7 @@
|
|||||||
|
import { MenuItemLocation } from '../../plugin_types/services/plugins/api/types';
|
||||||
import CommandService from '../CommandService';
|
import CommandService from '../CommandService';
|
||||||
import KeymapService from '../KeymapService';
|
import KeymapService from '../KeymapService';
|
||||||
|
import { PluginStates, utils as pluginUtils } from '../plugins/reducer';
|
||||||
import propsHaveChanged from './propsHaveChanged';
|
import propsHaveChanged from './propsHaveChanged';
|
||||||
const { createSelectorCreator, defaultMemoize } = require('reselect');
|
const { createSelectorCreator, defaultMemoize } = require('reselect');
|
||||||
const { createCachedSelector } = require('re-reselect');
|
const { createCachedSelector } = require('re-reselect');
|
||||||
@ -127,4 +129,18 @@ export default class MenuUtils {
|
|||||||
return selectObjectByCommands({ array: output }, commandNames);
|
return selectObjectByCommands({ array: output }, commandNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public pluginContextMenuItems(plugins: PluginStates, location: MenuItemLocation): MenuItem[] {
|
||||||
|
const output: MenuItem[] = [];
|
||||||
|
const pluginViewInfos = pluginUtils.viewInfosByType(plugins, 'menuItem');
|
||||||
|
|
||||||
|
for (const info of pluginViewInfos) {
|
||||||
|
if (info.view.location !== location) continue;
|
||||||
|
output.push(this.commandToStatefulMenuItem(info.view.commandName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output.length) output.splice(0, 0, { type: 'separator' } as any);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,10 @@ export enum MenuItemLocation {
|
|||||||
Note = 'note',
|
Note = 'note',
|
||||||
Tools = 'tools',
|
Tools = 'tools',
|
||||||
Help = 'help',
|
Help = 'help',
|
||||||
|
// Deprecated - do not use - same as NoteListContext
|
||||||
Context = 'context',
|
Context = 'context',
|
||||||
|
NoteListContextMenu = 'noteListContextMenu',
|
||||||
|
EditorContextMenu = 'editorContextMenu',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MenuItem {
|
export interface MenuItem {
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"**/node_modules",
|
"**/node_modules",
|
||||||
|
"**/plugin_types",
|
||||||
],
|
],
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user