pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
205 stars 143 forks source link

Invoke-PnPSiteTemplate adds blank line above Heading 1 text in Text Web Parts #197

Closed ericpskl closed 3 years ago

ericpskl commented 3 years ago

Summary of issue:

When creating or updating a SharePoint Online page using Invoke-PnPSiteTemplate, an extra line of whitespace is added above "Heading 1" text.

Version:

Get-InstalledModule -Name PnP.Powershell

Version    Name                                Repository           Description                                                                                                                                                             
-------    ----                                ----------           -----------                                                                                                                                                             
1.3.0      PnP.PowerShell                      PSGallery            Microsoft 365 Patterns and Practices PowerShell Cmdlets                                                                                                                 

Steps to reproduce:

Create a new Modern page in SharePoint online. Add a single Text web part, with one line of text formatted as Heading 1.

initial

Export this page to XML: Export-PnPPage -Identity Test-Page-12345.aspx -Out Test-Page-12345.xml -Force

Inspect the XML template and confirm that there is no extra blank line present in the webpart's XML:

<pnp:CanvasControlProperty Key="Text" Value="&lt;h2&gt;There is no whitespace before this sentence (Heading 1)&lt;/h2&gt;&lt;p&gt;&lt;br&gt;&lt;/p&gt;" />

Apply the XML as a template (this will overwrite the page): Invoke-PnPSiteTemplate -Path .\Test-Page-12345.xml

Load the page and observe that a blank line has been inserted above the "Heading 1" formatted text. (It is easier to see the extra space by going into Edit mode on the page)

after2

Any suggestions appreciated!

jansenbe commented 3 years ago

Known bug that I need to fix. All text are wrapped in a P element when being added via the API, but when there a H then that's not needed. The extra P causes the line break you see I think

ericpskl commented 3 years ago

Thanks @jansenbe

jansenbe commented 3 years ago

@ericpskl : just fixed this one, will be part of the next nightly of PnP Framework and PnP PowerShell

ericpskl commented 3 years ago

Thanks @jansenbe !!!