feat(AdvancedPaste): add Paste as Rich Text option natively - #49460
feat(AdvancedPaste): add Paste as Rich Text option natively#49460RamonRiosJr wants to merge 4 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
@microsoft-github-policy-service agree |
daverayment
left a comment
There was a problem hiding this comment.
Hi @RamonRiosJr. Thanks for your contribution. I have a few questions and comments at this stage:
- You reference #36329 as the originating issue. This is unrelated to pasting RichText.
- You mention that you've been cleared to start on this by checking the Communication checkbox. Can you point to where this communication is, please.
- You've checked Dev docs, New binaries, and Documentation updated, but there are no doc updates or new binaries. Please uncheck these.
- Your
ContentCopyAndPasteAsRichText()test includes manyThread.Sleep()delays which would impact the time taken to run the CI build. These total 35 seconds, including 15 seconds each for opening Notepad and the Advanced Paste window. I think there are other methods for chaining these actions which don't require such long delays. - There is an existing issue regarding pasting Markdown as RichText here: #40202. This includes unresolved questions about whether it would be better to have HTML as a single output for multiple transformations (i.e. to auto-format like a Word Processor application). Ideally, there should be discussion and agreement about an approach before a PR is produced, as it means everyone's opinion is respected and eases the review burden.
In light of the above, this work cannot be approved at this time.
|
Understood completely. Apologies for the boilerplate checkboxes and the hardcoded Thread.Sleep() calls in the UI test—that was sloppy on my end. I have just pushed a new commit that rips out the static delays and replaces them with a proper, blazing-fast polling loop. I have also left a comment on #40202 to join the architectural discussion regarding the single-output transformations. Let me know what the core team decides on that thread, and I'll be happy to pivot this PR's architecture to match the vision. |
Summary of the Pull Request
Adds a native "Paste as Rich Text" option to the Advanced Paste module. This allows users to copy Markdown text (or raw HTML) to their clipboard and paste it directly into word processors (like MS Word or Outlook) as perfectly formatted Rich Text, utilizing the native
CF_HTMLclipboard format.It natively ports the exact functionality requested by the community to convert Markdown strings into rich formatted text on the fly, saving users from having to run intermediate conversion scripts.
It leverages
Markdig.Signed(which is already a trusted and used dependency inFilePreviewCommon) to parse the Markdown into HTML, and then uses the native WindowsHtmlFormatHelperto package it asCF_HTMLin aDataPackage. It follows the exact architectural pattern of the existingPaste as Markdownlogic.PR Checklist
TestCasePasteAsRichTextinAdvancedPasteUITest.cs)PasteAsRichTexttoResources.resw)MicrosoftDocs/windows-uwpto document the new shortcut action if accepted)Detailed Description of the Pull Request / Additional comments
AdvancedPaste.csprojto include the existingMarkdig.Signedpackage reference.PasteFormats.RichTextto thePasteFormatsenum, setting it as a core action.RichTextHelper.csto execute the Markdig Markdown-to-HTML conversion pipeline.DataPackageHelpers.cswithCreateFromHtml()to properly wrap HTML strings with WindowsCF_HTMLheaders for Word/Outlook compatibility.AdvancedPasteUITest.cs.Validation Steps Performed
TestCasePasteAsRichTexttoAdvancedPasteUITest.cs. This simulates taking a Markdown source file (PasteAsRichTextFile.txt), triggering the Advanced Paste UI button ("Paste as Rich Text") inside WordPad, and verifying that the resulting pasted RTF structure validates correctly.Markdig.Signedis already a cleared dependency (used inFilePreviewCommon), removing the need for PM/Security clearance for a net-new dependency.