pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
416 stars 643 forks source link

Set-PnPClientSideText causing additional <p> tag to be added #1998

Open prawnz opened 6 years ago

prawnz commented 6 years ago

Category

[X] Bug [ ] Enhancement

Environment

[X] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

Set-PnPClientSideText to set the text as according to the text passed in via the -Text parameter

Observed Behavior

The following text is to be loaded using Set-PnPClientSideText

<h2>Policy Objective</h2><p>The policy establishes the development requirements for constructing
 vehicle crossovers in road reserves.</p>

The command used is where $textToUpdate contained the above Set-PnPClientSideText -Page $PageName -InstanceId $control.InstanceId -Text $textToUpdate

The following text what appears after using Set-PnPClientSideText

Text              : <p></p><h2>Policy Objective</h2><p>The policy establishes the development 
                    requirements for constructing vehicle crossovers in road reserves.</p><p></p>
Rte               : 
PreviewText       : 
Type              : OfficeDevPnP.Core.Pages.ClientSideText
SpControlData     : OfficeDevPnP.Core.Pages.ClientSideTextControlData
Section           : OfficeDevPnP.Core.Pages.CanvasSection
Column            : OfficeDevPnP.Core.Pages.CanvasColumn
DataVersion       : 1.0
CanvasDataVersion : 1.0
CanvasControlData : 
ControlType       : 4
JsonControlData   : 
InstanceId        : d47cf563-b88b-42af-859b-cd6665da358d
Order             : 1

Steps to Reproduce

Use the following command Set-PnPClientSideText -Page $PageName -InstanceId $InstanceId -Text "<h2>Policy Objective</h2><p>The policy establishes the development requirements for constructing vehicle crossovers in road reserves.</p>"

Note : You will have to use your own page and section with a Text Webpart to set it up. Same error also appears using the following which I believe both cmdlet uses the same api calls Add-PnPClientSideText -Page $PageName -Text "<h2>Policy Objective</h2><p>The policy establishes the development requirements for constructing vehicle crossovers in road reserves.</p>" -Column 1 -Order 1 -Section 1

jansenbe commented 6 years ago

The text control internally wraps the contents in a P tag, provide <p><h2>Policy Objective</h2>The policy establishes the development requirements for constructing vehicle crossovers in road reserves.</p> as input and see if that works

prawnz commented 6 years ago

Hey @jansenbe , tried your method, however it added the close tag in the beginning and added the opening p tag at the end <p></p><h2>Policy Objective</h2>The policy establishes the development requirements for constructing vehicle crossovers in road reserves.<p></p>

Even editing in SharePoint showed the additional space on the top and bottom. So now I don't know if this is a SharePoint RTE thingy or something else

prawnz commented 5 years ago

Any updates on this?

kachihro commented 5 years ago

Same issue for me - this seems like a bug - compared to how it's working in the UI.

Looks to be a problem with the checking for "DIV" and "P" tags - in this code ; OfficeDevPnP.Core.Pages.ClientSideText

phillipharding commented 5 years ago

I'm also seeing the same behaviour using PnP Provisioning for Client-side pages.

mag210 commented 5 years ago

We are also seeing this space appear in text webparts when we provision new sites. This looks to be a bug in the provisioning engine where an empty

class is generated before the heading text. Do we have an eta on when this will be resolved? It actually presents quite an issue when you want to template intranet based sites for end users

zshane15 commented 4 years ago

I'm still experiencing this same issue with the additional

tag at the top. I tried wrapping everything in a

tag but that just added one to the top and bottom.

Looks like the issue is happening only in the default section. I have other sections/columns that aren't producing this issue.

lassealfastsen commented 4 years ago

I Have the exact same problem, it is a bit annoying and my OCD is killing me, anybody find a workaround?