Allow directly pasting the gitmoji

This commit is contained in:
2026-06-30 17:19:50 +02:00
parent 27fc7d3ec4
commit 2969af132f
2 changed files with 33 additions and 12 deletions
+9
View File
@@ -30,6 +30,15 @@
{ "title": "Gitmoji Code", "value": "code" }
],
"default": "emoji"
},
{
"name": "directPaste",
"title": "Direct Paste",
"description": "Paste the gitmoji directly into the focused app instead of copying to the clipboard.",
"required": false,
"type": "checkbox",
"label": "Paste directly into the focused app",
"default": false
}
],
"scripts": {
+13 -1
View File
@@ -20,6 +20,7 @@ type CopyFormat = "emoji" | "code";
type GitmojiPreferences = {
copyFormat?: CopyFormat;
directPaste?: boolean;
};
const gitmojis = gitmojisData.gitmojis as Gitmoji[];
@@ -30,10 +31,11 @@ const contentFor = (gitmoji: Gitmoji, format: CopyFormat) =>
format === "code" ? gitmoji.code : gitmoji.emoji;
export default function GitmojiList() {
const { copyFormat } = getPreferenceValues<GitmojiPreferences>();
const { copyFormat, directPaste } = getPreferenceValues<GitmojiPreferences>();
const primaryFormat: CopyFormat = copyFormat === "code" ? "code" : "emoji";
const secondaryFormat: CopyFormat =
primaryFormat === "code" ? "emoji" : "code";
const preferPaste = directPaste === true;
return (
<List searchBarPlaceholder="Search gitmojis...">
@@ -47,6 +49,15 @@ export default function GitmojiList() {
keywords={[gitmoji.name]}
actions={
<ActionPanel>
{preferPaste ? (
<Action.Paste
title={`Paste ${labelFor(primaryFormat)}`}
content={contentFor(gitmoji, primaryFormat)}
onPaste={(content) =>
showToast(Toast.Style.Success, "Pasted", String(content))
}
/>
) : (
<Action.CopyToClipboard
title={`Copy ${labelFor(primaryFormat)}`}
content={contentFor(gitmoji, primaryFormat)}
@@ -58,6 +69,7 @@ export default function GitmojiList() {
)
}
/>
)}
<Action.CopyToClipboard
title={`Copy ${labelFor(secondaryFormat)}`}
content={contentFor(gitmoji, secondaryFormat)}