Input defines properties to access the input text contents.

interface Input {
    content: PasteboardContent;
    data: {
        emails: RangedStrings;
        nonHttpUrls: RangedStrings;
        paths: RangedStrings;
        urls: RangedStrings;
    };
    html: string;
    isUrl: boolean;
    markdown: string;
    matchedText: string;
    regexResult?: string[] | RegExpMatchArray;
    rtf: string;
    text: string;
    xhtml: string;
}

Properties

Unprocessed selection contents indexed by UTI.

data: {
    emails: RangedStrings;
    nonHttpUrls: RangedStrings;
    paths: RangedStrings;
    urls: RangedStrings;
}

Data of various kinds, that PopClip detected in the selected text.

Type declaration

  • emails: RangedStrings

    Email addresses.

  • nonHttpUrls: RangedStrings

    Other protocols or app urls e.g. ftp:, omnifocus:, craftdocs: etc. (PopClip has a pre-defined allowlist for custom URL schemes.)

  • paths: RangedStrings

    Local file paths.

  • urls: RangedStrings

    HTTP ot HTTPS urls.

html: string

HTML content (if captureHtml is true).

isUrl: boolean

Indicate if the text content is just a web URL (or URL-like string such as popclip.app), allowing for leading and trailing whitespace.

markdown: string

Markdown content (if captureHtml is true).

matchedText: string

If the action specified Action.requirements or a Action.regex to match the input, this will be the matching part of the text. Otherwise, it will be the same string as text.

regexResult?: string[] | RegExpMatchArray

If the action specified a regex to match the input, this will be the result of the the match.

You can use this to access any capture groups from the regex.

If the regex was specified as a JavaScript regex, the value is a return value from JavaScript's RegExp.prototype.exec() method.

If the regex was specified as an ICU regex in the static config, the value is the array of capture components.

Example

// text: "apple", regex: /.(.)/
selection.regexResult[0] // "ap" (full match)
selection.regexResult[1] // "p" (capture group 1)
rtf: string

RTF content (if captureRtf is true).

text: string

The plain text selected by the user. If there is no selected text, this will be the empty string.

xhtml: string

XHTML content (if captureHtml is true).