mirror of
https://github.com/penpot/penpot.git
synced 2026-05-05 08:08:27 +00:00
* 🎉 Add tokens to plugins API documentation And add poc plugin example * 📚 Document better the tokens value in plugins API * 🔧 Refactor token validation schemas * 🔧 Use automatic validation in token proxies * 🔧 Use schemas to validate token creation * 🔧 Use multi schema for token value * 🔧 Use schema in token api methods * 🐛 Fix review comments --------- Co-authored-by: Andrey Antukh <niwi@niwi.nz>
113 lines
1.9 KiB
TypeScript
113 lines
1.9 KiB
TypeScript
import { TokenProperty } from '@penpot/plugin-types';
|
|
|
|
/**
|
|
* This file contains the typescript interfaces for the plugin events.
|
|
*/
|
|
|
|
// Events sent from the ui to the plugin
|
|
|
|
export interface LoadLibraryEvent {
|
|
type: 'load-library';
|
|
}
|
|
|
|
export interface LoadTokensEvent {
|
|
type: 'load-tokens';
|
|
setId: string;
|
|
}
|
|
|
|
export interface AddThemeEvent {
|
|
type: 'add-theme';
|
|
themeGroup: string;
|
|
themeName: string;
|
|
}
|
|
|
|
export interface AddSetEvent {
|
|
type: 'add-set';
|
|
setName: string;
|
|
}
|
|
|
|
export interface AddTokenEvent {
|
|
type: 'add-token';
|
|
setId: string;
|
|
tokenType: string;
|
|
tokenName: string;
|
|
tokenValue: unknown;
|
|
}
|
|
|
|
export interface RenameThemeEvent {
|
|
type: 'rename-theme';
|
|
themeId: string;
|
|
newName: string;
|
|
}
|
|
|
|
export interface RenameSetEvent {
|
|
type: 'rename-set';
|
|
setId: string;
|
|
newName: string;
|
|
}
|
|
|
|
export interface RenameTokenEvent {
|
|
type: 'rename-token';
|
|
setId: string;
|
|
tokenId: string;
|
|
newName: string;
|
|
}
|
|
|
|
export interface DeleteThemeEvent {
|
|
type: 'delete-theme';
|
|
themeId: string;
|
|
}
|
|
|
|
export interface DeleteSetEvent {
|
|
type: 'delete-set';
|
|
setId: string;
|
|
}
|
|
|
|
export interface DeleteTokenEvent {
|
|
type: 'delete-token';
|
|
setId: string;
|
|
tokenId: string;
|
|
}
|
|
|
|
export interface ToggleThemeEvent {
|
|
type: 'toggle-theme';
|
|
themeId: string;
|
|
}
|
|
|
|
export interface ToggleSetEvent {
|
|
type: 'toggle-set';
|
|
setId: string;
|
|
}
|
|
|
|
export interface ApplyTokenEvent {
|
|
type: 'apply-token';
|
|
setId: string;
|
|
tokenId: string;
|
|
properties?: TokenProperty[];
|
|
}
|
|
|
|
export type PluginUIEvent =
|
|
| LoadLibraryEvent
|
|
| LoadTokensEvent
|
|
| AddThemeEvent
|
|
| AddSetEvent
|
|
| AddTokenEvent
|
|
| RenameThemeEvent
|
|
| RenameSetEvent
|
|
| RenameTokenEvent
|
|
| DeleteThemeEvent
|
|
| DeleteSetEvent
|
|
| DeleteTokenEvent
|
|
| ToggleThemeEvent
|
|
| ToggleSetEvent
|
|
| ApplyTokenEvent;
|
|
|
|
// Events sent from the plugin to the ui
|
|
|
|
export interface ThemePluginEvent {
|
|
type: 'theme';
|
|
content: string;
|
|
}
|
|
|
|
export type PluginMessageEvent = ThemePluginEvent;
|