From 13feb30f3ff9b913670a5fe7c8a9c1907d2c1740 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Fri, 4 Jul 2025 12:03:11 -0500 Subject: Initial commit --- api/JoplinViewsPanels.d.ts | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 api/JoplinViewsPanels.d.ts (limited to 'api/JoplinViewsPanels.d.ts') diff --git a/api/JoplinViewsPanels.d.ts b/api/JoplinViewsPanels.d.ts new file mode 100644 index 0000000..ba96c8a --- /dev/null +++ b/api/JoplinViewsPanels.d.ts @@ -0,0 +1,84 @@ +import Plugin from '../Plugin'; +import { ViewHandle } from './types'; +/** + * Allows creating and managing view panels. View panels allow displaying any HTML + * content (within a webview) and updating 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. + * + * On desktop, view panels currently are displayed at the right of the sidebar, though can + * be moved with "View" > "Change application layout". + * + * On mobile, view panels are shown in a tabbed dialog that can be opened using a + * toolbar button. + * + * [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; + /** + * Sets the panel webview HTML + */ + setHtml(handle: ViewHandle, html: string): Promise; + /** + * Adds and loads a new JS or CSS files into the panel. + */ + addScript(handle: ViewHandle, scriptPath: string): Promise; + /** + * Called when a message is sent from the webview (using postMessage). + * + * To post a message from the webview to the plugin use: + * + * ```javascript + * const response = await webviewApi.postMessage(message); + * ``` + * + * - `message` can be any JavaScript object, string or number + * - `response` is whatever was returned by the `onMessage` handler + * + * Using this mechanism, you can have two-way communication between the + * plugin and webview. + * + * See the [postMessage + * demo](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins/post_messages) for more details. + * + */ + onMessage(handle: ViewHandle, callback: Function): Promise; + /** + * Sends a message to the webview. + * + * The webview must have registered a message handler prior, otherwise the message is ignored. Use; + * + * ```javascript + * webviewApi.onMessage((message) => { ... }); + * ``` + * + * - `message` can be any JavaScript object, string or number + * + * The view API may have only one onMessage handler defined. + * This method is fire and forget so no response is returned. + * + * It is particularly useful when the webview needs to react to events emitted by the plugin or the joplin api. + */ + postMessage(handle: ViewHandle, message: any): void; + /** + * Shows the panel + */ + show(handle: ViewHandle, show?: boolean): Promise; + /** + * Hides the panel + */ + hide(handle: ViewHandle): Promise; + /** + * Tells whether the panel is visible or not + */ + visible(handle: ViewHandle): Promise; + isActive(handle: ViewHandle): Promise; +} -- cgit v1.2.3