Skip to content

Commit 54db542

Browse files
committed
warnings, TODO!s
1 parent 7a25711 commit 54db542

File tree

5 files changed

+86
-10
lines changed

5 files changed

+86
-10
lines changed

hub/powertoys/command-palette/add-top-level-commands-to-your-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ There you have it. Now you can add additional top-level commands to your extensi
5151

5252
If you'd like to update the list of top-level commands dynamically, you can do so in the same way as you would update a list page. This can be useful for cases like an extension that might first require the user to log in, before showing certain commands. In that case, you can show the "log in" command at the top level initially. Then, once the user logs in successfully, you can update the list of top-level commands to include the commands that required authentication.
5353

54-
Once you've determined that you need to change the top level list, call [`RaiseItemsChanged()`](../microsoft-commandpalette-extensions-toolkit/commandprovider-raiseitemschanged.md) on your `CommandProvider`. Command Palette will then ask for the top-level commands via `TopLevelCommands()` again, and you can return the updated list.
54+
Once you've determined that you need to change the top level list, call [`RaiseItemsChanged()`](./microsoft-commandpalette-extensions-toolkit/commandprovider_raiseitemschanged.md) on your `CommandProvider`. Command Palette will then ask for the top-level commands via `TopLevelCommands()` again, and you can return the updated list.
5555

5656
> [!TIP]
5757
> Create the `CommandItem`s for the top-level commands before calling `RaiseItemsChanged()`. This will ensure that the new commands are available when Command Palette asks for the top-level commands. This will help keep the work being done in call to `TopLevelCommands()` method to a minimum.

hub/powertoys/command-palette/command-results.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ If you don't know what else to use, this should be your default. Ideally, users
4747

4848
This result displays a transient desktop-level message to the user. This is especially useful for displaying confirmation that an action took place when the palette will be closed.
4949

50-
Consider the [CopyTextCommand](../microsoft-commandpalette-extensions-toolkit/copytextcommand.md) in the helpers - this command will show a toast with the text "Copied to clipboard", then dismiss the palette.
50+
Consider the [CopyTextCommand](./microsoft-commandpalette-extensions-toolkit/copytextcommand.md) in the helpers - this command will show a toast with the text "Copied to clipboard", then dismiss the palette.
5151

5252
By default, [`CommandResult.ShowToast(string)`](./microsoft-commandpalette-extensions-toolkit/commandresult_showtoast_string.md) helper will have a `Result` of `CommandResult.Dismiss`. However, you can instead change the result to any of the other results if you want. This allows you to display a toast and keep the palette open, if you'd like.
5353

hub/powertoys/command-palette/creating-an-extension.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ ExtensionName/
5151
From here, you can immediately build the project and run it. Once your package is deployed and running, Command Palette will automatically discover your extension and load it into the palette.
5252

5353
> [!TIP]
54-
> Make sure you deploy your app! Just **build**ing your application won't update the package in the same way that deploying it will.
54+
> Make sure you _deploy_ your app! Just **build**ing your application won't update the package in the same way that deploying it will.
5555
5656
> [!WARNING]
5757
> Running "ExtensionName (Unpackaged)" from Visual Studio will not **deploy** your app package.
5858
>
59-
> If you're using `git` for source control, and you used the standard `.gitignore` file for C#, you'll want to remove the
59+
> If you're using `git` for source control, and you used the standard `.gitignore` file for C#, you'll want to remove the following two lines from your `.gitignore` file:
6060
> ```
6161
> **/Properties/launchSettings.json
62+
> *.pubxml
6263
> ```
63-
> line from your `.gitignore` file. This file is used by WinAppSdk to deploy your app as a package. Without it, anyone who clones your repo won't be able to deploy your extension.
64+
> These files are used by WinAppSdk to deploy your app as a package. Without it, anyone who clones your repo won't be able to deploy your extension.
6465
6566
You should be able to see your extension in the Command Palette at the end of the list of commands. Entering that command should take you to the page for your command, and you should see a single command that says "TODO: Implement your extension here".
6667

hub/powertoys/command-palette/publish-extension.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,28 @@ The following tools are required to build and publish your extension:
2323

2424
Publishing packages to WinGet is the recommended way to share your extensions with users. Extension packages which are listed on WinGet can be discovered and installed directly from the Command Palette.
2525

26-
For the most part, following the steps on [Submit packages to Windows Package Manager](https://learn.microsoft.com/en-us/windows/package-manager/package/) will get your extension onto WinGet itself.
26+
For the most part, following the steps on [Submit packages to Windows Package Manager](../../package-manager/package/manifest.md) will get your extension onto WinGet itself.
2727

2828
Before submitting your manifest to WinGet, you'll need to check two things:
2929

3030
### Add `windows-commandpalette-extension` tag
3131

32+
Command Palette uses the special `windows-commandpalette-extension` tag to discover extensions. Make sure that your manifest includes this tag, so that Command Palette can discover your extension. Add the following to each `.locale.*.yaml` file in your manifest:
33+
34+
```yaml
35+
Tags:
36+
- windows-commandpalette-extension
37+
```
38+
3239
### Ensure WindowsAppSdk is listed as a dependency
3340
34-
If you're using Windows App SDK, then you'll need to make sure that it is listed as a dependency of your package
41+
If you're using Windows App SDK, then you'll need to make sure that it is listed as a dependency of your package. Add the following to your `.installer.yaml` manifest:
42+
43+
```yaml
44+
Dependencies:
45+
PackageDependencies:
46+
- PackageIdentifier: Microsoft.WindowsAppRuntime.1.6
47+
```
3548

3649
If you're not using the template project, then this may not apply to you.
3750

hub/powertoys/command-palette/samples.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class MyCommand : Microsoft.CommandPalette.Extensions.Toolkit.InvokableCommand {
2525
Icon = new("\uE945"); // Segoe UI LightningBolt
2626
}
2727

28-
// Open MY_WEBSITE_URL in the user's default web browser
28+
// Open GitHub in the user's default web browser
2929
public ICommandResult Invoke() {
30-
Process.Start(new ProcessStartInfo("MY_WEBSITE_URL") { UseShellExecute = true });
30+
Process.Start(new ProcessStartInfo("https://github.com") { UseShellExecute = true });
3131

3232
// Hides the Command Palette window, without changing the page that's open
3333
return CommandResult.Hide();
@@ -37,7 +37,69 @@ class MyCommand : Microsoft.CommandPalette.Extensions.Toolkit.InvokableCommand {
3737

3838
## Create a page of commands
3939

40-
TODO!
40+
```csharp
41+
using Microsoft.CommandPalette.Extensions.Toolkit;
42+
43+
class MyPage : ListPage {
44+
public MyPage()
45+
{
46+
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.png");
47+
Title = "My sample extension";
48+
Name = "Open";
49+
}
50+
51+
public override IListItem[] GetItems()
52+
{
53+
return [
54+
new ListItem(new OpenUrlCommand("https://github.com"))
55+
{
56+
Title = "Open GitHub",
57+
},
58+
new ListItem(new OpenUrlCommand("https://learn.microsoft.com"))
59+
{
60+
Title = "Open Microsoft Learn",
61+
},
62+
new ListItem(new OpenUrlCommand("https://github.com/microsoft/PowerToys"))
63+
{
64+
Title = "Open PowerToys on GitHub",
65+
},
66+
new ListItem(new CopyTextCommand("Foo bar"))
67+
{
68+
Title = "Copy 'Foo bar' to the clipboard",
69+
},
70+
];
71+
}
72+
}
73+
```
74+
75+
## Icons
76+
77+
Icons using the [`IIconInfo`](./microsoft-commandpalette-extensions/iiconinfo.md) class can be specified in a number of ways. Here are some examples:
78+
79+
```csharp
80+
81+
using Microsoft.CommandPalette.Extensions.Toolkit;
82+
83+
namespace ExtensionName;
84+
85+
internal sealed class Icons
86+
{
87+
// Icons can be specified as a Segoe Fluent icon, ...
88+
internal static IconInfo OpenFile { get; } = new("\uE8E5"); // OpenFile
89+
90+
// ... or as an emoji, ...
91+
internal static IconInfo OpenFileEmoji { get; } = new("📂");
92+
93+
// ... Or as a path to an image file, ...
94+
internal static IconInfo FileExplorer { get; } = IconHelpers.FromRelativePath("Assets\\FileExplorer.png");
95+
96+
// ... which can be on a remote server, or svg's, or ...
97+
internal static IconInfo FileExplorerSvg { get; } = new("https://raw.githubusercontent.com/microsoft/PowerToys/refs/heads/main/src/modules/cmdpal/Exts/Microsoft.CmdPal.Ext.Indexer/Assets/FileExplorer.svg");
98+
99+
// Or they can be embedded in a exe / dll:
100+
internal static IconInfo FolderIcon { get; } = new("%systemroot%\\system32\\system32\\shell32.dll,3");
101+
}
102+
```
41103

42104
## Related content
43105

0 commit comments

Comments
 (0)