Environment

The top-level object representing the Inkdrop application in the renderer process — packages, themes, menus, the local database, and the window. Your plugin receives it as the first argument of activate(env).

import type { Environment, IInkdropPlugin } from '@inkdropapp/types'

class YourPlugin implements IInkdropPlugin {
  activate(env: Environment) {
    env.notifications.addInfo(`Running Inkdrop ${env.appVersion}`)
  }
  deactivate(env: Environment) {
    env.notifications.addInfo('Your plugin is deactivated')
  }
}

export default new YourPlugin()

The same instance is also exposed globally as inkdrop, but that global is deprecated and will be sandboxed away in a future release, so take env from activate() instead.


Properties

  • Name
    appVersion
    Type
    string
    Description

    The application version string.

  • Name
    clipboard
    Type
    object
    Description

    The system clipboard proxy. See IPCClipboard for the available methods.

  • Name
    commands
    Type
    object
    Description

    A CommandRegistry instance.

  • Name
    components
    Type
    object
    Description

    A ComponentManager instance.

  • Name
    config
    Type
    object
    Description

    A Config instance.

  • Name
    contextMenu
    Type
    object
    Description

    A ContextMenuManager instance.

  • Name
    devMode
    Type
    boolean
    Description

    Boolean, true if Development Mode is enabled, false if disabled.

  • Name
    dialog
    Type
    object
    Description

    The native dialog box proxy. See IPCDialog for the available methods.

  • Name
    keymaps
    Type
    object
    Description

    A KeymapManager instance.

  • Name
    layouts
    Type
    object
    Description

    A LayoutManager instance.

  • Name
    localDB
    Type
    object
    Description

    The local database proxy, with notes, books, tags, files and utils sub-objects plus change events. See Accessing the local database.

  • Name
    markdownRenderer
    Type
    object
    Description

    A MarkdownRenderer instance.

  • Name
    menu
    Type
    object
    Description

    A MenuManager instance.

  • Name
    notifications
    Type
    object
    Description

    A NotificationManager instance.

  • Name
    packages
    Type
    object
    Description

    A PackageManager instance.

  • Name
    resourcePath
    Type
    string
    Description

    A path to the app's bundled resource directory. For example, usually "/Applications/Inkdrop.app/Contents/Resources/app.asar" on macOS.

  • Name
    store
    Type
    object
    Description

    The Redux store holding the app state. Use store.getState() to read it and store.dispatch() to run an action — see Getting & modifying the app state.

  • Name
    styles
    Type
    object
    Description

    A StyleManager instance.

  • Name
    telescope
    Type
    object
    Description

    A TelescopeManager instance.

  • Name
    themes
    Type
    object
    Description

    A ThemeManager instance.

  • Name
    userDataPath
    Type
    string
    Description

    The path to the user's data directory.

  • Name
    window
    Type
    object
    Description

    The IPC proxy for the current window.


onEditorLoad(callback)

Editor Load Event

Invoke the given callback when the editor has been loaded.

Parameters

  • Name
    callback(editor)
    Type
    function
    Required
    Description

    Function to be called when the editor loads, where editor is the EditorView instance that was loaded.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.


onEditorUnload(callback)

Editor Unload Event

Invoke the given callback when the editor has been unloaded.

Parameters

  • Name
    callback()
    Type
    function
    Required
    Description

    Function to be called when the editor unloads.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.


ensureEditorLoaded(callback)

Ensure Editor Loaded

Run the given callback with the active editor, waiting for one if needed. If an editor is already loaded, the callback is invoked immediately; otherwise it is invoked once when the next editor loads, after which the subscription disposes itself.

Parameters

  • Name
    callback(editor)
    Type
    function
    Required
    Description

    Function to be called with the loaded EditorView.

Returns

Nothing. In windows without an editor the callback simply never fires rather than throwing.


onAppReady(callback)

App Readiness Event

Invoke the given callback when the app is ready.

Parameters

  • Name
    callback()
    Type
    function
    Required
    Description

    Function to be called when the app is ready.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.


onAppQuit(callback)

App Quit Event

Invoke the given callback when the app is about to quit.

Parameters

  • Name
    callback()
    Type
    function
    Required
    Description

    Function to be called before the app quits.

Returns

Returns a Disposable on which .dispose() can be called to unsubscribe.


isEditorActive()

Is Editor Active

Check if the editor is currently active.

Returns

Returns a Boolean indicating whether the editor is active.


getActiveEditor()

Get Active Editor

Retrieve the active editor instance.

Returns

Returns the active EditorView if the editor is active, otherwise null or undefined.


getActiveEditorOrThrowError()

Get Active Editor with Error Handling

Retrieve the active editor instance or throw an error if it's not available.

Returns

Returns the active EditorView if the editor is active, otherwise throws an error.


setActiveEditor(editor)

Set Active Editor

Set the currently active editor instance.

Parameters

  • Name
    editor
    Type
    EditorView
    Required
    Description

    The EditorView to set as the active editor, or null to clear it.


Can you help us improve the docs? 🙏

The source of these docs is here on GitHub. If you see a way these docs can be improved, please fork us!