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" } { "title": "Gitmoji Code", "value": "code" }
], ],
"default": "emoji" "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": { "scripts": {
+13 -1
View File
@@ -20,6 +20,7 @@ type CopyFormat = "emoji" | "code";
type GitmojiPreferences = { type GitmojiPreferences = {
copyFormat?: CopyFormat; copyFormat?: CopyFormat;
directPaste?: boolean;
}; };
const gitmojis = gitmojisData.gitmojis as Gitmoji[]; const gitmojis = gitmojisData.gitmojis as Gitmoji[];
@@ -30,10 +31,11 @@ const contentFor = (gitmoji: Gitmoji, format: CopyFormat) =>
format === "code" ? gitmoji.code : gitmoji.emoji; format === "code" ? gitmoji.code : gitmoji.emoji;
export default function GitmojiList() { export default function GitmojiList() {
const { copyFormat } = getPreferenceValues<GitmojiPreferences>(); const { copyFormat, directPaste } = getPreferenceValues<GitmojiPreferences>();
const primaryFormat: CopyFormat = copyFormat === "code" ? "code" : "emoji"; const primaryFormat: CopyFormat = copyFormat === "code" ? "code" : "emoji";
const secondaryFormat: CopyFormat = const secondaryFormat: CopyFormat =
primaryFormat === "code" ? "emoji" : "code"; primaryFormat === "code" ? "emoji" : "code";
const preferPaste = directPaste === true;
return ( return (
<List searchBarPlaceholder="Search gitmojis..."> <List searchBarPlaceholder="Search gitmojis...">
@@ -47,6 +49,15 @@ export default function GitmojiList() {
keywords={[gitmoji.name]} keywords={[gitmoji.name]}
actions={ actions={
<ActionPanel> <ActionPanel>
{preferPaste ? (
<Action.Paste
title={`Paste ${labelFor(primaryFormat)}`}
content={contentFor(gitmoji, primaryFormat)}
onPaste={(content) =>
showToast(Toast.Style.Success, "Pasted", String(content))
}
/>
) : (
<Action.CopyToClipboard <Action.CopyToClipboard
title={`Copy ${labelFor(primaryFormat)}`} title={`Copy ${labelFor(primaryFormat)}`}
content={contentFor(gitmoji, primaryFormat)} content={contentFor(gitmoji, primaryFormat)}
@@ -58,6 +69,7 @@ export default function GitmojiList() {
) )
} }
/> />
)}
<Action.CopyToClipboard <Action.CopyToClipboard
title={`Copy ${labelFor(secondaryFormat)}`} title={`Copy ${labelFor(secondaryFormat)}`}
content={contentFor(gitmoji, secondaryFormat)} content={contentFor(gitmoji, secondaryFormat)}