From c4e96c7ee959e106649e88b4cc8137ee2a646053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pol=C3=A1=C5=A1ek?= Date: Tue, 28 Oct 2025 20:28:46 +0100 Subject: [PATCH] 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 image ## 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 ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .github/actions/spell-check/expect.txt | 2 +- .../Pages/AddBookmarkForm.cs | 65 ++++++++++++++++--- .../Properties/Resources.Designer.cs | 50 +++++++++++++- .../Properties/Resources.resx | 18 ++++- 4 files changed, 123 insertions(+), 12 deletions(-) diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index 37ce368394..cd757f1552 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -750,7 +750,7 @@ INITDIALOG INITGUID INITTOLOGFONTSTRUCT INLINEPREFIX -Inlines +inlines INPC inproc INPUTHARDWARE diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs index 6931064a90..e165bfd0d4 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Pages/AddBookmarkForm.cs @@ -30,25 +30,72 @@ internal sealed partial class AddBookmarkForm : FormContent "type": "Input.Text", "style": "text", "id": "bookmark", - "value": {{JsonSerializer.Serialize(url, BookmarkSerializationContext.Default.String)}}, - "label": "{{Resources.bookmarks_form_bookmark_label}}", + "value": {{EncodeString(url)}}, + "label": {{EncodeString(Resources.bookmarks_form_bookmark_label)}}, "isRequired": true, - "errorMessage": "{{Resources.bookmarks_form_bookmark_required}}" + "errorMessage": {{EncodeString(Resources.bookmarks_form_bookmark_required)}}, + "placeholder": {{EncodeString(Resources.bookmarks_form_bookmark_placeholder)}} }, { "type": "Input.Text", "style": "text", "id": "name", - "label": "{{Resources.bookmarks_form_name_label}}", - "value": {{JsonSerializer.Serialize(name, BookmarkSerializationContext.Default.String)}}, - "isRequired": false, - "errorMessage": "{{Resources.bookmarks_form_name_required}}" + "label": {{EncodeString(Resources.bookmarks_form_name_label)}}, + "value": {{EncodeString(name)}}, + "isRequired": false + }, + { + "type": "RichTextBlock", + "inlines": [ + { + "type": "TextRun", + "text": {{EncodeString(Resources.bookmarks_form_hint_text1)}}, + "isSubtle": true, + "size": "Small" + }, + { + "type": "TextRun", + "text": " ", + "isSubtle": true, + "size": "Small" + }, + { + "type": "TextRun", + "text": {{EncodeString(Resources.bookmarks_form_hint_text2)}}, + "fontType": "Monospace", + "size": "Small" + }, + { + "type": "TextRun", + "text": " ", + "isSubtle": true, + "size": "Small" + }, + { + "type": "TextRun", + "text": {{EncodeString(Resources.bookmarks_form_hint_text3)}}, + "isSubtle": true, + "size": "Small" + }, + { + "type": "TextRun", + "text": " ", + "isSubtle": true, + "size": "Small" + }, + { + "type": "TextRun", + "text": {{EncodeString(Resources.bookmarks_form_hint_text4)}}, + "fontType": "Monospace", + "size": "Small" + } + ] } ], "actions": [ { "type": "Action.Submit", - "title": "{{Resources.bookmarks_form_save}}", + "title": {{EncodeString(Resources.bookmarks_form_save)}}, "data": { "name": "name", "bookmark": "bookmark" @@ -59,6 +106,8 @@ internal sealed partial class AddBookmarkForm : FormContent """; } + private static string EncodeString(string s) => JsonSerializer.Serialize(s, BookmarkSerializationContext.Default.String); + public override CommandResult SubmitForm(string payload) { var formInput = JsonNode.Parse(payload); diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs index e5a65f2db3..02f95cf479 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.CmdPal.Ext.Bookmarks.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { @@ -177,6 +177,15 @@ namespace Microsoft.CmdPal.Ext.Bookmarks.Properties { } } + /// + /// Looks up a localized string similar to Enter URL or file path, you can use {placeholders}, e.g. https://www.bing.com/search?q={Query}. + /// + public static string bookmarks_form_bookmark_placeholder { + get { + return ResourceManager.GetString("bookmarks_form_bookmark_placeholder", resourceCulture); + } + } + /// /// Looks up a localized string similar to URL or file path is required. /// @@ -187,7 +196,44 @@ namespace Microsoft.CmdPal.Ext.Bookmarks.Properties { } /// - /// Looks up a localized string similar to Name. + /// Looks up a localized string similar to You can add placeholders to bookmarks, and Command Palette will prompt you to enter their values when you open the bookmark. + ///A placeholder looks like this:. + /// + public static string bookmarks_form_hint_text1 { + get { + return ResourceManager.GetString("bookmarks_form_hint_text1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {placeholder}. + /// + public static string bookmarks_form_hint_text2 { + get { + return ResourceManager.GetString("bookmarks_form_hint_text2", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to — for example:. + /// + public static string bookmarks_form_hint_text3 { + get { + return ResourceManager.GetString("bookmarks_form_hint_text3", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to https://www.bing.com/search?q={Query}. + /// + public static string bookmarks_form_hint_text4 { + get { + return ResourceManager.GetString("bookmarks_form_hint_text4", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name (optional). /// public static string bookmarks_form_name_label { get { diff --git a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx index 763c697f2e..45f57c0d77 100644 --- a/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx +++ b/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Bookmark/Properties/Resources.resx @@ -140,7 +140,7 @@ "Terminal" should be the localized name of the Windows Terminal - Name + Name (optional) Save @@ -185,4 +185,20 @@ Failed to open {0} + + You can add placeholders to bookmarks, and Command Palette will prompt you to enter their values when you open the bookmark. +A placeholder looks like this: + + + {placeholder} + + + — for example: + + + https://www.bing.com/search?q={Query} + + + Enter URL or file path, you can use {placeholders}, e.g. https://www.bing.com/search?q={Query} + \ No newline at end of file