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:
parent
ffa5156fac
commit
a95c4b8eaf
2 changed files with 61 additions and 0 deletions
45
libs/plugin-types/index.d.ts
vendored
45
libs/plugin-types/index.d.ts
vendored
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue