The selected text and related properties. (Same object as [[PopClip.selection]].)
Current values of the options for this extension. (Same object as PopClip.options.)
Information about the context surrounding the selection. (Same object as PopClip.context.)
Strings which can be used to specify the after action.
Object returned by Extension.auth when there is an authentication flow to kick off
Function signature of the Extension.auth method.
Strings which can be used to specify the before action.
A type to represent a localizable string.
The value may be either a string or an object.
If you supply a string, that string is used.
If you supply a StringTable object, PopClip will
display the string for the user's preferred language if possible, with fallback to the en
string.
option.label = "Color" // just use this string
option.label = { en: "Color", "en-GB": "Colour", fr: "Couleur", "zh-Hans": "颜色" }
Negated form of Requirement.
A population function dynamically generates the actions for the extension. See Extension.actions.
The selected text and related properties. (Same object as [[PopClip.selection]].)
Current values of the options for this extension. (Same object as PopClip.options.)
Information about the context surrounding the selection. (Same object as PopClip.context.)
A single action, an array of actions.
A requirement is specified in the Action.requirements array as a string.
["paste", "!urls", "option-goFishing=1"]
This global function may be called as an alternative to setting module.exports
directly.
The advantage of using defineExtension()
is that you will automatically get type checking
and autocomplete for your extension object.
You may define the shape of the extensions's options object by specifying the
CustomOptions
generic type parameter. This will enable type checking and autocomplete for
the options
parameter in action functions and the population function.
The extension object to define.
Output a string for debugging purposes. By default it is not output anywhere, but you can configure PopClip to output to the Console app by running the following command in Terminal:
defaults write com.pilotmoon.popclip EnableExtensionDebug -bool YES
then Quit and restart PopClip.
print("Hello, world!")
// print: Hello, world!
print(1, Math.PI, 2/3, ['a','b','c'])
// print: 1 3.141592653589793 0.6666666666666666 a,b,c
Import an object from another file.
PopClip's require()
implementation attempts to import from the following module formats:
define(...)
.module.exports = ...
or exports.name = ...
exports.default = ...
Paths beginning with ./
or ../
are resolved relative to the the location of the current file.
Otherwise, the path is resolved relative to the extensions's package root. If there is no file in the extension, PopClip will look in its internal module repository.
If no file extension is given, PopCLip will try adding the extensions .js
, .ts
, .json
in that order.
TypeScript files are transpiled to JavaScript on the fly.
JSON files are parsed and returned as an object.å
Path to the file to import.
The imported object.
A promise-based sleep function. Included as a more convenient alternative
to [[setTimeout]] for performing simple delays. Call as await sleep(1000)
.
How long to sleep in milliseconds
The global pasteboard
object provides access to the contents of the macOS general pasteboard (i.e. the system clipboard). It implements Pasteboard.
The global popclip
object encapsulates the user's current interaction with PopClip, and provides methods
for performing various actions. It implements PopClip.
The global util
object acts as a container for various utility functions and constants. It implements Util.
Generated using TypeDoc
An action function is called when the user clicks the action button in PopClip. This is where the extension does its main work.