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
200 stars 140 forks source link

Script Editor Mapping Restrictions #1034

Open nloand opened 3 days ago

nloand commented 3 days ago

Attempting to map the script editor web part on the page conversion, and it does work correctly, but it only works if the script editor is one line and doesn't have special characters like semi-colons.

Is there a way to force it to bring the code over as is? If I have to edit every page to clean up the HTML from

<div id="ctl00_PlaceHolderMain_ctl00__ControlWrapper_SummaryLinkFieldControl" style="display:inline"> <div id="slwp_ctl00_PlaceHolderMain_ctl00_ctl00" class="slm-layout-main slwpmarker mt-1"> <div class="dfwp-column col-12"> <div class="slm-layout-main groupmarker"> <ul class="dfwp-list ml-0"> <li class="ml-0">...

to <div id="slwp_ctl00_PlaceHolderMain_ctl00_ctl00" class="slm-layout-main slwpmarker mt-1"><div class="dfwp-column col-12"><div class="slm-layout-main groupmarker"><ul class="dfwp-list ml-0"><li class="ml-0">...

Defeats the purpose of the automation.

I get the following errors:

6/27/2024 9:41:52 PM - [page 1)

_'0x09' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 1166. at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 json, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at PnP.Core.Model.SharePoint.PageWebPart.set_PropertiesJson(String value) at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List1 webParts) at PnP.Framework.Modernization.Publishing.PublishingPageTransformator.Transform(PublishingPageTransformationInformation publishingPageTransformationInformation)_

6/27/2024 9:41:55 PM - [page 2)

_'0x0D' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 272. at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan1 json, JsonTypeInfo1 jsonTypeInfo) at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options) at PnP.Core.Model.SharePoint.PageWebPart.set_PropertiesJson(String value) at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List1 webParts) at PnP.Framework.Modernization.Publishing.PublishingPageTransformator.Transform(PublishingPageTransformationInformation publishingPageTransformationInformation)_

Log for example page (page 1 above)

Transformation Details: Page 1

Page Transformation Settings

Property Setting
Engine version 1.14.3.0
Overwrite True
Target Page Name index.aspx
Target Page Folder
Target Page Folder Overrides Default Folder False
Keep Page Specific Permissions False
Remove Empty Sections And Columns True
Handle Wiki Images And Videos True
Add Table List Image As Image Web Part True
Keep Page Creation Modification Information True
Publish Created Page True
Post As News False
Disable Page Comments True
Skip Url Rewrite False
Skip Default Url Rewrite False
Url Mapping File urlmapping.csv
Skip Hidden Web Parts False
Term Mapping File
Skip Term Store Mapping False
Skip User Mapping False
User Mapping File
L D A P Connection String
Skip Telemetry False

Transformation Operation Details

Date Operation Actions Performed
6/27/2024 9:41:48 PM Input Validation Validation checks complete
6/27/2024 9:41:48 PM SharePoint Connection Loading client context objects
6/27/2024 9:41:48 PM SharePoint Connection Loading target client context object
6/27/2024 9:41:48 PM Page Creation Detect if the page is living inside a folder
6/27/2024 9:41:48 PM Page Creation Just try to load the page in the fastest possible manner, we only want to see if the page exists or not
6/27/2024 9:41:49 PM Page Creation The page already exists in target location
6/27/2024 9:41:50 PM Page Creation Modern page created
6/27/2024 9:41:50 PM Article page handling Transforming source page as Article page
6/27/2024 9:41:50 PM Article page handling Recognized source page as a Publishing Page - Analyzing web parts and page layouts
6/27/2024 9:41:50 PM Page Layout Manager Page uses xxx as page layout, mapping that will be used is xxx
6/27/2024 9:41:52 PM Article page handling Splitting images and videos from wiki text - as modern text web part does not support embedded images and videos
6/27/2024 9:41:52 PM Set Page Title Setting the modern page title: Cyber and Operational Technology
6/27/2024 9:41:52 PM Article page handling Preparing content transformation
6/27/2024 9:41:52 PM Article page handling Transforming content
6/27/2024 9:41:52 PM Content Transform Transforming web parts
6/27/2024 9:41:52 PM Web Part Mapping Web Part:'WikiText' of type 'SharePointPnP.Modernization.WikiTextPart' is being transformed
6/27/2024 9:41:52 PM Web Part Mapping Processing selector functions
6/27/2024 9:41:52 PM Web Part Mapping Combining mapping data
6/27/2024 9:41:52 PM Adding Web Parts to Target Page Added 'Client Side Text Web Part' to target page
6/27/2024 9:41:52 PM Web Part Mapping Web Part:'Content Editor' of type 'Microsoft.SharePoint.WebPartPages.ContentEditorWebPart' is being transformed
6/27/2024 9:41:52 PM Web Part Mapping Processing selector functions
6/27/2024 9:41:52 PM Web Part Mapping Combining mapping data
6/27/2024 9:41:52 PM Adding Web Parts to Target Page Added 'Client Side Text Web Part' to target page
6/27/2024 9:41:52 PM Web Part Mapping Web Part:'Script Editor' of type 'Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart' is being transformed
6/27/2024 9:41:52 PM Web Part Mapping Processing selector functions
6/27/2024 9:41:52 PM Web Part Mapping Combining mapping data
6/27/2024 9:41:52 PM Adding Web Parts to Target Page Using 'custom' modern web part

Related issue: https://github.com/pnp/modernization/issues/606