{"version":3,"file":"ArticleJumpLinks.CaRDMITG.mjs","names":["useState","useRef","contentElements"],"sources":["https:/framerusercontent.com/modules/TMvQYgBuuOY1P4RXowjM/jl93DhzZAqAuLs63MlgL/ArticleJumpLinks.js"],"sourcesContent":["// Article Jump Links Component - Dynamically generates navigation links from H2 and H3 headings in article content\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Custom Jump Link component that handles scrolling and styling\nfunction JumpLink({listNumber,title,targetId,level,isActive,numberFontFamily,numberFontSize,numberColor,titleFontFamily,titleFontSize,titleLineHeight,titleColor,borderColor,showNumbers,indentSubheadings,indentSize,activeColor,showActiveIndicator}){const handleClick=e=>{e.preventDefault();e.stopPropagation();const targetElement=document.getElementById(targetId);if(targetElement){targetElement.scrollIntoView({behavior:\"smooth\",block:\"start\"});}};const isSubheading=level===3;const leftPadding=indentSubheadings&&isSubheading?indentSize:0;const showNumberForThisItem=showNumbers&&!isSubheading// Only show numbers for H2, not H3\n;return /*#__PURE__*/_jsxs(\"div\",{onClick:handleClick,style:{display:\"grid\",gridTemplateColumns:showNumberForThisItem?\"40px 1fr\":\"1fr\",gap:showNumberForThisItem?\"12px\":\"0px\",padding:\"8px 0\",paddingLeft:`${leftPadding}px`,cursor:\"pointer\",borderBottom:`1px solid ${borderColor||\"#e5e5e5\"}`,alignItems:\"flex-start\",userSelect:\"none\",backgroundColor:\"transparent\",transition:\"all 0.2s ease\"},children:[showNumberForThisItem&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"40px\",fontFamily:numberFontFamily||\"JetBrains Mono, monospace\",fontSize:`${numberFontSize||14}px`,color:isActive&&showActiveIndicator?\"rgb(15, 25, 36)\"// neutral-950\n:numberColor||\"#666\",fontWeight:isActive&&showActiveIndicator?\"500\":\"normal\"},children:listNumber}),/*#__PURE__*/_jsx(\"div\",{style:{fontFamily:titleFontFamily||\"inherit\",fontSize:`${(titleFontSize||14)-(isSubheading?1:0)}px`,lineHeight:titleLineHeight||1.5,color:isActive&&showActiveIndicator?\"rgb(15, 25, 36)\"// neutral-950\n:titleColor||\"#333\",fontWeight:isActive&&showActiveIndicator?\"500\"// medium font weight\n:isSubheading?\"400\":\"400\",opacity:isSubheading?.8:1},children:title})]});}/**\n * Article Jump Links - Dynamically generates navigation from H2 and H3 headings\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ArticleJumpLinks({width=304,height=\"fit-content\",gap=0,numberFontFamily=\"JetBrains Mono, monospace\",numberFontSize=14,numberColor=\"#666\",titleFontFamily=\"inherit\",titleFontSize=14,titleLineHeight=1.5,titleColor=\"#333\",borderColor=\"#e5e5e5\",showNumbers=true,indentSubheadings=true,indentSize=20,activeColor=\"#0066FF\",showActiveIndicator=true,includeH3=true}){const[jumpLinks,setJumpLinks]=useState([]);const[activeId,setActiveId]=useState(\"\");const componentRef=useRef(null);useEffect(()=>{const findArticleHeadings=()=>{const currentElement=componentRef.current;if(!currentElement)return[];// Multiple strategies to find content\nconst findContentElements=()=>{const contentElements=[];// Strategy 1: Look for direct siblings (most likely in your case)\nconst parent=currentElement.parentElement;if(parent){const siblings=Array.from(parent.children);siblings.forEach(sibling=>{if(sibling!==currentElement){// Check if sibling contains headings\nconst headingsInSibling=sibling.querySelectorAll(\"h1, h2, h3\");if(headingsInSibling.length>0){contentElements.push(sibling);}}});}// Strategy 2: Look in parent's siblings\nif(contentElements.length===0&&parent?.parentElement){const grandParent=parent.parentElement;const parentSiblings=Array.from(grandParent.children);parentSiblings.forEach(parentSibling=>{if(parentSibling!==parent){const headingsInParentSibling=parentSibling.querySelectorAll(\"h1, h2, h3\");if(headingsInParentSibling.length>0){contentElements.push(parentSibling);}}});}// Strategy 3: Look for common content selectors anywhere in the document\nif(contentElements.length===0){const commonSelectors=['[role=\"article\"]',\"article\",\".content\",\".article-content\",\"#content\",\"main\",\"[data-content]\"];commonSelectors.forEach(selector=>{const elements=document.querySelectorAll(selector);elements.forEach(element=>{const headingsInElement=element.querySelectorAll(\"h1, h2, h3\");if(headingsInElement.length>0){contentElements.push(element);}});});}// Strategy 4: Scan entire document as fallback\nif(contentElements.length===0){const allHeadings=document.querySelectorAll(\"h1, h2, h3\");if(allHeadings.length>0){contentElements.push(document.body);}}return contentElements;};const contentElements=findContentElements();const sectionData=[];contentElements.forEach(contentElement=>{// Find H2 and optionally H3 elements based on includeH3 prop\nconst headingSelector=includeH3?\"h2, h3\":\"h2\";const headings=contentElement.querySelectorAll(headingSelector);headings.forEach((heading,index)=>{const level=parseInt(heading.tagName.charAt(1))// Extract 2 or 3 from H2/H3\n;let id=heading.id;// If heading doesn't have an ID, create one\nif(!id){const text=heading.textContent||\"\";id=`heading-${text.toLowerCase().replace(/[^a-z0-9]+/g,\"-\").replace(/^-+|-+$/g,\"\")}-${index}`;heading.id=id;}const title=heading.textContent?.trim()||\"\";if(title){sectionData.push({id,title,level});}});});return sectionData;};const updateJumpLinks=()=>{const sections=findArticleHeadings();setJumpLinks(sections);};// Initial scan with longer delay to ensure content is loaded\nconst timeoutId=setTimeout(updateJumpLinks,500);// More frequent rescans for dynamic content\nconst interval=setInterval(updateJumpLinks,1e3);return()=>{clearTimeout(timeoutId);clearInterval(interval);};},[includeH3])// Add includeH3 to dependency array so it re-scans when changed\n;// Track active section based on scroll position\nuseEffect(()=>{if(!showActiveIndicator||jumpLinks.length===0)return;const handleScroll=()=>{const scrollPosition=window.scrollY+100// Offset for better UX\n;let currentActiveId=\"\";// Find the heading that's currently in view\nfor(let i=jumpLinks.length-1;i>=0;i--){const element=document.getElementById(jumpLinks[i].id);if(element){const rect=element.getBoundingClientRect();const elementTop=rect.top+window.scrollY;if(elementTop<=scrollPosition){currentActiveId=jumpLinks[i].id;break;}}}if(currentActiveId!==activeId){setActiveId(currentActiveId);}};window.addEventListener(\"scroll\",handleScroll,{passive:true});handleScroll()// Initial check\n;return()=>{window.removeEventListener(\"scroll\",handleScroll);};},[jumpLinks,activeId,showActiveIndicator]);return /*#__PURE__*/_jsx(\"div\",{ref:componentRef,style:{width:typeof width===\"number\"?`${width}px`:width,height:typeof height===\"number\"?`${height}px`:height,display:\"flex\",flexDirection:\"column\",gap:`${gap}px`},children:jumpLinks.length>0?jumpLinks.map((link,index)=>{// Only count H2s for numbering\nconst h2Index=jumpLinks.slice(0,index+1).filter(l=>l.level===2).length;return /*#__PURE__*/_jsx(JumpLink,{listNumber:String(h2Index).padStart(2,\"0\"),title:link.title,targetId:link.id,level:link.level,isActive:activeId===link.id,numberFontFamily:numberFontFamily,numberFontSize:numberFontSize,numberColor:numberColor,titleFontFamily:titleFontFamily,titleFontSize:titleFontSize,titleLineHeight:titleLineHeight,titleColor:titleColor,borderColor:borderColor,showNumbers:showNumbers,indentSubheadings:indentSubheadings,indentSize:indentSize,activeColor:activeColor,showActiveIndicator:showActiveIndicator},link.id);}):/*#__PURE__*/_jsxs(\"div\",{style:{padding:\"16px\",backgroundColor:\"#f5f5f5\",color:\"#666\",textAlign:\"center\",fontSize:\"14px\",borderRadius:\"4px\"},children:[\"No headings found in article content\",/*#__PURE__*/_jsx(\"br\",{}),/*#__PURE__*/_jsxs(\"small\",{style:{opacity:.7},children:[\"Scanning for \",includeH3?\"H2 and H3\":\"H2\",\" elements...\"]})]})});}addPropertyControls(ArticleJumpLinks,{gap:{type:ControlType.Number,title:\"Gap\",defaultValue:0,min:0,max:50,step:1},includeH3:{type:ControlType.Boolean,title:\"Include H3 Headings\",defaultValue:true,enabledTitle:\"Include\",disabledTitle:\"H2 Only\"},showNumbers:{type:ControlType.Boolean,title:\"Show Numbers\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},// Number Typography Controls\nnumberFontFamily:{type:ControlType.String,title:\"Number Font Family\",defaultValue:\"JetBrains Mono, monospace\",placeholder:\"JetBrains Mono, monospace\",hidden:props=>!props.showNumbers},numberFontSize:{type:ControlType.Number,title:\"Number Font Size\",defaultValue:14,min:8,max:32,step:1,unit:\"px\",hidden:props=>!props.showNumbers},numberColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#666\",hidden:props=>!props.showNumbers},// Title Typography Controls\ntitleFontFamily:{type:ControlType.String,title:\"Title Font Family\",defaultValue:\"inherit\",placeholder:\"inherit\"},titleFontSize:{type:ControlType.Number,title:\"Title Font Size\",defaultValue:14,min:8,max:32,step:1,unit:\"px\"},titleLineHeight:{type:ControlType.Number,title:\"Title Line Height\",defaultValue:1.5,min:1,max:3,step:.1},titleColor:{type:ControlType.Color,title:\"Title Color\",defaultValue:\"#333\"},// Styling Controls\nborderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#e5e5e5\"},indentSubheadings:{type:ControlType.Boolean,title:\"Indent H3\",defaultValue:true,enabledTitle:\"Indent\",disabledTitle:\"No Indent\",hidden:props=>!props.includeH3},indentSize:{type:ControlType.Number,title:\"Indent Size\",defaultValue:20,min:0,max:60,step:4,unit:\"px\",hidden:props=>!props.indentSubheadings||!props.includeH3},// Active State Controls\nshowActiveIndicator:{type:ControlType.Boolean,title:\"Active Indicator\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},activeColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#0066FF\",hidden:props=>!props.showActiveIndicator}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ArticleJumpLinks\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ArticleJumpLinks.map"],"mappings":"6MAEA,SAAS,EAAS,CAAC,aAAW,QAAM,WAAS,QAAM,WAAS,mBAAiB,iBAAe,cAAY,kBAAgB,gBAAc,kBAAgB,aAAW,cAAY,cAAY,oBAAkB,aAAW,cAAY,uBAAqB,CAAC,IAAM,EAAY,GAAG,CAAC,EAAE,gBAAgB,CAAC,EA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