API Reference

Spell Book works both in CEP and UXP platforms.

It consists of application and extension, which acts as a bridge between Spell Book app and your extension. Use npm modules, both for CEP and UXP, that provide interface for commands registration and handling command event.

Installation

Make sure that Spell Book is installed (both app and Spell Book extension).

Installation

npm install @knights-of-the-editing-table/spell-book

Usage

// code.js
import Spellbook from '@knights-of-the-editing-table/spell-book';

const commands = [
    {
        commandID: 'command.id',
        // name: use localised name if needed
        name: 'Command 1',
        // group: optional
        group: 'Group 1',
        // action runs when command is triggered
        action: () => { 
            console.log('command.id triggered!')
        }
    }
];

const spellbook = new Spellbook('Extension name', 'extension.id', commands);

Spellbook constructor

const spellbook = new Spellbook(
    pluginName: string,
    pluginID: string,
    commands?: Command[])

Methods

// Add or update commands
spellbook.register(commands)
// Start listening for command events
spellbook.start()
// Stop listening for command events
spellbook.stop()

Events

The plugin extends EventEmitter and emits events when commands are triggered:

spellbook.on('command.id', (commandID) => {
    console.log('command.id triggered!')
});

Last updated