UNPKG

semantic-heading-hierarchy

Version:

A JavaScript library that automatically invisibly corrects improper heading hierarchies for better accessibility. Used for user or admin edited content where the developer doesn't have 100% direct control over the content.

38 lines (32 loc) 1.1 kB
import { healHeadings } from './core.js'; import { createLoggingInterface } from './logging.js'; import { SemanticHeadingHierarchyInterface } from './types.js'; // Re-export types for public API export type { FixOptions } from './types.js'; /** * Semantic Heading Hierarchy API */ export const SemanticHeadingHierarchy: SemanticHeadingHierarchyInterface = { /** * Fix heading hierarchies in the specified container * @param containerOrSelector - CSS selector string or DOM element to search within * @param options - Options object or boolean for logResults (for backwards compatibility) */ fix: healHeadings, /** * Logging control methods */ logging: createLoggingInterface() }; // Export as default for convenience export default SemanticHeadingHierarchy; // Browser global declarations for window object declare global { interface Window { SemanticHeadingHierarchy: typeof SemanticHeadingHierarchy; } } // Make available on window object for browser usage if (typeof window !== 'undefined') { window.SemanticHeadingHierarchy = SemanticHeadingHierarchy; }