UXP Toolkit
    Preparing search index...

    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.

    var action = require('photoshop').action;
    

    media

    interface ActionModule {
        addNotificationListener: (
            events: string[],
            notifier: NotificationListener,
        ) => Promise<void>;
        batchPlay: (
            commands: ActionDescriptor[],
            options?: BatchPlayCommandOptions,
        ) => Promise<ActionDescriptor[]>;
        getIDFromString: (value: string) => number;
        removeNotificationListener: (
            events: string[],
            notifier: NotificationListener,
        ) => Promise<void>;
        validateReference: (ref: ActionReference | ActionReference[]) => boolean;
    }
    Index

    Properties

    addNotificationListener: (
        events: string[],
        notifier: NotificationListener,
    ) => Promise<void>

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

    await action.addNotificationListener(['open'], onOpenNewDocument)
    

    23.0

    batchPlay: (
        commands: ActionDescriptor[],
        options?: BatchPlayCommandOptions,
    ) => Promise<ActionDescriptor[]>

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

    var target = { _ref: 'layer', _enum: 'ordinal', _value: 'targetEnum'}
    var commands = [{ _obj: 'hide', _target: target }]
    await action.batchPlay(commands)

    23.0

    getIDFromString: (value: string) => 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.

    24.0

    removeNotificationListener: (
        events: string[],
        notifier: NotificationListener,
    ) => Promise<void>

    Detaches a listener from a Photoshop event. See addNotificationListener

    await action.removeNotificationListener(['open'], onOpenNewDocument)
    

    23.0

    validateReference: (ref: ActionReference | ActionReference[]) => 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

    23.1