Skip to content

Commit c4e96c7

Browse files
authored
CmdPal: Add hints about bookmark placeholders to the Add/Edit Bookmark form (#42793)
## Summary of the Pull Request This PR adds a short explanation to the Add/Edit Bookmark form, describing how to use placeholders in bookmark URLs or paths <img width="823" height="525" alt="image" src="https://github.com/user-attachments/assets/b66adfc4-2dbc-4934-8796-9d4ad46d9f5f" /> <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: #42265 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
1 parent 103429b commit c4e96c7

File tree

4 files changed

+123
-12
lines changed

4 files changed

+123
-12
lines changed

‎.github/actions/spell-check/expect.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ INITDIALOG
750750
INITGUID
751751
INITTOLOGFONTSTRUCT
752752
INLINEPREFIX
753-
Inlines
753+
inlines
754754
INPC
755755
inproc
756756
INPUTHARDWARE

‎src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs‎

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,72 @@ public AddBookmarkForm(BookmarkData? bookmark)
3030
"type": "Input.Text",
3131
"style": "text",
3232
"id": "bookmark",
33-
"value": {{JsonSerializer.Serialize(url, BookmarkSerializationContext.Default.String)}},
34-
"label": "{{Resources.bookmarks_form_bookmark_label}}",
33+
"value": {{EncodeString(url)}},
34+
"label": {{EncodeString(Resources.bookmarks_form_bookmark_label)}},
3535
"isRequired": true,
36-
"errorMessage": "{{Resources.bookmarks_form_bookmark_required}}"
36+
"errorMessage": {{EncodeString(Resources.bookmarks_form_bookmark_required)}},
37+
"placeholder": {{EncodeString(Resources.bookmarks_form_bookmark_placeholder)}}
3738
},
3839
{
3940
"type": "Input.Text",
4041
"style": "text",
4142
"id": "name",
42-
"label": "{{Resources.bookmarks_form_name_label}}",
43-
"value": {{JsonSerializer.Serialize(name, BookmarkSerializationContext.Default.String)}},
44-
"isRequired": false,
45-
"errorMessage": "{{Resources.bookmarks_form_name_required}}"
43+
"label": {{EncodeString(Resources.bookmarks_form_name_label)}},
44+
"value": {{EncodeString(name)}},
45+
"isRequired": false
46+
},
47+
{
48+
"type": "RichTextBlock",
49+
"inlines": [
50+
{
51+
"type": "TextRun",
52+
"text": {{EncodeString(Resources.bookmarks_form_hint_text1)}},
53+
"isSubtle": true,
54+
"size": "Small"
55+
},
56+
{
57+
"type": "TextRun",
58+
"text": " ",
59+
"isSubtle": true,
60+
"size": "Small"
61+
},
62+
{
63+
"type": "TextRun",
64+
"text": {{EncodeString(Resources.bookmarks_form_hint_text2)}},
65+
"fontType": "Monospace",
66+
"size": "Small"
67+
},
68+
{
69+
"type": "TextRun",
70+
"text": " ",
71+
"isSubtle": true,
72+
"size": "Small"
73+
},
74+
{
75+
"type": "TextRun",
76+
"text": {{EncodeString(Resources.bookmarks_form_hint_text3)}},
77+
"isSubtle": true,
78+
"size": "Small"
79+
},
80+
{
81+
"type": "TextRun",
82+
"text": " ",
83+
"isSubtle": true,
84+
"size": "Small"
85+
},
86+
{
87+
"type": "TextRun",
88+
"text": {{EncodeString(Resources.bookmarks_form_hint_text4)}},
89+
"fontType": "Monospace",
90+
"size": "Small"
91+
}
92+
]
4693
}
4794
],
4895
"actions": [
4996
{
5097
"type": "Action.Submit",
51-
"title": "{{Resources.bookmarks_form_save}}",
98+
"title": {{EncodeString(Resources.bookmarks_form_save)}},
5299
"data": {
53100
"name": "name",
54101
"bookmark": "bookmark"
@@ -59,6 +106,8 @@ public AddBookmarkForm(BookmarkData? bookmark)
59106
""";
60107
}
61108

109+
private static string EncodeString(string s) => JsonSerializer.Serialize(s, BookmarkSerializationContext.Default.String);
110+
62111
public override CommandResult SubmitForm(string payload)
63112
{
64113
var formInput = JsonNode.Parse(payload);

‎src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs‎

Lines changed: 48 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<comment>"Terminal" should be the localized name of the Windows Terminal</comment>
141141
</data>
142142
<data name="bookmarks_form_name_label" xml:space="preserve">
143-
<value>Name</value>
143+
<value>Name (optional)</value>
144144
</data>
145145
<data name="bookmarks_form_save" xml:space="preserve">
146146
<value>Save</value>
@@ -185,4 +185,20 @@
185185
<data name="bookmark_toast_failed_open_text" xml:space="preserve">
186186
<value>Failed to open {0}</value>
187187
</data>
188+
<data name="bookmarks_form_hint_text1" xml:space="preserve">
189+
<value>You can add placeholders to bookmarks, and Command Palette will prompt you to enter their values when you open the bookmark.
190+
A placeholder looks like this:</value>
191+
</data>
192+
<data name="bookmarks_form_hint_text2" xml:space="preserve">
193+
<value>{placeholder}</value>
194+
</data>
195+
<data name="bookmarks_form_hint_text3" xml:space="preserve">
196+
<value>— for example:</value>
197+
</data>
198+
<data name="bookmarks_form_hint_text4" xml:space="preserve">
199+
<value>https://www.bing.com/search?q={Query}</value>
200+
</data>
201+
<data name="bookmarks_form_bookmark_placeholder" xml:space="preserve">
202+
<value>Enter URL or file path, you can use {placeholders}, e.g. https://www.bing.com/search?q={Query}</value>
203+
</data>
188204
</root>

0 commit comments

Comments
 (0)