You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/powertoys/command-palette/adding-commands.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,7 +193,7 @@ There are two different kinds of pages you can show:
193
193
-[ContentPage](./microsoft-commandpalette-extensions-toolkit/contentpage.md) - This is a page that shows rich content to the user. This allows you to specify abstract content, and let Command Palette worry about rendering the content in a native experience. There are two different types of content supported so far:
194
194
-[Markdown content](./using-markdown-content.md) - This is content that's written in Markdown, and is rendered in the Command Palette. See [MarkdownContent](./microsoft-commandpalette-extensions-toolkit/markdowncontent.md) for details.
195
195
196
-

196
+

197
197
198
198
-[Form content](./using-form-pages.md) - This is content that shows a form to the user, and then returns the results of that form to the extension. These are powered by [Adaptive Cards](https://aka.ms/adaptive-cards) This is useful for getting user input, or displaying more complex layouts of information. See [FormContent](./microsoft-commandpalette-extensions-toolkit/formcontent.md) for details.
Copy file name to clipboardExpand all lines: hub/powertoys/command-palette/using-markdown-content.md
+43-20Lines changed: 43 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,18 +17,16 @@ So far, we've only shown how to display a list of commands in a **ListPage**. Ho
17
17
18
18
[IContentPage](./microsoft-commandpalette-extensions/icontentpage.md) (and its toolkit implementation, [ContentPage](microsoft-commandpalette-extensions-toolkit/contentpage.md)) is the base for displaying all types of rich content in the Command Palette. To display markdown content, you can use the [MarkdownContent](microsoft-commandpalette-extensions-toolkit/markdowncontent.md) class.
19
19
20
-
As a simple example, we can create the following page:
21
-
22
-
> [!NOTE]
23
-
> If working from prior sections, modify the code below from `MarkdownPage` to `<ExtensionName>Page`.
20
+
1. In your <ExtensionName>Page.cs, replace content with:
@@ -40,49 +38,74 @@ public class MarkdownPage : ContentPage
40
38
}
41
39
```
42
40
43
-
In this example, a new **MarkdownPage** that displays a simple markdown string is created. The **MarkdownContent** class takes a string of markdown content and renders it in the Command Palette.
41
+
1. Deploy your extension
42
+
1. In command palette, `Reload`
44
43
45
-
You can also add multiple blocks of content to a page. For example, you can add two blocks of markdown content:
44
+
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.
46
45
47
-
```csharp
46
+

47
+
48
+
You can also add multiple blocks of content to a page. For example, you can add two blocks of markdown content.
49
+
50
+
1. Update `GetContent`:
51
+
52
+
```diff
48
53
public override IContent[] GetContent()
49
54
{
50
55
return [
51
56
new MarkdownContent("# Hello, world!\n This is a **markdown** page."),
52
-
newMarkdownContent("## Second block\n This is another block of content."),
57
+
+ new MarkdownContent("## Second block\n This is another block of content."),
53
58
];
54
59
}
55
60
```
56
61
62
+
1. Deploy your extension
63
+
1. In command palette, `Reload`
64
+
57
65
This allows you to mix-and-match different types of content on a single page.
58
66
59
-
## Adding commands
67
+
## Adding CommandContextItem
68
+
69
+
You can also add commands to a `ContentPage`. This allows you to add additional commands to be invoked by the user, while in the context of the content. For example, if you had a page that displayed a document, you could add a command to open the document in File Explorer:
60
70
61
-
You can also add commands to a **ContentPage**. This allows you to add additional commands to be invoked by the user, while in the context of the content. For example, if you had a page that displayed a document, you could add a command to open the document in File Explorer:
71
+
1. In your <ExtensionName>Page.cs, add `doc_path`, `Commands` and `MarkdownContent`:
0 commit comments