diff --git a/libs/plugin-types/index.d.ts b/libs/plugin-types/index.d.ts index 90e425a..4c8f934 100644 --- a/libs/plugin-types/index.d.ts +++ b/libs/plugin-types/index.d.ts @@ -292,6 +292,36 @@ export interface PenpotColor { image?: PenpotImageData; } +/** + * TODO PenpotColorShapeInfoEntry + */ +export interface PenpotColorShapeInfoEntry { + /** + * TODO property + */ + readonly property: string; + + /** + * TODO index + */ + readonly index: number; + + /** + * TODO shapeId + */ + readonly shapeId: string; +} + +/** + * TODO PenpotColorShapeInfo + */ +export interface PenpotColorShapeInfo { + /** + * TODO shapesInfo + */ + readonly shapesInfo: PenpotColorShapeInfoEntry[]; +} + /** * Represents shadow properties in Penpot. * This interface includes properties for defining drop shadows and inner shadows, along with their visual attributes. @@ -2256,6 +2286,21 @@ export interface PenpotContext { * ``` */ getSelectedShapes(): PenpotShape[]; + + /** + * TODO: getSelectedColors + */ + getColors(shapes: PenpotShape[]): (PenpotColor & PenpotColorShapeInfo)[]; + + /** + * TODO: changeSelectedColor + */ + changeColor( + shapes: PenpotShape[], + oldColor: PenpotColor, + newColor: PenpotColor + ): void; + /** * Retrieves the current theme (light or dark) in Penpot. * Returns the current theme. diff --git a/libs/plugins-runtime/src/lib/api/index.ts b/libs/plugins-runtime/src/lib/api/index.ts index fda2d05..99e76fe 100644 --- a/libs/plugins-runtime/src/lib/api/index.ts +++ b/libs/plugins-runtime/src/lib/api/index.ts @@ -20,6 +20,8 @@ import type { PenpotActiveUser, PenpotFontsContext, PenpotSvgRaw, + PenpotColor, + PenpotColorShapeInfo, } from '@penpot/plugin-types'; import { Manifest, Permissions } from '../models/manifest.model.js'; @@ -256,6 +258,20 @@ export function createApi(context: PenpotContext, manifest: Manifest): Penpot { return context.getSelectedShapes(); }, + getColors(shapes: PenpotShape[]): (PenpotColor & PenpotColorShapeInfo)[] { + // checkPermission('selection:read'); + return context.getColors(shapes); + }, + + changeColor( + shapes: PenpotShape[], + oldColor: PenpotColor, + newColor: PenpotColor + ) { + // checkPermission('selection:read'); + return context.changeColor(shapes, oldColor, newColor); + }, + getTheme(): PenpotTheme { return context.getTheme(); },