✨ Allow directly pasting the gitmoji
This commit is contained in:
@@ -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": {
|
||||||
|
|||||||
+24
-12
@@ -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,17 +49,27 @@ export default function GitmojiList() {
|
|||||||
keywords={[gitmoji.name]}
|
keywords={[gitmoji.name]}
|
||||||
actions={
|
actions={
|
||||||
<ActionPanel>
|
<ActionPanel>
|
||||||
<Action.CopyToClipboard
|
{preferPaste ? (
|
||||||
title={`Copy ${labelFor(primaryFormat)}`}
|
<Action.Paste
|
||||||
content={contentFor(gitmoji, primaryFormat)}
|
title={`Paste ${labelFor(primaryFormat)}`}
|
||||||
onCopy={(content) =>
|
content={contentFor(gitmoji, primaryFormat)}
|
||||||
showToast(
|
onPaste={(content) =>
|
||||||
Toast.Style.Success,
|
showToast(Toast.Style.Success, "Pasted", String(content))
|
||||||
"Copied to clipboard",
|
}
|
||||||
String(content),
|
/>
|
||||||
)
|
) : (
|
||||||
}
|
<Action.CopyToClipboard
|
||||||
/>
|
title={`Copy ${labelFor(primaryFormat)}`}
|
||||||
|
content={contentFor(gitmoji, primaryFormat)}
|
||||||
|
onCopy={(content) =>
|
||||||
|
showToast(
|
||||||
|
Toast.Style.Success,
|
||||||
|
"Copied to clipboard",
|
||||||
|
String(content),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Action.CopyToClipboard
|
<Action.CopyToClipboard
|
||||||
title={`Copy ${labelFor(secondaryFormat)}`}
|
title={`Copy ${labelFor(secondaryFormat)}`}
|
||||||
content={contentFor(gitmoji, secondaryFormat)}
|
content={contentFor(gitmoji, secondaryFormat)}
|
||||||
|
|||||||
Reference in New Issue
Block a user