penpot/plugins/apps/e2e/src/plugins/create-board-text-rect.ts
Andrey Antukh ec1af4ad96 🎉 Import penpot-plugins repository
As commit 819a549e4928d2b1fa98e52bee82d59aec0f70d8
2025-12-30 14:56:15 +01:00

59 lines
1.2 KiB
TypeScript

import type { Board, Rectangle, Text } from '@penpot/plugin-types';
export default function () {
function createText(text: string): Text | undefined {
const textNode = penpot.createText(text);
if (!textNode) {
return;
}
textNode.x = penpot.viewport.center.x;
textNode.y = penpot.viewport.center.y;
return textNode;
}
function createRectangle(): Rectangle {
const rectangle = penpot.createRectangle();
rectangle.setPluginData('customKey', 'customValue');
rectangle.x = penpot.viewport.center.x;
rectangle.y = penpot.viewport.center.y;
rectangle.resize(200, 200);
return rectangle;
}
function createBoard(): Board {
const board = penpot.createBoard();
board.name = 'Board name';
board.x = penpot.viewport.center.x;
board.y = penpot.viewport.center.y;
board.borderRadius = 8;
board.resize(300, 300);
const text = penpot.createText('Hello from board');
if (!text) {
throw new Error('Could not create text');
}
text.x = 10;
text.y = 10;
board.appendChild(text);
return board;
}
createBoard();
createRectangle();
createText('Hello from plugin');
}