Merge pull request #2804 from Jwaegebaert/pageNavCollapsibleHeaders

react-page-navigator - Capability to find collapsible section headers
This commit is contained in:
Hugo Bernier 2022-06-29 20:26:22 -07:00 committed by GitHub
commit 405f34dd89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -27,6 +27,7 @@ Version|Date|Comments
1.1|October 20, 2021|SPFx Upgraded to 1.12.1 and code refactored 1.1|October 20, 2021|SPFx Upgraded to 1.12.1 and code refactored
1.2|May, 2022|SPFx Upgraded to 1.14.0 1.2|May, 2022|SPFx Upgraded to 1.14.0
1.3|June 9, 2022|Updated React package from `^16.14.0` to `16.13.1` 1.3|June 9, 2022|Updated React package from `^16.14.0` to `16.13.1`
1.4|June 29, 2022|Adds the capability to find collapsible section headers and insert them into the navigation
## Minimal Path to Awesome ## Minimal Path to Awesome

View File

@ -9,7 +9,7 @@
"This web part fetches all the automatically added Header anchor tags in a SharePoint page and displays them in a Navigation component." "This web part fetches all the automatically added Header anchor tags in a SharePoint page and displays them in a Navigation component."
], ],
"creationDateTime": "2019-09-05", "creationDateTime": "2019-09-05",
"updateDateTime": "2022-05-31", "updateDateTime": "2022-06-29",
"products": [ "products": [
"SharePoint" "SharePoint"
], ],

View File

@ -65,6 +65,15 @@ export class SPService {
/* Traverse through all the Text web parts in the page */ /* Traverse through all the Text web parts in the page */
canvasContent1JSON.map((webPart) => { canvasContent1JSON.map((webPart) => {
if (webPart.zoneGroupMetadata) {
const headingValue = webPart.zoneGroupMetadata.displayName;
const anchorUrl = this.GetAnchorUrl(headingValue);
this.allUrls.push(anchorUrl);
/* Add link to Nav element */
anchorLinks.push({ name: headingValue, key: anchorUrl, url: anchorUrl, links: [], isExpanded: webPart.zoneGroupMetadata.isExpanded });
}
if (webPart.innerHTML) { if (webPart.innerHTML) {
const HTMLString: string = webPart.innerHTML; const HTMLString: string = webPart.innerHTML;
@ -75,7 +84,11 @@ export class SPService {
headers.forEach(header => { headers.forEach(header => {
const headingValue = header.textContent; const headingValue = header.textContent;
const headingOrder = parseInt(header.tagName.substring(1)); let headingOrder = parseInt(header.tagName.substring(1));
if (webPart.zoneGroupMetadata) {
headingOrder++;
}
const anchorUrl = this.GetAnchorUrl(headingValue); const anchorUrl = this.GetAnchorUrl(headingValue);
this.allUrls.push(anchorUrl); this.allUrls.push(anchorUrl);