pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
988 stars 662 forks source link

Tables disappear when editing modern pages. #1682

Open thlju opened 6 years ago

thlju commented 6 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

I'm experiencing an issue when using PowerShell to create modern pages containing HTML tables. I use Add-PnPClientSideText to add a table (see code below).

The pages are created with tables, but when I enter edit mode the tables are gone. Just an empty Text web part appears. If I press "Discard changes" (to enter display mode without changes), the page is displayed without tables. However, if I press F5 the page displays correctly. Should I choose to press "Save and close" or "Publish" when in edit mode, the tables are lost forever.

Expected behavior

If I add a table I expect it to appear on the page both on display and edit modes, i.e. I expect the page to be editable.

Actual behavior

When entering edit mode, the tables disappeares.

Steps to reproduce behavior

Run this from Windows PowerShell ISE:

Connect-PnPOnline –Url [my url here] –Credentials (Get-Credential) Add-PnPClientSidePage -Name "table_page" Add-PnPClientSideText -Page "table_page" -Text "<table><tr><td>This is cell 1</td><td>This is cell 2</td></tr></table>"

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

SharePointPnPPowerShellOnline

How did you install the PnP-PowerShell Cmdlets?

dimachernov commented 6 years ago

Can you try adding two div tags as below? Worked for me.

Add-PnPClientSideText -Page "table_page" -Text '
<div class="canvasRteResponsiveTable">
<div class="tableWrapper">
<table title="Table">
        <tbody>
                <tr>
                        <td>This is cell 1</td>
                        <td>This is cell 2</td>
                </tr>
        </tbody>
</table>
</div>
</div>`
thlju commented 6 years ago

Yes, it works when I wrap the table in the two div tags as you suggested.

I also created a page with some tables using the SharePoint GUI and noticed that all tables are automatically wrapped in these divs. Good to know.

Thanks for this, it really helped!