/**
* ContentsControl - Table of Contents Display Control
*
* Provides an interactive table of contents for document navigation.
* Extracts headings from the document and displays them in a hierarchical
* structure with clickable links for quick navigation.
*
* Features:
* - Automatic heading extraction from document
* - Hierarchical display with proper indentation
* - Clickable navigation links with smooth scrolling
* - Real-time updates when document structure changes
* - Search functionality within the table of contents
*
* Dependencies:
* - ControlBase (base control functionality)
*/
/**
* ContentsControl - Interactive table of contents control
*
* Built on the base class architecture for consistency with other panels.
* Only implements content-specific functionality while inheriting all
* common panel behavior from ControlBase.
*/
class ContentsControl extends ControlBase {
constructor() {
super();
// Configure for contents functionality
this.config = {
icon: '📋',
title: 'Contents',
className: 'contents-control',
defaultContent: 'Loading table of contents...',
ariaLabel: 'Table of Contents Control',
position: 'w' // West positioning
};
// Contents-specific state
this.headings = [];
this.lastScanTime = null;
this.updateInterval = null;
this.searchQuery = '';
}
/**
* Generate contents control content (called by base class buildContent)
*/
generateContent() {
// Extract headings first
this.extractHeadings();
return this.safeOperation(() => {
if (this.headings.length === 0) {
return `