addHeaders()

in src/app/shared/table-of-contents/table-of-contents.ts [119:135]


  addHeaders(sectionName: string, docViewerContent: HTMLElement, sectionIndex = 0) {
    const links = Array.from(docViewerContent.querySelectorAll('h3, h4'), header => {
      // remove the 'link' icon name from the inner text
      const name = (header as HTMLElement).innerText.trim().replace(/^link/, '');
      const {top} = header.getBoundingClientRect();
      return {
        name,
        type: header.tagName.toLowerCase(),
        top: top,
        id: header.id,
        active: false
      };
    });

    this._linkSections[sectionIndex] = {name: sectionName, links};
    this._links.push(...links);
  }