diff --git a/src/lib/PnP.Framework/Provisioning/Model/SharePoint/ModernExperiences/CanvasSection.cs b/src/lib/PnP.Framework/Provisioning/Model/SharePoint/ModernExperiences/CanvasSection.cs index b40c94591..238af3174 100644 --- a/src/lib/PnP.Framework/Provisioning/Model/SharePoint/ModernExperiences/CanvasSection.cs +++ b/src/lib/PnP.Framework/Provisioning/Model/SharePoint/ModernExperiences/CanvasSection.cs @@ -71,6 +71,10 @@ public CanvasControlCollection Controls /// public bool ShowDividerLine { get; set; } + /// + /// Defines Heading Level for collapsible Canvas Section Title of a Client-side Page. + /// + public int HeadingLevel { get; set; } #endregion #region Constructors @@ -93,7 +97,7 @@ public CanvasSection() /// Returns HashCode public override int GetHashCode() { - return (String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|", + return (String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|", this.Controls.Aggregate(0, (acc, next) => acc += (next != null ? next.GetHashCode() : 0)), Order.GetHashCode(), Type.GetHashCode(), @@ -103,7 +107,8 @@ public override int GetHashCode() (this.DisplayName != null ? this.DisplayName.GetHashCode() : 0), this.IsExpanded.GetHashCode(), this.IconAlignment.GetHashCode(), - this.ShowDividerLine.GetHashCode() + this.ShowDividerLine.GetHashCode(), + this.HeadingLevel.GetHashCode() ).GetHashCode()); } @@ -142,7 +147,8 @@ public bool Equals(CanvasSection other) this.DisplayName == other.DisplayName && this.IsExpanded == other.IsExpanded && this.IconAlignment == other.IconAlignment && - this.ShowDividerLine == other.ShowDividerLine + this.ShowDividerLine == other.ShowDividerLine && + this.HeadingLevel == other.HeadingLevel ); } diff --git a/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs b/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs index c0c6de973..8f53414e3 100644 --- a/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs +++ b/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs @@ -507,6 +507,13 @@ private void CreatePage(Web web, ProvisioningTemplate template, TokenParser pars typeof(PnP.Core.Model.SharePoint.IconAlignment), section.IconAlignment.ToString()); targetSection.ShowDividerLine = section.ShowDividerLine; + //XML-Schema does not support HeadingLevel-Value, so we need to get it from JsonControlData if not set through code manually + if (section.HeadingLevel == 0) + { + SetSectionHeadingLevel(section); + } + if( section.HeadingLevel > 0) + targetSection.HeadingLevel = section.HeadingLevel; } // Add controls to the section @@ -1105,6 +1112,20 @@ private static void SetZoneReflowStrategy(PnPCore.ICanvasColumn canvasColumn, JO } } + private static void SetSectionHeadingLevel(CanvasSection section) + { + var control = section.Controls.FirstOrDefault(p => !string.IsNullOrWhiteSpace(p.JsonControlData) && p.JsonControlData.ToLower().Contains("headinglevel")); + if (control != null) + { + var json = JsonConvert.DeserializeObject(control.JsonControlData); + var headingLevel = json.SelectToken("zoneGroupMetadata.headingLevel")?.Value(); + if (headingLevel.HasValue) + { + section.HeadingLevel = headingLevel.Value; + } + } + } + private static string DeterminePageName(TokenParser parser, BaseClientSidePage clientSidePage) { string pageName;