mirror of
https://github.com/penpot/penpot-mcp.git
synced 2026-04-25 19:28:13 +00:00
Refactoring: Move every concrete plugin task to a separate source file
This commit is contained in:
parent
0468381d2b
commit
283f01b0ac
@ -51,34 +51,3 @@ export abstract class PluginTask<TParams = any, TResult = any> {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the printText task.
|
||||
*/
|
||||
export class PluginTaskPrintTextParams {
|
||||
/**
|
||||
* The text to be displayed in Penpot.
|
||||
*/
|
||||
public readonly text: string;
|
||||
|
||||
constructor(text: string) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task for printing/creating text in Penpot.
|
||||
*
|
||||
* This task instructs the plugin to create a text element
|
||||
* at the viewport center and select it.
|
||||
*/
|
||||
export class PluginTaskPrintText extends PluginTask<PluginTaskPrintTextParams> {
|
||||
/**
|
||||
* Creates a new print text task.
|
||||
*
|
||||
* @param params - The parameters containing the text to print
|
||||
*/
|
||||
constructor(params: PluginTaskPrintTextParams) {
|
||||
super("printText", params);
|
||||
}
|
||||
}
|
||||
|
||||
32
mcp-server/src/tasks/PrintTextPluginTask.ts
Normal file
32
mcp-server/src/tasks/PrintTextPluginTask.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { PluginTask } from "../PluginTask";
|
||||
|
||||
/**
|
||||
* Parameters for the printText task.
|
||||
*/
|
||||
export class PrintTextPluginTaskParams {
|
||||
/**
|
||||
* The text to be displayed in Penpot.
|
||||
*/
|
||||
public readonly text: string;
|
||||
|
||||
constructor(text: string) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task for printing/creating text in Penpot.
|
||||
*
|
||||
* This task instructs the plugin to create a text element
|
||||
* at the viewport center and select it.
|
||||
*/
|
||||
export class PrintTextPluginTask extends PluginTask<PrintTextPluginTaskParams> {
|
||||
/**
|
||||
* Creates a new print text task.
|
||||
*
|
||||
* @param params - The parameters containing the text to print
|
||||
*/
|
||||
constructor(params: PrintTextPluginTaskParams) {
|
||||
super("printText", params);
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
import { IsNotEmpty, IsString } from "class-validator";
|
||||
import { Tool } from "../Tool";
|
||||
import { PluginTaskPrintText, PluginTaskPrintTextParams } from "../PluginTask";
|
||||
import type { ToolResponse } from "../ToolResponse";
|
||||
import { TextResponse } from "../ToolResponse";
|
||||
import "reflect-metadata";
|
||||
import { PenpotMcpServer } from "../PenpotMcpServer";
|
||||
import { PrintTextPluginTask, PrintTextPluginTaskParams } from "../tasks/PrintTextPluginTask";
|
||||
|
||||
/**
|
||||
* Arguments class for the PrintText tool with validation decorators.
|
||||
@ -43,8 +43,8 @@ export class PrintTextTool extends Tool<PrintTextArgs> {
|
||||
}
|
||||
|
||||
protected async executeCore(args: PrintTextArgs): Promise<ToolResponse> {
|
||||
const taskParams = new PluginTaskPrintTextParams(args.text);
|
||||
const task = new PluginTaskPrintText(taskParams);
|
||||
const taskParams = new PrintTextPluginTaskParams(args.text);
|
||||
const task = new PrintTextPluginTask(taskParams);
|
||||
this.mcpServer.executePluginTask(task);
|
||||
return new TextResponse(
|
||||
`Successfully sent text creation task. Text "${args.text}" should now appear in Penpot.`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user