diff --git a/extensions/drafts/CHANGELOG.md b/extensions/drafts/CHANGELOG.md index 04d36acc2f4..ee888c8f36d 100644 --- a/extensions/drafts/CHANGELOG.md +++ b/extensions/drafts/CHANGELOG.md @@ -1,5 +1,9 @@ # Drafts Changelog +## [Add Command for Capture] - 2024-10-04 + +- Add command to capture Draft from command argument + ## [Add Commands for Background creation] - 2024-09-26 - Add commands to create Draft in the background diff --git a/extensions/drafts/README.md b/extensions/drafts/README.md index 885f1521443..19be4f46f98 100644 --- a/extensions/drafts/README.md +++ b/extensions/drafts/README.md @@ -9,6 +9,10 @@ It supports the following features as commands: Create drafts in a Raycast form with tags (either with opening it afterwards or in the background). +## Capture Draft + +Quickly capture content from command argument into a new draft in the background. + ## Append/Prepend to Draft Configure Drafts you often want to append / prepend text to. diff --git a/extensions/drafts/package.json b/extensions/drafts/package.json index 2ce52ba55fe..dfcdd033533 100644 --- a/extensions/drafts/package.json +++ b/extensions/drafts/package.json @@ -5,6 +5,9 @@ "description": "integrate Raycast with Drafts app", "icon": "drafts-icon.png", "author": "FlohGro", + "contributors": [ + "william_morgano" + ], "categories": [ "Applications", "Productivity" @@ -115,6 +118,21 @@ "required": true } ] + }, + { + "name": "capture", + "title": "Capture Draft", + "subtitle": "Drafts", + "description": "create a new draft quickly in the background using the command argument", + "mode": "no-view", + "arguments": [ + { + "name": "content", + "placeholder": "Draft Content", + "type": "text", + "required": true + } + ] } ], "dependencies": { diff --git a/extensions/drafts/src/capture.tsx b/extensions/drafts/src/capture.tsx new file mode 100644 index 00000000000..24ae634b3c0 --- /dev/null +++ b/extensions/drafts/src/capture.tsx @@ -0,0 +1,19 @@ +import { LaunchProps, PopToRootType, showHUD } from "@raycast/api"; +import { runAppleScript } from "@raycast/utils"; + +export default async function main(props: LaunchProps<{ arguments: Arguments.Capture }>) { + const { content } = props.arguments; + + const res = await runAppleScript( + ` +on run argv + tell application "Drafts" + make new draft with properties {content:argv, flagged:false} + end tell +end run + `, + [content] + ); + + await showHUD("Created Draft 👍", { clearRootSearch: true, popToRootType: PopToRootType.Immediate }); +}