Skip to content

Commit 5cc875f

Browse files
Add info for using images in Command Palette Extension markdown content (#5868)
* Add info for using images in cmdpal ext markdown * Update hub/powertoys/command-palette/using-markdown-content.md Co-authored-by: Copilot <[email protected]> * Update hub/powertoys/command-palette/using-markdown-content.md Co-authored-by: Copilot <[email protected]> * Update note about large images * Change wording to sound less redundant * Intro and SEO updates --------- Co-authored-by: Copilot <[email protected]>
1 parent 937eba4 commit 5cc875f

1 file changed

Lines changed: 46 additions & 7 deletions

File tree

hub/powertoys/command-palette/using-markdown-content.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
---
2-
title: Display markdown content
3-
description: Learn how to display markdown in your Command Palette extension.
4-
ms.date: 3/23/2025
2+
title: Display markdown content in Command Palette extensions
3+
description: Learn how to display markdown content in your Command Palette extension. Create rich documentation, file previews, and interactive tutorials with formatted text and embedded commands.
4+
ms.date: 09/30/2025
55
ms.topic: how-to
66
no-loc: [PowerToys, Windows, Insider]
7-
# Customer intent: As a Windows developer, I want to learn how to develop an extension for the Command Palette.
7+
# Customer intent: As a Windows developer, I want to learn how to develop an extension for the Command Palette that displays markdown content, so that I can provide rich documentation or previews within the Command Palette.
88
---
99

1010
# Display markdown content
1111

1212
**Previous**: [Command Results](command-results.md)
1313

14+
The Command Palette supports rich content display beyond simple command lists. You can create extensions that show formatted text, documentation, and interactive content using markdown. This capability is particularly useful for:
15+
16+
- Displaying help documentation or user guides
17+
- Showing file previews or summaries
18+
- Providing formatted instructions or tutorials
19+
- Creating interactive content with embedded commands
20+
21+
This article shows you how to create pages that display markdown content in your Command Palette extension.
22+
1423
So far, we've only shown how to display a list of commands in a **ListPage**. However, you can also display rich content in your extension, such as markdown. This can be useful for showing documentation, or a preview of a document.
1524

1625
## Working with markdown content
@@ -63,7 +72,7 @@ public <ExtensionName>CommandsProvider()
6372

6473
In this example, a new `ContentPage` that displays a simple markdown string is created. The 'MarkdownContent' class takes a string of markdown content and renders it in the Command Palette.
6574

66-
![Screenshot of extension using ContentPage for markdown](../../images/command-palette/markdown.png)
75+
:::image type="content" source="../../images/command-palette/markdown.png" alt-text="Screenshot of Command Palette extension displaying markdown content with formatted text and document icon.":::
6776

6877
You can also add multiple blocks of content to a page. For example, you can add two blocks of markdown content.
6978

@@ -122,9 +131,39 @@ public class <ExtensionName>Page : ContentPage
122131
1. Select \<ExtensionName\>
123132
1. Press `Enter` key, the docs should open
124133

125-
![Screenshot of extension using CommandContextItem](../../images/command-palette/command-context-item.png)
134+
:::image type="content" source="../../images/command-palette/command-context-item.png" alt-text="Screenshot of Command Palette extension showing CommandContextItem with Open in File Explorer option.":::
135+
136+
## Add images to markdown content
137+
138+
With Command Palette in PowerToys 0.95 and later, you can add images to your markdown content from additional sources using one of the following schemes:
139+
140+
- File scheme: Enables loading images using the `file:` scheme.
141+
- This scheme intentionally restricts file URIs to absolute paths to ensure correct resolution when passed through the Command Palette extension/host boundary. In most cases, 3rd-party extensions provide the paths. However, the Command Palette host performs the actual loading and would otherwise resolve paths relative to itself.
142+
- Data scheme: Enables loading images from URIs with the `data:` scheme (both Base64 and URL-encoded forms).
143+
- **Note**: Before the changes introduced in PowerToys 0.95 and later, the markdown control could hang or become unresponsive when processing very large input, such as images larger than 5 MB or with dimensions exceeding 4000×4000 pixels, or markdown files exceeding 1 MB in size. Even with the changes, it is recommended to keep image file sizes below 5 MB and resize images to reasonable dimensions before embedding. For best results, compress images and split very large markdown content into smaller sections where possible.
144+
- `ms-appx` scheme: This scheme is now supported for loading images.
145+
- **Note**: Since the Command Palette host performs the loading, `ms-appx:` resolution applies to the host and not the extensions, which limits its usefulness.
146+
- `ms-appdata` scheme: This scheme is now supported for loading images.
147+
- Similar to `ms-appx:`, `ms-appdata:` resolution applies to the host, not the extensions. This limits its usefulness for 3rd-party extensions.
148+
149+
Additionally, Command Palette in PowerToys 0.95 and later introduces the concept of image source hints, implemented as query string parameters piggy-backed on the original URI.
150+
151+
These hints allow extension developers to influence the behavior of images within the markdown content.
152+
153+
- `--x-cmdpal-fit`
154+
- `none`: No automatic scaling, provides image as is (default)
155+
- `fit`: Scale to fit the available space
156+
- `--x-cmdpal-upscale`
157+
- `true`: Allow upscaling
158+
- `false`: Downscale only (default)
159+
- `--x-cmdpal-width`: Desired width in pixels
160+
- `--x-cmdpal-height`: Desired height in pixels
161+
- `--x-cmdpal-maxwidth`: Max width in pixels
162+
- `--x-cmdpal-maxheight`: Max height in pixels
163+
164+
See the [SampleMarkdownImages](https://github.com/microsoft/PowerToys/blob/main/src/modules/cmdpal/ext/SamplePagesExtension/Pages/SampleMarkdownImagesPage.cs) page in the [SamplePagesExtension](https://github.com/microsoft/PowerToys/tree/main/src/modules/cmdpal/ext/SamplePagesExtension) generic sample project in the PowerToys GitHub repository for examples of using images in your extension's markdown content.
126165

127-
### Next up: [Get user input with forms](using-form-pages.md)
166+
## Next up: [Get user input with forms](using-form-pages.md)
128167

129168
## Related content
130169

0 commit comments

Comments
 (0)