✨ Allow directly pasting the gitmoji
This commit is contained in:
@@ -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
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user