Edit in GitHubLog an issue

photoshopAction

The module that facilitates Actions being performed in the UXP-Photoshop world. You may perform your own batchPlay commands, or attach listeners using this module.

Copied to your clipboard
var PhotoshopAction = require('photoshop').action;

Functions

addNotificationListener

23.0

Promise<void>

Attach a listener to a Photoshop event. A callback in the form of (eventName: string, descriptor: Descriptor) => void will be performed.

Copied to your clipboard
await PhotoshopAction.addNotificationListener(['open'], onOpenNewDocument)

Parameters

NameType
events
string[]
notifier
NotificationListener

batchPlay

23.0

Promise<ActionDescriptor[]>

Performs a batchPlay call with the provided commands. Equivalent to an executeAction in ExtendScript.

Copied to your clipboard
1var target = { _ref: 'layer', _enum: 'ordinal', _value: 'targetEnum'}
2var commands = [{ _obj: 'hide', _target: target }]
3await PhotoshopAction.batchPlay(commands)

Parameters

NameType
commands
ActionDescriptor[]
options?

batchPlaySync

23.1

ActionDescriptor[]

Performs a batchPlay call with the provided commands. Equivalent to an executeAction in ExtendScript.

Copied to your clipboard
1var target = { _ref: 'layer', _enum: 'ordinal', _value: 'targetEnum'}
2var commands = [{ _obj: 'hide', _target: target }]
3await PhotoshopAction.batchPlay(commands)

Parameters

NameType
commands
ActionDescriptor[]
options?

getIDFromString

24.0

number

Return the identifier number assigned to an action string value. If the string is not already registered, a new ID will be created and returned.

Parameters

NameType
value
string

recordAction

25.0

Promise<void>

Records this plugin's action to an active Action recording. See Action Recording for usage and manifest requirements.

Copied to your clipboard
await PhotoshopAction.recordAction("name": "My Command", methodName: "actionHandler", info: {"prop": value})

When the action is invoked, the following top level JavaScript function will be invoked:

Copied to your clipboard
1async function actionHandler(executionContext, info) {
2 let propValue = info["prop"];
3}

Parameters

NameTypeDescription
name
string
User visible string for the Actions panel.
methodName
string
Name of top level JavaScript function callback.
info
ActionDescriptor
Object with action specific information. See Action Recording.

removeNotificationListener

23.0

Promise<void>

Detaches a listener from a Photoshop event. See addNotificationListener

Copied to your clipboard
await PhotoshopAction.removeNotificationListener(['open'], onOpenNewDocument)

Parameters

NameType
events
string[]
notifier
NotificationListener

validateReference

23.1

boolean

Synchronously validates the given action reference, returning true if it still exists. For example, calling this with a closed document would return false.

This feature is intended for advanced developers who understand well how batchPlay works. Validate reference could get handy when you want to add new DOM functionality or use low-level code for performance optimization.

See Action references for details.

Supported reference classes: action, document, channel, layer, guide, historyState, compsClass, path, actionSet

Parameters

NameType
ref
ActionReference | ActionReference[]
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.