'use client' import type * as React from 'react' import { formatTextValue } from '@byline/core' import cx from 'clsx' import { extractHeadingText } from './utils.ts' import type { SerializedLexicalNode } from '../richtext-lexical/serialize/types.ts' type Heading = Extract export function HeadingWithAnchorSerializer({ node, }: { node: SerializedLexicalNode }): React.JSX.Element { const tag = node?.tag const text = extractHeadingText(node?.children) const headingId = formatTextValue(text) const Element = tag as Heading if (tag != null && (tag === 'h4' || tag === 'h5' || tag === 'h6')) { return ( {text} ) } else { return ( {text} ) } }