Options
All
  • Public
  • Public/Protected
  • All
Menu

joplin.views.panels

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

Index

Methods

addScript

  • addScript(handle: ViewHandle, scriptPath: string): Promise<void>
  • Adds and loads a new JS or CSS files into the panel.

    Parameters

create

  • Creates a new panel

    Parameters

    • id: string

hide

isActive

onMessage

  • onMessage(handle: ViewHandle, callback: Function): Promise<void>
  • Called when a message is sent from the webview (using postMessage).

    To post a message from the webview to the plugin use:

    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 for more details.

    Parameters

postMessage

  • postMessage(handle: ViewHandle, message: any): void
  • Sends a message to the webview.

    The webview must have registered a message handler prior, otherwise the message is ignored. Use;

    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.

    Parameters

setHtml

  • setHtml(handle: ViewHandle, html: string): Promise<string>
  • Sets the panel webview HTML

    Parameters

show

  • show(handle: ViewHandle, show?: boolean): Promise<void>
  • Shows the panel

    Parameters

    • handle: ViewHandle
    • Default value show: boolean = true

visible

  • Tells whether the panel is visible or not

    Parameters