@knights-of-the-editing-table/spell-book-uxp
v1.0.1
Published
Add Spell Book support to an extension. Execute actions with shortcuts or control surface.
Maintainers
Readme
Spell Book UXP
Spell Book is a support app to listen for a shortcut or a control surface button press in Adobe apps, to trigger extension commands. This module provides an interface for registering commands and handling shortcuts in your Adobe extension.
Installation
npm install @knights-of-the-editing-table/spell-book-uxpUsage
Basic Setup
Add command entrypoint and enablePluginCommunication to manifest.json, for Inter Plugin Communication:
{
"entrypoints": [
{
"type": "command",
"id": "spellbook.plugin",
"label": {
"default": "- spellbook plugin" // you can use your label
}
}
],
"requiredPermissions": {
"ipc": {
"enablePluginCommunication": true
}
}
}Add Spell Book plugin:
import Spellbook from '@knights-of-the-editing-table/spell-book-uxp';
const commands = [
{
commandID: 'command.id',
name: 'Command 1', // use localised name if needed
group: 'Group 1', // optional
action: () => { // run action when command is triggered
console.log('command.id triggered!')
}
}
];
const spellbook = new Spellbook('Extension name', 'extension.id', commands);
// add spellbook.plugin to entry points
const { entrypoints } = require("uxp");
entrypoints.setup({
commands: {
'spellbook.plugin': {
run: (data, args) => spellbook.plugin(data, args),
},
},
});Command Interface
/**
* @typedef {Object} Command
* @property {string} commandID - Unique identifier for the command
* @property {string} name - Display name for the command
* @property {string?} group - Name of group the command belongs to
* @property {(args?: any) => void} [action] - Function to execute when command is triggered
*/API Reference
Spellbook
Constructor
new Spellbook(
pluginName: string,
pluginID: string,
commands?: Command[])Methods
register(commands: Command[]): void- Add or update commandsstart(): void- Start listening for command eventsstop(): void- Stop listening for command events
Events
The plugin extends EventEmitter and emits events when commands are triggered:
spellbook.on('command.id', () => {
console.log('command.id triggered!')
});Supported Adobe Hosts
- Premiere Pro
- Photoshop
- InDesign
Integration with Adobe UXP
Make sure that Spell Book is installed (both app and Spell Book extension).
CEP support
For CEP use @knights-of-the-editing-table/spell-book
License
MIT License - see LICENSE file for details.
