Options
All
  • Public
  • Public/Protected
  • All
Menu

This interface describes the methods and properties of the global popclip object.

Hierarchy

  • PopClip

Index

Methods

  • appear(): void
  • Trigger PopClip to appear again with the current selection.

    Returns void

  • Copy arbitrary pasteboard content.

    Parameters

    Returns void

  • copyText(text: string): void
  • Places the given string on the pasteboard, and shows "Copied" notificaction to the user.

    Parameters

    • text: string

      The plain text string to copy

    Returns void

  • openUrl(url: string, options?: { app?: string }): void
  • Open a URL in an application.

    Choice of application

    If a target application bundle identifier is specified via the app option, PopClip will ask that app to open the URL.

    If no target app is specified:

    • If the URL has the http or https scheme, and the current app is a browser, the URL is opened in the current app.
    • Otherwise, PopClip asks macOS to open the URL in the default handler for that URL type.

    URL encoding

    Any parameters etc. in the URL must be appropriately percent-encoded. JavaScript provides the encodeURIComponent() function for this.

    Example

    popclip.openUrl("https://xkcd.com"); // open xckd.com in current/default browser
    popclip.openUrl("https://xkcd.com", {app: "com.brave.Browser"}); // open xkcd.com in Brave browser
    popclip.openUrl(`mailto:support@pilotmoon.com?subject=${encodeURIComponent("What's up?")}`); // open mailto link in the default mail application

    Parameters

    • url: string

      A well-formed URL

    • Optional options: { app?: string }

      Options.

      • Optional app?: string

        Bundle identifier of the app to open the URL with. For example "com.google.Chrome".

    Returns void

  • If the target app's Paste command is available, this method places the given string on the pasteboard and then invokes the target app's Paste comand. If the restore flag is set in the options, it will then restore the original pasteboard contents.

    If the target app's Paste command is not available, it behaves as copyText instead.

    Example

    // place "Hello" on the clipboard and invoke Paste
    popclip.pasteText("Hello");
    // place "Hello", then restore the original pasteboard contents
    popclip.pasteText("Hello", {restore: true});

    Parameters

    • text: string

      The plain text string to paste

    • Optional options: PasteOptions

    Returns void

  • performCommand(command: "cut" | "paste" | "copy", options?: { transform?: "none" | "plain" }): void
  • Invokes a command in the target app.

    Parameters

    • command: "cut" | "paste" | "copy"

      Either cut, copy or paste.

    • Optional options: { transform?: "none" | "plain" }

      Options for the command.

      • Optional transform?: "none" | "plain"

        Transformation to apply to the pasteboard contents. (Default: none)

        • none: regular pasteboard operation
        • plain: strips away everything but plain text

    Returns void

  • pressKey(key: string | number, modifiers?: number): void
  • Simulate a key press by the user.

    Examples

    // press the key combo ⌘B
    popclip.pressKey('command B');
    // press the key combo ⌥⌘H
    popclip.pressKey('option command H');
    // press the return key
    popclip.pressKey('return');
    popclip.pressKey(util.constant.KEY_RETURN); // equivalent
    * // press option and the page down key
    popclip.pressKey('option 0x79');
    popclip.pressKey(0x79, util.constant.MODIFIER_OPTION); // equivalent

    Notes

    Some key code and modifier constants are available in util.constant.

    Parameters

    • key: string | number

      The key to press. When this parameter is a string, PopClip will interpret it as in Key Press actions. When this parameter is a number, PopClip will use that exact key code.

    • Optional modifiers: number

      An optional bit mask specifiying additional modifier keys, if any.

    Returns void

  • showFailure(): void
  • PopClip will show an "X" symbol to indicate failure.

    Returns void

  • showSettings(): void
  • PopClip will open the settings UI for this extension.

    Notes

    If the extension has no settings, this method does nothing.

    Returns void

  • showSuccess(): void
  • PopClip will show a checkmark symbol to indicate success.

    Returns void

  • showText(text: string, options?: { preview?: boolean }): void
  • Display text inside PopClip's popup, with option to make the display a clickable button to paste the text.

    Parameters

    • text: string

      The text to display. It will be truncated to 160 characters when shown.

    • Optional options: { preview?: boolean }
      • Optional preview?: boolean

        If true, and the app's Paste command is available, the displayed text will be in a cickable button, which clicked, pastes the full text.

    Returns void

Properties

context: Context

The current context.

input: Input

The current selection.

modifiers: Modifiers

The state of the modifier keys when the action was invoked in PopClip.

Notes

During the execution of the population function, all the modifiers will read as false.

options: Options & AuthOptions

The current values of the options.

Generated using TypeDoc