0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-06 14:50:21 -05:00

feat(plugins-types): new methods to access selection colors

This commit is contained in:
alonso.torres 2024-06-24 15:27:51 +02:00 committed by Alonso Torres
parent ffa5156fac
commit a95c4b8eaf
2 changed files with 61 additions and 0 deletions

View file

@ -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.

View file

@ -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();
},