2025-02-19 08:46:58 +07:00

26 lines
635 B
TypeScript

import {clipboard, HeadlessCommand, toast} from "@kksh/api/headless";
export class BaseExt extends HeadlessCommand {
_func: Function;
constructor(func: (text: string) => string) {
super();
this._func = func;
}
async load() {
if (!await clipboard.hasText()) {
await toast.error("Clipboard is empty");
return;
}
const clipboardText = await clipboard.readText();
const convertedText = this._func(clipboardText);
await clipboard.writeText(convertedText);
await toast.success(`Copied "${convertedText}"`);
return;
}
}