@conloca/mdx 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +31 -9
  2. package/dist/blocks.d.ts +37 -0
  3. package/dist/blocks.d.ts.map +1 -0
  4. package/dist/blocks.js +51 -0
  5. package/dist/code-block-frame.d.ts +41 -0
  6. package/dist/code-block-frame.d.ts.map +1 -0
  7. package/dist/code-block-frame.js +186 -0
  8. package/dist/editor-core.d.ts +58 -0
  9. package/dist/editor-core.d.ts.map +1 -0
  10. package/dist/editor-core.js +181 -0
  11. package/dist/hooks/useMDXEvaluation.d.ts +28 -0
  12. package/dist/hooks/useMDXEvaluation.d.ts.map +1 -0
  13. package/dist/hooks/useMDXEvaluation.js +117 -0
  14. package/dist/index.d.mts +104 -50
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.d.ts +8 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +4 -0
  19. package/dist/index.mjs +440 -369
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/markdown-options.d.ts +3 -0
  22. package/dist/markdown-options.d.ts.map +1 -0
  23. package/dist/markdown-options.js +19 -0
  24. package/dist/mdx/compile.d.ts +3 -0
  25. package/dist/mdx/compile.d.ts.map +1 -0
  26. package/dist/mdx/compile.js +27 -0
  27. package/dist/mdx/evaluate.d.ts +44 -0
  28. package/dist/mdx/evaluate.d.ts.map +1 -0
  29. package/dist/mdx/evaluate.js +57 -0
  30. package/dist/mdx-editor.d.ts +7 -0
  31. package/dist/mdx-editor.d.ts.map +1 -0
  32. package/dist/mdx-editor.js +7 -0
  33. package/dist/node.d.mts +46 -74
  34. package/dist/node.d.mts.map +1 -1
  35. package/dist/node.d.ts +17 -0
  36. package/dist/node.d.ts.map +1 -0
  37. package/dist/node.js +16 -0
  38. package/dist/node.mjs +35 -116
  39. package/dist/node.mjs.map +1 -1
  40. package/dist/style.css +88 -0
  41. package/dist/types.d.ts +16 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +1 -0
  44. package/package.json +54 -15
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["MDXEditorLib"],"sources":["../src/hooks/useMDXEvaluation.ts","../src/mdx-editor.tsx"],"sourcesContent":["import { evaluate } from '@mdx-js/mdx';\nimport type React from 'react';\nimport { useEffect, useState } from 'react';\nimport * as devRuntime from 'react/jsx-dev-runtime';\nimport * as runtime from 'react/jsx-runtime';\nimport remarkFrontmatter from 'remark-frontmatter';\nimport remarkGfm from 'remark-gfm';\nimport remarkMdxFrontmatter from 'remark-mdx-frontmatter';\n\n// Cache for compiled MDX components\nconst compiledCache = new Map<string, React.ComponentType>();\n\n/**\n * Standalone function that creates MDX evaluation options.\n * Checks for development mode only once at startup to avoid repeated\n * environment checks during runtime.\n *\n * @returns Configuration object for MDX evaluation with appropriate JSX runtime\n */\nfunction createMDXEvaluationOptions() {\n const isDevelopment = process.env.NODE_ENV === 'development';\n\n // Note: 'as any' is necessary due to @mdx-js/mdx type definitions not perfectly\n // matching the spread operator usage with JSX runtime objects\n return {\n ...(isDevelopment ? devRuntime : runtime),\n development: isDevelopment,\n remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkGfm],\n } as any;\n}\n\n// Call once at module load (startup)\nconst mdxEvaluationOptions = createMDXEvaluationOptions();\n\n/**\n * Simple hash function for generating cache keys from MDX content.\n * Uses string hashing to avoid collisions when cacheKey isn't provided.\n */\nfunction hashString(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash; // Convert to 32-bit integer\n }\n return hash.toString(36);\n}\n\ninterface UseMDXEvaluationOptions {\n mdxContent: string | null;\n cacheKey?: string;\n}\n\ninterface UseMDXEvaluationResult {\n Component: React.ComponentType | null;\n error: Error | null;\n isLoading: boolean;\n retry: () => void;\n}\n\n/**\n * Hook for evaluating MDX content into React components.\n *\n * Features:\n * - Evaluates MDX strings into renderable React components using @mdx-js/mdx\n * - Caches compiled components to avoid re-evaluation of unchanged content\n * - Handles both development (jsx-dev-runtime) and production (jsx-runtime) environments\n * - Provides retry mechanism to clear cache and re-evaluate failed compilations\n * - Returns loading and error states for UI feedback\n *\n * @param options - Configuration options\n * @param options.mdxContent - The MDX string to evaluate. If null, returns null component\n * @param options.cacheKey - Optional cache key. If not provided, uses first 100 chars of content\n *\n * @returns Object containing:\n * - Component: The compiled React component (null if not yet compiled or error occurred)\n * - error: Error object if evaluation failed (null otherwise)\n * - isLoading: Boolean indicating if evaluation is in progress\n * - retry: Function to clear cache and retry evaluation\n *\n * @example\n * ```tsx\n * const { Component, error, isLoading, retry } = useMDXEvaluation({\n * mdxContent: '# Hello\\n\\nThis is **MDX** content',\n * cacheKey: 'my-unique-key'\n * });\n *\n * if (isLoading) return <Spinner />;\n * if (error) return <Error message={error.message} onRetry={retry} />;\n * if (Component) return <Component />;\n * ```\n */\nexport function useMDXEvaluation({ mdxContent, cacheKey }: UseMDXEvaluationOptions): UseMDXEvaluationResult {\n const [Component, setComponent] = useState<React.ComponentType | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(!!mdxContent);\n const [retryCount, setRetryCount] = useState(0);\n\n // Retry function that clears cache and retries evaluation\n const retry = () => {\n if (mdxContent) {\n const key = cacheKey || `mdx-${hashString(mdxContent)}`;\n compiledCache.delete(key);\n }\n setRetryCount((prev) => prev + 1);\n };\n\n useEffect(() => {\n if (!mdxContent) {\n setComponent(null);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n // Check cache first - use hash of full content to prevent collisions\n const key = cacheKey || `mdx-${hashString(mdxContent)}`;\n const cached = compiledCache.get(key);\n if (cached) {\n setComponent(() => cached);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n // Evaluate MDX\n const evaluateMDX = async () => {\n try {\n setError(null);\n setIsLoading(true);\n\n // Evaluate MDX with proper JSX runtime\n const { default: MDXComponent } = await evaluate(mdxContent, mdxEvaluationOptions);\n\n // Cache the component\n compiledCache.set(key, MDXComponent);\n setComponent(() => MDXComponent);\n } catch (err) {\n const evaluationError = err instanceof Error ? err : new Error('MDX evaluation failed');\n setError(evaluationError);\n setComponent(null);\n } finally {\n setIsLoading(false);\n }\n };\n\n evaluateMDX();\n }, [mdxContent, cacheKey, retryCount]);\n\n return { Component, error, isLoading, retry };\n}\n","import {\n BlockTypeSelect,\n BoldItalicUnderlineToggles,\n CreateLink,\n codeBlockPlugin,\n codeMirrorPlugin,\n DiffSourceToggleWrapper,\n diffSourcePlugin,\n frontmatterPlugin,\n headingsPlugin,\n InsertCodeBlock,\n InsertImage,\n InsertTable,\n InsertThematicBreak,\n imagePlugin,\n jsxPlugin,\n ListsToggle,\n linkDialogPlugin,\n linkPlugin,\n listsPlugin,\n MDXEditor as MDXEditorLib,\n type MDXEditorMethods,\n markdownShortcutPlugin,\n quotePlugin,\n Separator,\n tablePlugin,\n thematicBreakPlugin,\n toolbarPlugin,\n UndoRedo,\n} from '@mdxeditor/editor';\nimport React, { useEffect, useState } from 'react';\nimport '@mdxeditor/editor/style.css';\n\n/**\n * Error Boundary for catching React errors in MDXEditor.\n * Prevents editor crashes from breaking the entire CMS.\n */\nclass MDXEditorErrorBoundary extends React.Component<\n { children: React.ReactNode },\n { hasError: boolean; error?: Error }\n> {\n constructor(props: { children: React.ReactNode }) {\n super(props);\n this.state = { hasError: false };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, error };\n }\n\n override componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\n console.error('[MDXEditor] Error boundary caught:', error, errorInfo);\n }\n\n override render() {\n if (this.state.hasError) {\n return (\n <div className=\"p-4 bg-red-50 border border-red-200 rounded text-red-600\">\n <p className=\"font-semibold mb-2\">MDXEditor Error</p>\n <p className=\"text-sm mb-2\">{this.state.error?.message || 'Unknown error occurred'}</p>\n <details className=\"text-xs\">\n <summary className=\"cursor-pointer font-medium\">Stack Trace</summary>\n <pre className=\"mt-2 p-2 bg-red-100 rounded overflow-auto whitespace-pre-wrap\">\n {this.state.error?.stack}\n </pre>\n </details>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n\nexport interface MDXEditorProps {\n value: string;\n onChange: (value: string) => void;\n onSave?: (value: string) => void;\n readOnly?: boolean;\n}\n\nexport const MDXEditor = React.forwardRef<MDXEditorMethods, MDXEditorProps>(\n ({ value, onChange, onSave, readOnly = false }, ref) => {\n // Handle keyboard shortcuts\n useEffect(() => {\n const handleKeyDown = (e: KeyboardEvent) => {\n // Save shortcut: Ctrl/Cmd+S\n if ((e.ctrlKey || e.metaKey) && e.key === 's') {\n e.preventDefault();\n if (onSave) {\n onSave(value);\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [value, onSave]);\n\n return (\n <MDXEditorLib\n ref={ref}\n markdown={value}\n onChange={onChange}\n readOnly={readOnly}\n contentEditableClassName=\"prose max-w-none\"\n plugins={[\n headingsPlugin(),\n listsPlugin(),\n quotePlugin(),\n linkPlugin(),\n linkDialogPlugin(),\n tablePlugin(),\n thematicBreakPlugin(),\n frontmatterPlugin(),\n codeBlockPlugin({ defaultCodeBlockLanguage: 'ts' }),\n codeMirrorPlugin({\n codeBlockLanguages: {\n text: 'Plain Text',\n js: 'JavaScript',\n jsx: 'JavaScript (React)',\n ts: 'TypeScript',\n tsx: 'TypeScript (React)',\n css: 'CSS',\n html: 'HTML',\n json: 'JSON',\n md: 'Markdown',\n mdx: 'MDX',\n bash: 'Bash',\n python: 'Python',\n },\n }),\n diffSourcePlugin({ viewMode: 'rich-text' }),\n markdownShortcutPlugin(),\n jsxPlugin(),\n imagePlugin(),\n toolbarPlugin({\n toolbarContents: () => (\n <DiffSourceToggleWrapper>\n <UndoRedo />\n <Separator />\n <BoldItalicUnderlineToggles />\n <Separator />\n <ListsToggle />\n <Separator />\n <BlockTypeSelect />\n <Separator />\n <CreateLink />\n <InsertImage />\n <InsertTable />\n <InsertThematicBreak />\n <Separator />\n <InsertCodeBlock />\n </DiffSourceToggleWrapper>\n ),\n }),\n ]}\n />\n );\n },\n);\n\nMDXEditor.displayName = 'MDXEditor';\n\n/**\n * DeferredMDXEditor - A wrapper component that defers MDXEditor initialization to avoid React 19 render-phase state updates\n *\n * ## Why This Wrapper Exists\n *\n * MDXEditor (v3.38.0) uses Lexical under the hood, which performs synchronous state updates during its initial render\n * when provided with markdown content. This violates React 19's stricter rules about state updates during render.\n *\n * ## The Specific React 19 Issue\n *\n * In React 19, the framework is more strict about preventing state updates during the render phase. When MDXEditor\n * initializes with the `markdown` prop, Lexical immediately:\n * 1. Parses the markdown content\n * 2. Converts it to Lexical's internal state representation\n * 3. Attempts to commit these changes via `$commitPendingUpdates`\n *\n * This happens synchronously during render, causing the error:\n * \"Can't perform a React state update on a component that hasn't mounted yet\"\n *\n * ## How This Wrapper Solves It\n *\n * By deferring the actual MDXEditor component render by 10ms using setTimeout, we ensure:\n * 1. React completes the current render cycle\n * 2. The component tree is fully mounted\n * 3. Only then does MDXEditor initialize with its content\n *\n * This prevents Lexical from trying to update state during the render phase.\n *\n * ## When This Issue Occurs\n *\n * This issue is particularly prevalent when:\n * - Using MDXEditor in a modal that mounts/unmounts frequently\n * - Dynamically loading content into the editor\n * - Using React 19 with its stricter concurrent rendering rules\n *\n * ## Technical Details\n *\n * The error stack trace shows the issue originates from:\n * - triggerListeners @ Lexical.dev.mjs:8156\n * - $commitPendingUpdates @ Lexical.dev.mjs:8116\n *\n * These Lexical internal methods are called during the initial render when markdown content is provided.\n *\n * ## Future Considerations\n *\n * This wrapper is a workaround for what should ideally be fixed in the MDXEditor/Lexical library itself.\n * The library should defer its own state initialization to a useEffect or similar to be React 19 compliant.\n *\n * Related issues:\n * - https://github.com/mdx-editor/editor/issues/494 (React 19 compatibility)\n * - Various modal-related issues (#584, #581, #758, #276)\n */\nconst DeferredMDXEditor: React.FC<MDXEditorProps> = ({ value, onChange, onSave, readOnly }) => {\n const editorRef = React.useRef<MDXEditorMethods>(null);\n const [isReady, setIsReady] = useState(false);\n\n useEffect(() => {\n // Use setTimeout to defer initialization to the next tick of the event loop\n // This ensures React has completed the current render cycle before MDXEditor initializes\n const timer = setTimeout(() => {\n setIsReady(true);\n }, 10); // 10ms is sufficient to defer to the next tick\n\n return () => clearTimeout(timer);\n }, []);\n\n if (!isReady) {\n return (\n <div className=\"flex items-center justify-center h-full text-gray-500\" data-testid=\"deferred-editor-loading\">\n Initializing editor...\n </div>\n );\n }\n\n return (\n <div data-testid=\"deferred-editor-ready\">\n <MDXEditor ref={editorRef} value={value} onChange={onChange} onSave={onSave} readOnly={readOnly} />\n </div>\n );\n};\n// Dialog/Modal components (simplified for now, can be replaced with proper UI library)\ninterface DialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n children: React.ReactNode;\n}\n\nconst Dialog: React.FC<DialogProps> = ({ open, onOpenChange, children }) => {\n if (!open) return null;\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n <div className=\"fixed inset-0 bg-black/50\" onClick={() => onOpenChange(false)} />\n <div className=\"relative z-50 bg-white rounded-lg shadow-lg max-w-[90vw] max-h-[90vh] overflow-hidden\">\n {children}\n </div>\n </div>\n );\n};\n\nconst DialogContent: React.FC<{ children: React.ReactNode; className?: string }> = ({ children, className = '' }) => {\n return <div className={`p-6 ${className}`}>{children}</div>;\n};\n\nconst DialogHeader: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n return <div className=\"mb-4\">{children}</div>;\n};\n\nconst DialogTitle: React.FC<{ children: React.ReactNode }> = ({ children }) => {\n return <h2 className=\"text-xl font-semibold\">{children}</h2>;\n};\n\nexport interface MDXEditorModalProps {\n isOpen: boolean;\n onClose: () => void;\n filePath?: string;\n initialContent: string;\n onSave: (content: string) => void | Promise<void>;\n headerExtra?: React.ReactNode;\n onBeforeClose?: () => boolean; // Return false to prevent closing\n}\n\nexport const MDXEditorModal: React.FC<MDXEditorModalProps> = ({\n isOpen,\n onClose,\n filePath,\n initialContent,\n onSave,\n headerExtra,\n onBeforeClose,\n}) => {\n const [content, setContent] = useState(initialContent);\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isSaving, setIsSaving] = useState(false);\n\n useEffect(() => {\n setContent(initialContent);\n }, [initialContent]);\n\n const handleClose = () => {\n // Check if parent wants to prevent closing\n if (onBeforeClose && !onBeforeClose()) {\n return;\n }\n onClose();\n };\n\n // Defer editor initialization to avoid render-phase state updates\n useEffect(() => {\n if (isOpen) {\n // Use a small delay to ensure we're out of the render phase\n const timer = setTimeout(() => {\n setIsEditorReady(true);\n }, 0);\n return () => clearTimeout(timer);\n }\n setIsEditorReady(false);\n return undefined;\n }, [isOpen]);\n\n const handleSave = async () => {\n setIsSaving(true);\n try {\n await onSave(content);\n // Only close if onSave completes without error\n handleClose();\n } catch (error) {\n // If onSave throws, don't close the modal\n console.error('Save failed:', error);\n } finally {\n setIsSaving(false);\n }\n };\n\n // Only render the editor when the modal is actually open\n if (!isOpen) {\n return null;\n }\n\n return (\n <Dialog open={isOpen} onOpenChange={handleClose}>\n <DialogContent className=\"w-[90vw] h-[90vh] flex flex-col\" data-testid=\"mdx-editor-modal\">\n <DialogHeader>\n <div className=\"flex items-center justify-between gap-4\">\n <DialogTitle>{filePath ? `Edit: ${filePath}` : 'New MDX File'}</DialogTitle>\n {headerExtra && <div className=\"flex items-center gap-2\">{headerExtra}</div>}\n <button onClick={handleClose} className=\"p-2 hover:bg-gray-100 rounded\" aria-label=\"Close\">\n ✕\n </button>\n </div>\n </DialogHeader>\n <div className=\"flex-1 overflow-hidden\">\n {isEditorReady ? (\n <MDXEditorErrorBoundary>\n {/* Using DeferredMDXEditor to avoid React 19 render-phase state update errors */}\n {/* See DeferredMDXEditor documentation for detailed explanation */}\n <DeferredMDXEditor value={content} onChange={setContent} onSave={handleSave} />\n </MDXEditorErrorBoundary>\n ) : (\n <div className=\"flex items-center justify-center h-full\">\n <div className=\"text-gray-500\" data-testid=\"modal-editor-loading\">\n Loading editor...\n </div>\n </div>\n )}\n </div>\n <div className=\"flex justify-end gap-2 mt-4\">\n <button\n onClick={handleClose}\n className=\"px-4 py-2 border border-gray-300 rounded hover:bg-gray-50\"\n disabled={isSaving}\n >\n Cancel\n </button>\n <button\n onClick={handleSave}\n className=\"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed\"\n disabled={isSaving}\n >\n {isSaving ? 'Saving...' : 'Save'}\n </button>\n </div>\n </DialogContent>\n </Dialog>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,gCAAgB,IAAI,KAAkC;;;;;;;;AAS5D,SAAS,6BAA6B;CACpC,MAAM,gBAAgB,QAAQ,IAAI,aAAa;AAI/C,QAAO;EACL,GAAI,gBAAgB,aAAa;EACjC,aAAa;EACb,eAAe;GAAC;GAAmB;GAAsB;GAAU;EACpE;;AAIH,MAAM,uBAAuB,4BAA4B;;;;;AAMzD,SAAS,WAAW,KAAqB;CACvC,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;EACnC,MAAM,OAAO,IAAI,WAAW,EAAE;AAC9B,UAAQ,QAAQ,KAAK,OAAO;AAC5B,SAAO,OAAO;;AAEhB,QAAO,KAAK,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+C1B,SAAgB,iBAAiB,EAAE,YAAY,YAA6D;CAC1G,MAAM,CAAC,WAAW,gBAAgB,SAAqC,KAAK;CAC5E,MAAM,CAAC,OAAO,YAAY,SAAuB,KAAK;CACtD,MAAM,CAAC,WAAW,gBAAgB,SAAS,CAAC,CAAC,WAAW;CACxD,MAAM,CAAC,YAAY,iBAAiB,SAAS,EAAE;CAG/C,MAAM,cAAc;AAClB,MAAI,YAAY;GACd,MAAM,MAAM,YAAY,OAAO,WAAW,WAAW;AACrD,iBAAc,OAAO,IAAI;;AAE3B,iBAAe,S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;AAIX,iBAAgB;AACd,MAAI,QAAQ;GAEV,MAAM,QAAQ,iBAAiB;AAC7B,qBAAiB,KAAK;MACrB,EAAE;AACL,gBAAa,aAAa,MAAM;;AAElC,mBAAiB,MAAM;IAEtB,CAAC,OAAO,CAAC;CAEZ,MAAM,aAAa,YAAY;AAC7B,cAAY,KAAK;AACjB,MAAI;AACF,SAAM,OAAO,QAAQ;AAErB,gBAAa;WACN,OAAO;AAEd,WAAQ,MAAM,gBAAgB,MAAM;YAC5B;AACR,eAAY,MAAM;;;AAKtB,KAAI,CAAC,OACH,QAAO;AAGT,QACE,oBAAC;EAAO,MAAM;EAAQ,cAAc;YAClC,qBAAC;GAAc,WAAU;GAAkC,eAAY;;IACrE,oBAAC,0BACC,qBAAC;KAAI,WAAU;;MACb,oBAAC,yBAAa,WAAW,SAAS,aAAa,iBAA6B;MAC3E,eAAe,oBAAC;OAAI,WAAU;iBAA2B;QAAkB;MAC5E,oBAAC;OAAO,SAAS;OAAa,WAAU;OAAgC,cAAW;iBAAQ;QAElF;;MACL,GACO;IACf,oBAAC;KAAI,WAAU;eACZ,gBACC,oBAAC,oCAGC,oBAAC;MAAkB,OAAO;MAAS,UAAU;MAAY,QAAQ;OAAc,GACxD,GAEzB,oBAAC;MAAI,WAAU;gBACb,oBAAC;OAAI,WAAU;OAAgB,eAAY;iBAAuB;QAE5D;OACF;MAEJ;IACN,qBAAC;KAAI,WAAU;gBACb,oBAAC;MACC,SAAS;MACT,WAAU;MACV,UAAU;gBACX;OAEQ,EACT,oBAAC;MACC,SAAS;MACT,WAAU;MACV,UAAU;gBAET,WAAW,cAAc;OACnB;MACL;;IACQ;GACT"}
1
+ {"version":3,"file":"index.mjs","names":["MDXEditorLib"],"sources":["../src/code-block-frame.tsx","../src/markdown-options.ts","../src/editor-core.tsx","../src/hooks/useMDXEvaluation.ts","../src/mdx-editor.tsx"],"sourcesContent":["import {\n Cell,\n type CodeBlockEditorDescriptor,\n type CodeBlockEditorProps,\n CodeMirrorEditor,\n useCellValue,\n useCodeBlockEditorContext,\n} from '@mdxeditor/editor';\nimport { Check, Copy } from 'lucide-react';\nimport { type ChangeEvent, createElement, type ReactElement, useCallback, useEffect, useMemo, useState } from 'react';\n\n/**\n * Frame chrome around the editor's fenced code blocks — header bar with\n * filename, language tag, and a copy button. The outer wrapper picks up\n * the host's code-block classes (published via `codeBlockWrapperInfo$`\n * by the host-wrapper plugin in cms-spa), so the host's actual code-\n * block CSS (Starlight's expressive-code, Tailwind's pre styling, etc.)\n * reaches the editor's frame through the cascade — no shipped mirror.\n *\n * Host-agnostic: no Shiki / Starlight / ExpressiveCode imports. Class\n * names are discovered at runtime from the host's live HTML.\n */\n\n/**\n * Realm-published cell carrying the host's code-block wrapper chain,\n * outermost first. For Starlight's expressive-code:\n *\n * [\n * { tagName: 'div', className: 'expressive-code' },\n * { tagName: 'figure', className: 'frame has-title not-content' },\n * ]\n *\n * The cms-spa `hostWrapperPlugin` writes to this whenever the fetched\n * wrapper info changes; the code-block frame reads from it to render\n * each chain link as a nested element with the host's expected tag\n * name. Same publish-pattern as the content-wrapper plugin in cms-spa.\n *\n * Null when the host has no code-block chrome (or the fetch is in\n * flight). The frame then falls back to its base `.conloca-code-block`\n * wrapper with no host inheritance — \"looks plain but not broken.\"\n */\nexport const codeBlockWrapperInfo$ = Cell<{ tagName: string; className: string }[] | null>(null);\n\nconst TITLE_META_RE = /\\btitle=(?:\"([^\"]*)\"|'([^']*)'|(\\S+))/;\n// First-line filename comment, the convention ExpressiveCode's frames\n// plugin recognizes when no explicit `title=` is set on the fence —\n// `// foo.ts`, `# foo.py`, `<!-- foo.html -->`, `/* foo.css */`,\n// `; foo.ini`, `-- foo.sql`. Requires a dot-extension so plain prose\n// comments don't get mistaken for filenames.\nconst FILENAME_COMMENT_RE = /^\\s*(?:\\/\\/|#|;|--|<!--|\\/\\*)\\s*([\\w.\\-/@]+\\.[\\w.-]+)\\s*(?:-->|\\*\\/)?\\s*$/;\n\ninterface MetaParts {\n /** The current title value (empty string when no title meta is set). */\n title: string;\n /** Everything else in the meta string, with the title slice removed. */\n rest: string;\n}\n\nfunction parseMeta(meta: string): MetaParts {\n const match = meta.match(TITLE_META_RE);\n if (!match) return { title: '', rest: meta.trim() };\n const value = match[1] ?? match[2] ?? match[3] ?? '';\n const rest = (meta.slice(0, match.index) + meta.slice(match.index! + match[0].length)).replace(/\\s+/g, ' ').trim();\n return { title: value, rest };\n}\n\n/** Reassemble a meta string with `title` set (or stripped when empty). */\nfunction buildMeta(title: string, rest: string): string {\n const trimmedTitle = title.trim();\n const titleFragment = trimmedTitle ? `title=\"${trimmedTitle.replace(/\"/g, '\\\\\"')}\"` : '';\n if (titleFragment && rest) return `${titleFragment} ${rest}`;\n return titleFragment || rest;\n}\n\n/**\n * Detect a leading filename comment, the convention EC's frames plugin\n * uses on the published page when no explicit `title=` is set. Returns\n * the filename when line 1 of the code is a single-line comment ending\n * in a dot-extension; empty string otherwise.\n *\n * Used to pre-fill the editor's filename input on legacy fences so\n * authors see the same value the reader sees in the rendered tab. Pure\n * read — the underlying code/comment is never touched.\n */\nfunction detectFilenameComment(code: string): string {\n const firstLine = code.split('\\n', 1)[0] ?? '';\n const match = firstLine.match(FILENAME_COMMENT_RE);\n return match ? (match[1] ?? '') : '';\n}\n\nfunction CopyButton({ code }: { code: string }) {\n const [copied, setCopied] = useState(false);\n const onClick = useCallback(() => {\n void navigator.clipboard.writeText(code).then(() => {\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n });\n }, [code]);\n return (\n <button\n type=\"button\"\n onClick={onClick}\n className=\"conloca-code-copy\"\n aria-label={copied ? 'Copied' : 'Copy code'}\n title={copied ? 'Copied' : 'Copy code'}\n >\n {copied ? <Check size={14} aria-hidden=\"true\" /> : <Copy size={14} aria-hidden=\"true\" />}\n </button>\n );\n}\n\n/**\n * Editable filename slot. Rewrites the code block's meta string via\n * `setMeta` from `useCodeBlockEditorContext` so authors can author the\n * frame title (`\\`\\`\\`ts title=\"src/foo.ts\"`) directly from the editor —\n * the meta string round-trips through MDXEditor's markdown serializer\n * and ExpressiveCode picks it up as the frame header on the published\n * page. Other meta fragments (ins/del/mark/wrap) are preserved.\n *\n * Legacy fences with a filename comment on line 1 (`// foo.ts`) — EC's\n * pre-meta convention for tab titles — are detected and pre-filled in\n * the input as a read-only display. Opening such a fence does NOT\n * mutate the source. Editing the field is an explicit author intent:\n * the new value is written as `title=` meta AND the original comment\n * line is stripped, so the editor's input becomes the single source of\n * truth without breaking the published render.\n */\nfunction FilenameInput({ meta, code }: { meta: string; code: string }) {\n const { setMeta, setCode } = useCodeBlockEditorContext();\n const parsed = useMemo(() => parseMeta(meta), [meta]);\n const detectedFromComment = useMemo(() => (parsed.title ? '' : detectFilenameComment(code)), [parsed.title, code]);\n const displayed = parsed.title || detectedFromComment;\n const [title, setTitle] = useState(displayed);\n const [interacted, setInteracted] = useState(false);\n\n // External updates (HMR, language change, sibling code edits) reset\n // the local view to the canonical value and clear the \"user edited\"\n // flag — so the next blur after an external update doesn't write\n // anything until the author actively types again.\n useEffect(() => {\n setTitle(displayed);\n setInteracted(false);\n }, [displayed]);\n\n const commit = useCallback(\n (next: string) => {\n if (!interacted) return;\n if (next === parsed.title) return;\n setMeta(buildMeta(next, parsed.rest));\n // If the pre-fill came from a leading filename comment and the\n // author has now committed an explicit title, strip the comment\n // so EC doesn't render the title twice (once as the tab, once as\n // a stray code comment) on the published page.\n if (detectedFromComment) {\n const lines = code.split('\\n');\n if (lines[0] && FILENAME_COMMENT_RE.test(lines[0])) {\n setCode(lines.slice(1).join('\\n').replace(/^\\n+/, ''));\n }\n }\n },\n [interacted, parsed.title, parsed.rest, detectedFromComment, code, setMeta, setCode],\n );\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n setInteracted(true);\n setTitle(e.target.value);\n };\n const onBlur = () => commit(title);\n\n return (\n <input\n type=\"text\"\n className=\"conloca-code-block__filename\"\n value={title}\n placeholder=\"filename\"\n spellCheck={false}\n onChange={onChange}\n onBlur={onBlur}\n aria-label=\"Code block filename\"\n />\n );\n}\n\nfunction ConlocaCodeBlockEditor(props: CodeBlockEditorProps) {\n // Materialise the host's discovered code-block chain as nested\n // elements. The INNERMOST link in the chain becomes the \"frame\"\n // element that directly holds the filename header, the code body,\n // and the copy slot — matching ExpressiveCode's authoring shape:\n //\n // <div class=\"expressive-code\"> ← outer link\n // <figure class=\"frame has-title …\"> ← inner link (frame)\n // <figcaption class=\"header\">\n // <span class=\"title\"><FilenameInput /></span>\n // </figcaption>\n // <pre><CodeMirror /></pre>\n // <div class=\"copy\"><CopyButton /></div>\n // </figure>\n // </div>\n //\n // Rendering with the host's expected tags (figure / figcaption / pre)\n // and nesting depth lets descendant CSS selectors land — both single-\n // class (`.frame { ... }`) and descendant (`.expressive-code .frame\n // .header > .title { ... }`) rules paint without us shipping a\n // parallel copy.\n //\n // When chain is null/empty (host has no code-block chrome, or the\n // wrapper fetch hasn't resolved yet) we fall back to a bare\n // `<div class=\"conloca-code-block\">` containing the same inner\n // shape — \"looks plain but not broken.\"\n const chain = useCellValue(codeBlockWrapperInfo$) ?? [];\n const frameLink = chain.length > 0 ? chain[chain.length - 1] : null;\n const outerLinks = frameLink ? chain.slice(0, -1) : [];\n\n const frameInner = (\n <>\n <figcaption className=\"conloca-code-block__header header\">\n <span className=\"title\">\n <FilenameInput meta={props.meta} code={props.code} />\n </span>\n </figcaption>\n <pre className=\"conloca-code-block__pre\">\n <CodeMirrorEditor {...props} />\n </pre>\n {/* `.copy` matches expressive-code's expected slot name so any\n `.frame .copy` styling from the host paints. We host only the\n copy button here — language selection lives in MDXEditor's\n own `_codeMirrorToolbar_*` (combobox), positioned via\n editor-styles.css so it doesn't overlap the code. */}\n <div className=\"conloca-code-block__copy copy\">\n <CopyButton code={props.code} />\n </div>\n </>\n );\n\n // The frame element carries `conloca-code-block` (our own targeting\n // hook) alongside the host's discovered classes. When the host has\n // no chain, we still wrap in a plain `<div>` so the inner shape is\n // consistent for our utility selectors.\n const frame = frameLink ? (\n createElement(frameLink.tagName, { className: `conloca-code-block ${frameLink.className}` }, frameInner)\n ) : (\n <div className=\"conloca-code-block\">{frameInner}</div>\n );\n\n // Wrap outer links from inside out. `reduceRight` so the first\n // chain link ends up as the outermost rendered element.\n return outerLinks.reduceRight<ReactElement>(\n (kids, link) => createElement(link.tagName, { className: link.className }, kids),\n frame,\n );\n}\n\n/**\n * Catch-all descriptor — `priority: 100`, `match: () => true` — registered\n * via `codeBlockPlugin({ codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor] })`.\n * Wraps the upstream `CodeMirrorEditor` with the host-themed frame.\n */\nexport const conlocaCodeBlockDescriptor: CodeBlockEditorDescriptor = {\n priority: 100,\n match: () => true,\n Editor: ConlocaCodeBlockEditor,\n};\n","import type { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';\n\n// MDXEditor rebuilds the markdown body from its Lexical AST on every change\n// via `mdast-util-to-markdown`. Without explicit options, the library defaults\n// flip canonical project style: thematic breaks render as `***` instead of\n// `---`, bullets pick `*` over `-`, and emphasis ambiguity inside GFM table\n// cells inserts backslash escapes on every save. Pinning these to match the\n// committed fixtures keeps no-op round-trips diff-clean.\n//\n// Exported as a plain TS module (no React deps) so it can be exercised\n// directly from tests against `mdast-util-to-markdown` without mounting the\n// editor.\nexport const TO_MARKDOWN_OPTIONS: ToMarkdownOptions = {\n bullet: '-',\n rule: '-',\n emphasis: '_',\n strong: '*',\n fence: '`',\n listItemIndent: 'one',\n tightDefinitions: true,\n};\n","import {\n BlockTypeSelect,\n BoldItalicUnderlineToggles,\n ButtonWithTooltip,\n ChangeCodeMirrorLanguage,\n ConditionalContents,\n CreateLink,\n codeBlockPlugin,\n codeMirrorPlugin,\n DiffSourceToggleWrapper,\n diffSourcePlugin,\n GenericJsxEditor,\n HighlightToggle,\n headingsPlugin,\n InsertCodeBlock,\n InsertImage,\n InsertTable,\n InsertThematicBreak,\n imagePlugin,\n type JsxComponentDescriptor,\n jsxPlugin,\n ListsToggle,\n linkDialogPlugin,\n linkPlugin,\n listsPlugin,\n MDXEditor as MDXEditorLib,\n type MDXEditorMethods,\n markdownShortcutPlugin,\n quotePlugin,\n type RealmPlugin,\n Separator,\n StrikeThroughSupSubToggles,\n tablePlugin,\n thematicBreakPlugin,\n toolbarPlugin,\n UndoRedo,\n} from '@mdxeditor/editor';\nimport { Maximize2, Minimize2 } from 'lucide-react';\nimport React, { useCallback, useEffect, useSyncExternalStore } from 'react';\nimport '@mdxeditor/editor/style.css';\nimport './editor-styles.css';\nimport { conlocaCodeBlockDescriptor } from './code-block-frame';\nimport { TO_MARKDOWN_OPTIONS } from './markdown-options';\n\nconst FOCUS_MODE_STORAGE_KEY = 'conloca.mdxeditor.focusMode';\nconst FOCUS_MODE_BODY_CLASS = 'mdxeditor-focus-mode';\n\n/**\n * Toggle focus-mode by writing the class on `document.body`. Direct DOM\n * mutation (vs. piping a boolean through React state into the editor's\n * `className` prop) avoids re-rendering Lexical on every toggle — the\n * editor's prop is the only entry point and changing it forces a parse\n * round-trip. Persisted in localStorage so the preference survives reloads.\n */\nfunction readFocusMode(): boolean {\n if (typeof document === 'undefined') return false;\n return document.body.classList.contains(FOCUS_MODE_BODY_CLASS);\n}\n\nfunction subscribeFocusMode(callback: () => void): () => void {\n if (typeof window === 'undefined') return () => {};\n const handler = () => callback();\n window.addEventListener('conloca:focusModeChange', handler);\n return () => window.removeEventListener('conloca:focusModeChange', handler);\n}\n\nfunction setFocusMode(next: boolean): void {\n if (typeof document === 'undefined') return;\n document.body.classList.toggle(FOCUS_MODE_BODY_CLASS, next);\n try {\n if (next) {\n window.localStorage.setItem(FOCUS_MODE_STORAGE_KEY, '1');\n } else {\n window.localStorage.removeItem(FOCUS_MODE_STORAGE_KEY);\n }\n } catch {\n // localStorage may be unavailable (private mode, SSR) — ignore.\n }\n window.dispatchEvent(new Event('conloca:focusModeChange'));\n}\n\nfunction FocusModeToggle() {\n const focusMode = useSyncExternalStore(subscribeFocusMode, readFocusMode, () => false);\n const onClick = useCallback(() => setFocusMode(!focusMode), [focusMode]);\n const Icon = focusMode ? Minimize2 : Maximize2;\n return (\n <ButtonWithTooltip\n title={focusMode ? 'Exit focus mode (wider column)' : 'Enter focus mode (narrow column)'}\n onClick={onClick}\n >\n <Icon size={16} aria-hidden />\n </ButtonWithTooltip>\n );\n}\n\nexport interface BaseMDXEditorProps {\n value: string;\n /**\n * Called whenever the editor content changes. The second argument is `true`\n * the first time the library normalizes the parsed markdown back to its\n * canonical form (bullet style, trailing newline, etc.) — consumers tracking\n * dirty state should treat that call as a re-baseline rather than a user\n * edit, otherwise the editor looks dirty the moment the page loads.\n */\n onChange: (value: string, initialMarkdownNormalize?: boolean) => void;\n onSave?: (value: string) => void;\n readOnly?: boolean;\n imageDialog?: React.FC | null;\n disableImageSettingsButton?: boolean;\n onImageShortcut?: () => void;\n imageButtonRef?: React.Ref<HTMLButtonElement>;\n /**\n * Upload handler for images pasted or dropped directly into the editor. When\n * provided, the underlying imagePlugin will route those events through this\n * function and insert the returned URL as the image src. Independent of the\n * library/picker `imageDialog` flow — both can be active simultaneously.\n */\n imageUploadHandler?: (file: File) => Promise<string>;\n jsxComponentDescriptors?: JsxComponentDescriptor[];\n /**\n * Additional @mdxeditor/editor RealmPlugins appended to the built-in\n * plugin list. Used by the SPA shell to register the MDX components\n * registry-driven slash menu without coupling @conloca/mdx to\n * @conloca/cms-spa.\n */\n extraPlugins?: RealmPlugin[];\n /**\n * Extra toolbar buttons inserted between `<InsertAdmonition />` and the\n * separator preceding focus mode. Pass `null` (default) to keep the\n * stock toolbar.\n */\n extraToolbarItems?: React.ReactNode;\n /**\n * Class applied to the MDXEditor root element (library forwards it to the\n * toolbar and portaled popups too). Pass `\"dark-theme\"` to activate the\n * library's built-in Radix dark palette.\n * See https://mdxeditor.dev/editor/docs/theming\n */\n className?: string;\n /** Placeholder shown when the editor is empty. Forwarded to MDXEditorLib. */\n placeholder?: React.ReactNode;\n /** Auto-focus the editor on mount. Forwarded to MDXEditorLib. */\n autoFocus?: boolean | { defaultSelection?: 'rootStart' | 'rootEnd'; preventScroll?: boolean };\n}\n\n// The empty-string entry is the documented escape hatch for code blocks\n// authored without a language hint. Without it, fences like ```\\nfoo\\n``` (which\n// the parser tags as language `null` / meta `'N/A'`) trip a hard error in\n// older versions and emit a noisy warning even on v3.55+. See mdx-editor/editor\n// issues #370, #423, #463, #885, #886, #901.\nconst codeBlockLanguages: Record<string, string> = {\n '': 'Plain text',\n text: 'Plain Text',\n js: 'JavaScript',\n jsx: 'JavaScript (React)',\n ts: 'TypeScript',\n tsx: 'TypeScript (React)',\n css: 'CSS',\n html: 'HTML',\n json: 'JSON',\n md: 'Markdown',\n mdx: 'MDX',\n bash: 'Bash',\n python: 'Python',\n};\n\n/**\n * Wildcard fallback so any unknown JSX tag round-trips through GenericJsxEditor\n * instead of crashing the importer with \"Parsing of the following markdown\n * structure failed\". Two entries because the upstream visitor dispatches by\n * `kind` (block vs inline JSX) — without the inline one, an inline `<Badge>`\n * mid-paragraph would be matched by the flow wildcard and lifted out of its\n * paragraph in Lexical. Consumers passing typed descriptors win via the\n * exact-name match in the visitor; the wildcard only handles the leftovers.\n */\nconst wildcardJsxDescriptors: JsxComponentDescriptor[] = [\n { name: '*', kind: 'flow', props: [], hasChildren: true, Editor: GenericJsxEditor },\n { name: '*', kind: 'text', props: [], hasChildren: true, Editor: GenericJsxEditor },\n];\n\nfunction renderInsertImageButton(imageButtonRef?: React.Ref<HTMLButtonElement>) {\n if (!imageButtonRef) {\n return <InsertImage />;\n }\n\n return React.createElement(InsertImage as unknown as React.FC<{ ref: React.Ref<HTMLButtonElement> }>, {\n ref: imageButtonRef,\n });\n}\n\n/**\n * Restore the persisted focus-mode preference on first import. Runs once at\n * module load so the class is in place before any editor mounts — avoids a\n * flash of wide column when the user previously selected focus mode.\n */\nif (typeof window !== 'undefined') {\n try {\n if (window.localStorage.getItem(FOCUS_MODE_STORAGE_KEY) === '1') {\n document.body.classList.add(FOCUS_MODE_BODY_CLASS);\n }\n } catch {\n // ignore\n }\n}\n\nexport const BaseMDXEditor = React.forwardRef<MDXEditorMethods, BaseMDXEditorProps>(\n (\n {\n value,\n onChange,\n onSave,\n readOnly = false,\n imageDialog,\n disableImageSettingsButton = false,\n onImageShortcut,\n imageButtonRef,\n imageUploadHandler,\n jsxComponentDescriptors,\n extraPlugins,\n extraToolbarItems,\n className,\n placeholder,\n autoFocus,\n },\n ref,\n ) => {\n useEffect(() => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if ((event.ctrlKey || event.metaKey) && event.key === 's') {\n event.preventDefault();\n onSave?.(value);\n }\n\n if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key.toLowerCase() === 'i') {\n if (!onImageShortcut) {\n return;\n }\n\n event.preventDefault();\n onImageShortcut();\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n return () => document.removeEventListener('keydown', handleKeyDown);\n }, [onImageShortcut, onSave, value]);\n\n return (\n <MDXEditorLib\n ref={ref}\n markdown={value}\n toMarkdownOptions={TO_MARKDOWN_OPTIONS}\n onChange={onChange}\n onError={({ error, source }) => {\n // Library invokes this synchronously inside a gurx signal, so don't\n // setState here — that triggers a render-phase warning (#872).\n // Logging only is enough; the React error boundary still catches\n // anything that escapes from rendering.\n console.error('[MDXEditor] parse error:', error, '\\nsource:', source);\n }}\n readOnly={readOnly}\n className={className}\n placeholder={placeholder}\n autoFocus={autoFocus}\n contentEditableClassName=\"conloca-prose conloca-prose--editor\"\n plugins={[\n headingsPlugin(),\n listsPlugin(),\n quotePlugin(),\n linkPlugin(),\n linkDialogPlugin(),\n tablePlugin(),\n thematicBreakPlugin(),\n // frontmatterPlugin intentionally omitted: metadata (title,\n // description, id, created, modified) is server-owned and stripped\n // from `content.mdx` on load. Re-introducing the plugin would let\n // the editor round-trip a YAML block as body text, corrupting the\n // file when content is inserted above it.\n codeBlockPlugin({\n defaultCodeBlockLanguage: 'ts',\n codeBlockEditorDescriptors: [conlocaCodeBlockDescriptor],\n }),\n codeMirrorPlugin({ codeBlockLanguages }),\n diffSourcePlugin({ viewMode: 'rich-text' }),\n markdownShortcutPlugin(),\n jsxPlugin({\n jsxComponentDescriptors: [...(jsxComponentDescriptors ?? []), ...wildcardJsxDescriptors],\n }),\n imagePlugin({\n ...(imageDialog ? { ImageDialog: imageDialog, disableImageSettingsButton } : {}),\n ...(imageUploadHandler ? { imageUploadHandler } : {}),\n }),\n ...(extraPlugins ?? []),\n toolbarPlugin({\n // flex-wrap so the toolbar reflows on narrow viewports instead of\n // overflowing horizontally — workaround documented in\n // mdx-editor/editor#908.\n toolbarClassName: 'mdxeditor-toolbar-wrap',\n toolbarContents: () => (\n <DiffSourceToggleWrapper>\n <ConditionalContents\n options={[\n {\n // When the user clicks into a code block, swap most of\n // the rich-text toolbar for the language picker — those\n // controls are no-ops inside CodeMirror anyway.\n when: (editor) => editor?.editorType === 'codeblock',\n contents: () => <ChangeCodeMirrorLanguage />,\n },\n {\n fallback: () => (\n <>\n <UndoRedo />\n <Separator />\n <BoldItalicUnderlineToggles />\n <StrikeThroughSupSubToggles />\n <HighlightToggle />\n <Separator />\n <ListsToggle />\n <Separator />\n <BlockTypeSelect />\n <Separator />\n <CreateLink />\n {renderInsertImageButton(imageButtonRef)}\n <InsertTable />\n <InsertThematicBreak />\n <Separator />\n <InsertCodeBlock />\n {extraToolbarItems}\n <Separator />\n <FocusModeToggle />\n </>\n ),\n },\n ]}\n />\n </DiffSourceToggleWrapper>\n ),\n }),\n ]}\n />\n );\n },\n);\n\nBaseMDXEditor.displayName = 'BaseMDXEditor';\n","import type React from 'react';\nimport { useEffect, useState } from 'react';\nimport * as devRuntime from 'react/jsx-dev-runtime';\nimport * as runtime from 'react/jsx-runtime';\n\n// Cache for compiled MDX components\nconst compiledCache = new Map<string, React.ComponentType>();\n\n/**\n * Execute pre-compiled MDX code (compiled with outputFormat: 'function-body').\n * This is the same as @mdx-js/mdx's run() — inlined here to avoid importing\n * the full @mdx-js/mdx package (which pulls acorn + remark + unified into the browser).\n *\n * Note: Uses AsyncFunction constructor which requires CSP `unsafe-eval`.\n * This is acceptable since the CMS admin UI runs in a trusted environment.\n */\nconst AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;\nasync function runMDX(code: string, options: Record<string, unknown>): Promise<{ default: React.ComponentType }> {\n return new AsyncFunction(String(code))(options);\n}\n\n/**\n * Create the JSX runtime options for runMDX().\n * Checked once at module load to avoid repeated environment checks.\n */\nfunction createRunOptions() {\n const isDevelopment = process.env.NODE_ENV === 'development';\n return isDevelopment ? { ...devRuntime, development: true } : { ...runtime };\n}\n\nconst runOptions = createRunOptions();\n\n/**\n * Simple hash function for generating cache keys from MDX content.\n */\nfunction hashString(str: string): string {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash = hash & hash;\n }\n return hash.toString(36);\n}\n\nexport interface UseMDXEvaluationOptions {\n compiledCode: string | null;\n cacheKey?: string;\n}\n\nexport interface UseMDXEvaluationResult {\n Component: React.ComponentType | null;\n error: Error | null;\n isLoading: boolean;\n retry: () => void;\n}\n\n/**\n * Hook for evaluating pre-compiled MDX code into React components.\n *\n * Uses the browser-side half of a server-compile + browser-run pattern:\n * 1. The server compiles MDX → JavaScript function body\n * 2. The browser executes the pre-compiled code with run() (zero compiler dependencies)\n *\n * This keeps the full MDX compilation pipeline on the server and only ships\n * a tiny runtime helper to the browser.\n *\n * @param options.compiledCode - The pre-compiled MDX function body. If null, returns null component\n * @param options.cacheKey - Optional cache key. If not provided, uses hash of code\n *\n * @returns Object containing Component, error, isLoading, retry\n */\nexport function useMDXEvaluation({ compiledCode, cacheKey }: UseMDXEvaluationOptions): UseMDXEvaluationResult {\n const [Component, setComponent] = useState<React.ComponentType | null>(null);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(() => {\n if (!compiledCode) return false;\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n return !compiledCache.has(key);\n });\n const [retryCount, setRetryCount] = useState(0);\n\n const retry = () => {\n if (compiledCode) {\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n compiledCache.delete(key);\n }\n setRetryCount((prev) => prev + 1);\n };\n\n useEffect(() => {\n void retryCount;\n\n if (!compiledCode) {\n setComponent(null);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n const key = cacheKey || `mdx-${hashString(compiledCode)}`;\n const cached = compiledCache.get(key);\n if (cached) {\n setComponent(() => cached);\n setError(null);\n setIsLoading(false);\n return;\n }\n\n let cancelled = false;\n\n const compileAndRun = async () => {\n try {\n setError(null);\n setIsLoading(true);\n\n const { default: MDXComponent } = await runMDX(compiledCode, runOptions);\n\n if (cancelled) return;\n\n compiledCache.set(key, MDXComponent);\n setComponent(() => MDXComponent);\n } catch (err) {\n if (cancelled) return;\n const evaluationError = err instanceof Error ? err : new Error('MDX evaluation failed');\n setError(evaluationError);\n setComponent(null);\n } finally {\n if (!cancelled) {\n setIsLoading(false);\n }\n }\n };\n\n compileAndRun();\n\n return () => {\n cancelled = true;\n };\n }, [compiledCode, cacheKey, retryCount]);\n\n return { Component, error, isLoading, retry };\n}\n","import type { MDXEditorMethods } from '@mdxeditor/editor';\nimport React from 'react';\nimport { BaseMDXEditor, type BaseMDXEditorProps } from './editor-core.js';\n\nexport interface MDXEditorProps\n extends Omit<\n BaseMDXEditorProps,\n 'disableImageSettingsButton' | 'imageButtonRef' | 'imageDialog' | 'onImageShortcut'\n > {}\n\nexport const MDXEditor = React.forwardRef<MDXEditorMethods, MDXEditorProps>((props, ref) => {\n return <BaseMDXEditor ref={ref} {...props} />;\n});\n\nMDXEditor.displayName = 'MDXEditor';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAa,wBAAwB,KAAsD,IAAI;AAE/F,MAAM,gBAAgB;AAMtB,MAAM,sBAAsB;AAS5B,SAAS,UAAU,MAAyB;CAC1C,MAAM,QAAQ,KAAK,MAAM,aAAa;CACtC,IAAI,CAAC,O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M,uBAAuB;IACtF,SAAS,eAAe;IACxB,aAAa,IAAI;GACnB,UAAU;IACR,IAAI,CAAC,WACH,aAAa,KAAK;GAEtB;EACF;EAEA,cAAc;EAEd,aAAa;GACX,YAAY;EACd;CACF,GAAG;EAAC;EAAc;EAAU;CAAU,CAAC;CAEvC,OAAO;EAAE;EAAW;EAAO;EAAW;CAAM;AAC9C;;;ACpIA,MAAa,YAAY,MAAM,YAA8C,OAAO,QAAQ;CAC1F,OAAO,oBAAC,eAAD;EAAoB;EAAK,GAAI;CAAQ,CAAA;AAC9C,CAAC;AAED,UAAU,cAAc"}
@@ -0,0 +1,3 @@
1
+ import type { Options as ToMarkdownOptions } from 'mdast-util-to-markdown';
2
+ export declare const TO_MARKDOWN_OPTIONS: ToMarkdownOptions;
3
+ //# sourceMappingURL=markdown-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-options.d.ts","sourceRoot":"","sources":["../src/markdown-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAY3E,eAAO,MAAM,mBAAmB,EAAE,iBAQjC,CAAC"}
@@ -0,0 +1,19 @@
1
+ // MDXEditor rebuilds the markdown body from its Lexical AST on every change
2
+ // via `mdast-util-to-markdown`. Without explicit options, the library defaults
3
+ // flip canonical project style: thematic breaks render as `***` instead of
4
+ // `---`, bullets pick `*` over `-`, and emphasis ambiguity inside GFM table
5
+ // cells inserts backslash escapes on every save. Pinning these to match the
6
+ // committed fixtures keeps no-op round-trips diff-clean.
7
+ //
8
+ // Exported as a plain TS module (no React deps) so it can be exercised
9
+ // directly from tests against `mdast-util-to-markdown` without mounting the
10
+ // editor.
11
+ export const TO_MARKDOWN_OPTIONS = {
12
+ bullet: '-',
13
+ rule: '-',
14
+ emphasis: '_',
15
+ strong: '*',
16
+ fence: '`',
17
+ listItemIndent: 'one',
18
+ tightDefinitions: true,
19
+ };
@@ -0,0 +1,3 @@
1
+ import type { MDXCompileResult } from '../types.js';
2
+ export declare function compileMDX(content: string): Promise<MDXCompileResult>;
3
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/mdx/compile.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuB3E"}
@@ -0,0 +1,27 @@
1
+ import { compile as mdxCompile } from '@mdx-js/mdx';
2
+ import matter from 'gray-matter';
3
+ import remarkFrontmatter from 'remark-frontmatter';
4
+ import remarkGfm from 'remark-gfm';
5
+ import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
6
+ export async function compileMDX(content) {
7
+ try {
8
+ const { data: metadata } = matter(content, {});
9
+ const compiled = await mdxCompile(content, {
10
+ outputFormat: 'function-body',
11
+ development: process.env.NODE_ENV === 'development',
12
+ remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkGfm],
13
+ });
14
+ return {
15
+ code: String(compiled.value),
16
+ metadata: metadata,
17
+ };
18
+ }
19
+ catch (error) {
20
+ if (error instanceof Error) {
21
+ const enhancedError = new Error(`MDX compilation failed: ${error.message}`);
22
+ enhancedError.stack = error.stack;
23
+ throw enhancedError;
24
+ }
25
+ throw error;
26
+ }
27
+ }
@@ -0,0 +1,44 @@
1
+ import type { ComponentType } from 'react';
2
+ /**
3
+ * Evaluate MDX content string to a React component.
4
+ *
5
+ * This is a framework-agnostic utility for converting MDX strings into
6
+ * executable React components. Works in any Node.js environment (Astro,
7
+ * Next.js, Remix, etc.) at build time or server-side.
8
+ *
9
+ * **When to use:**
10
+ * - Building static sites with MDX content
11
+ * - Server-side rendering MDX as React components
12
+ * - Need React components (not HTML strings)
13
+ *
14
+ * @param mdxContent - The MDX string to evaluate
15
+ * @param options - Optional configuration
16
+ * @param options.development - Whether to use development mode (default: false)
17
+ * @returns Object containing Component (or null) and optional error
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import { evaluateMDXToComponent } from '@conloca/mdx/node';
22
+ *
23
+ * const { Component, error } = await evaluateMDXToComponent('# Hello\n\nThis is **MDX**');
24
+ * if (error) {
25
+ * console.error('Failed to evaluate:', error);
26
+ * } else if (Component) {
27
+ * // Render <Component /> in your React app
28
+ * }
29
+ * ```
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // In Astro pages
34
+ * const { Component } = await evaluateMDXToComponent(mdxContent);
35
+ * // Then render in JSX: <Component />
36
+ * ```
37
+ */
38
+ export declare function evaluateMDXToComponent(mdxContent: string, options?: {
39
+ development?: boolean;
40
+ }): Promise<{
41
+ Component: ComponentType | null;
42
+ error?: Error;
43
+ }>;
44
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/mdx/evaluate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAClC,OAAO,CAAC;IAAE,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,CAe7D"}
@@ -0,0 +1,57 @@
1
+ import { evaluate } from '@mdx-js/mdx';
2
+ import * as runtime from 'react/jsx-runtime';
3
+ import remarkFrontmatter from 'remark-frontmatter';
4
+ import remarkGfm from 'remark-gfm';
5
+ import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
6
+ /**
7
+ * Evaluate MDX content string to a React component.
8
+ *
9
+ * This is a framework-agnostic utility for converting MDX strings into
10
+ * executable React components. Works in any Node.js environment (Astro,
11
+ * Next.js, Remix, etc.) at build time or server-side.
12
+ *
13
+ * **When to use:**
14
+ * - Building static sites with MDX content
15
+ * - Server-side rendering MDX as React components
16
+ * - Need React components (not HTML strings)
17
+ *
18
+ * @param mdxContent - The MDX string to evaluate
19
+ * @param options - Optional configuration
20
+ * @param options.development - Whether to use development mode (default: false)
21
+ * @returns Object containing Component (or null) and optional error
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { evaluateMDXToComponent } from '@conloca/mdx/node';
26
+ *
27
+ * const { Component, error } = await evaluateMDXToComponent('# Hello\n\nThis is **MDX**');
28
+ * if (error) {
29
+ * console.error('Failed to evaluate:', error);
30
+ * } else if (Component) {
31
+ * // Render <Component /> in your React app
32
+ * }
33
+ * ```
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * // In Astro pages
38
+ * const { Component } = await evaluateMDXToComponent(mdxContent);
39
+ * // Then render in JSX: <Component />
40
+ * ```
41
+ */
42
+ export async function evaluateMDXToComponent(mdxContent, options) {
43
+ try {
44
+ const { default: MDXComponent } = await evaluate(mdxContent, {
45
+ ...runtime,
46
+ remarkPlugins: [remarkFrontmatter, remarkMdxFrontmatter, remarkGfm],
47
+ development: options?.development ?? false,
48
+ });
49
+ return { Component: MDXComponent };
50
+ }
51
+ catch (error) {
52
+ return {
53
+ Component: null,
54
+ error: error instanceof Error ? error : new Error('MDX evaluation failed'),
55
+ };
56
+ }
57
+ }
@@ -0,0 +1,7 @@
1
+ import type { MDXEditorMethods } from '@mdxeditor/editor';
2
+ import React from 'react';
3
+ import { type BaseMDXEditorProps } from './editor-core.js';
4
+ export interface MDXEditorProps extends Omit<BaseMDXEditorProps, 'disableImageSettingsButton' | 'imageButtonRef' | 'imageDialog' | 'onImageShortcut'> {
5
+ }
6
+ export declare const MDXEditor: React.ForwardRefExoticComponent<MDXEditorProps & React.RefAttributes<MDXEditorMethods>>;
7
+ //# sourceMappingURL=mdx-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mdx-editor.d.ts","sourceRoot":"","sources":["../src/mdx-editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,WAAW,cACf,SAAQ,IAAI,CACV,kBAAkB,EAClB,4BAA4B,GAAG,gBAAgB,GAAG,aAAa,GAAG,iBAAiB,CACpF;CAAG;AAEN,eAAO,MAAM,SAAS,yFAEpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { BaseMDXEditor } from './editor-core.js';
4
+ export const MDXEditor = React.forwardRef((props, ref) => {
5
+ return _jsx(BaseMDXEditor, { ref: ref, ...props });
6
+ });
7
+ MDXEditor.displayName = 'MDXEditor';
package/dist/node.d.mts CHANGED
@@ -1,86 +1,58 @@
1
1
  import { ComponentType } from "react";
2
- import { ContentAPI } from "@conloca/content-api";
3
-
4
- //#region src/blocks.d.ts
5
- /**
6
- * Evaluate all MDX blocks from Content API into React components.
7
- *
8
- * High-level helper function for Astro pages that handles:
9
- * - Fetching all blocks from Content API
10
- * - Evaluating MDX content to React components
11
- * - Error handling with fallback error components
12
- * - Empty content handling with fallback components
13
- *
14
- * Returns data in the format expected by `createPageRendererWithBlocks`.
15
- *
16
- * @param api - ContentAPI instance
17
- * @param locale - Locale code to fetch (e.g., 'en', 'es')
18
- * @returns Array of blocks with evaluated React components
19
- *
20
- * @example
21
- * ```astro
22
- * ---
23
- * import { createPageRendererWithBlocks } from '@conloca/astro-cms/components';
24
- * import { createContentAPI } from '@conloca/content-api/node';
25
- * import config from '../puck.config';
26
- *
27
- * const api = await createContentAPI({ contentRoot: './content' });
28
- * const mdxComponents = await evaluateMDXBlocks(api, 'en');
29
- * const PageRenderer = createPageRendererWithBlocks(config, puckData, mdxComponents);
30
- * ---
31
- * <PageRenderer />
32
- * ```
33
- */
34
- declare function evaluateMDXBlocks(api: ContentAPI, locale: string): Promise<Array<{
2
+ import { MDXCompileResponse as MDXCompileResult } from "@conloca/content-api";
3
+ //#region src/types.d.ts
4
+ interface EvaluatedMDXBlock {
5
+ ok: true;
35
6
  id: string;
36
7
  title: string;
37
8
  Component: ComponentType;
38
- }>>;
39
- //#endregion
40
- //#region src/types.d.ts
41
- /**
42
- * MDX compilation types
43
- */
44
- interface MDXCompileResult {
45
- code: string;
46
- metadata: Record<string, any>;
47
9
  }
48
- interface MDXCompiler {
49
- compile: (content: string) => Promise<MDXCompileResult>;
50
- compileFile: (filePath: string) => Promise<MDXCompileResult>;
10
+ interface FailedMDXBlockEvaluation {
11
+ ok: false;
12
+ id: string;
13
+ title: string;
14
+ error: Error;
51
15
  }
16
+ type MDXBlockEvaluationResult = EvaluatedMDXBlock | FailedMDXBlockEvaluation;
52
17
  //#endregion
53
- //#region src/mdx/compile.d.ts
54
- /**
55
- * Compile MDX content to executable JavaScript
56
- *
57
- * We use BOTH gray-matter and remark-frontmatter plugins:
58
- * 1. gray-matter extracts frontmatter data for returning as separate metadata
59
- * 2. remark-frontmatter + remark-mdx-frontmatter allow using frontmatter values as {variables} in MDX
60
- *
61
- * This dual approach gives us:
62
- * - Separate metadata object for the API response
63
- * - Ability to use frontmatter variables like {title} directly in MDX content
64
- *
65
- * @param content - MDX content string (may include frontmatter)
66
- * @param components - Component scope to inject
67
- * @returns Compiled code and extracted metadata
68
- */
69
- declare function compileMDX(content: string, components: Record<string, any>): Promise<MDXCompileResult>;
70
- /**
71
- * Create an MDX compiler with a fixed component scope
72
- *
73
- * @param componentScope - Components available to all MDX files
74
- * @returns Compiler instance
75
- */
76
- declare function createMDXCompiler(componentScope: Record<string, any>): MDXCompiler;
18
+ //#region src/blocks.d.ts
19
+ interface BlockLocaleSummary {
20
+ meta?: {
21
+ title?: string;
22
+ };
23
+ name?: string;
24
+ }
25
+ interface BlockManifest {
26
+ id: string;
27
+ locales: Record<string, BlockLocaleSummary | undefined>;
28
+ }
29
+ interface BlockLocalizedEntry {
30
+ localized?: {
31
+ meta?: {
32
+ title?: string;
33
+ };
34
+ name?: string;
35
+ content?: {
36
+ mdx?: string;
37
+ };
38
+ };
39
+ }
40
+ interface BlockAPI {
41
+ listAllContent(filters: {
42
+ kind: 'block';
43
+ }): Iterable<BlockManifest>;
44
+ getLocalized(id: string, locale: string): Promise<BlockLocalizedEntry | null>;
45
+ }
77
46
  /**
78
- * Create a component scope by merging defaults with custom components
47
+ * Evaluate all MDX blocks from a compatible content API.
79
48
  *
80
- * @param customComponents - Project-specific components
81
- * @returns Merged component scope
49
+ * Returns structured success/error results so callers can decide how to
50
+ * surface broken blocks instead of hardcoding fallback UI in this package.
82
51
  */
83
- declare function createComponentScope(customComponents?: Record<string, any>): {};
52
+ declare function evaluateMDXBlocks(api: BlockAPI, locale: string): Promise<MDXBlockEvaluationResult[]>;
53
+ //#endregion
54
+ //#region src/mdx/compile.d.ts
55
+ declare function compileMDX(content: string): Promise<MDXCompileResult>;
84
56
  //#endregion
85
57
  //#region src/mdx/evaluate.d.ts
86
58
  /**
@@ -126,5 +98,5 @@ declare function evaluateMDXToComponent(mdxContent: string, options?: {
126
98
  error?: Error;
127
99
  }>;
128
100
  //#endregion
129
- export { type MDXCompileResult, type MDXCompiler, compileMDX, createComponentScope, createMDXCompiler, evaluateMDXBlocks, evaluateMDXToComponent };
101
+ export { type EvaluatedMDXBlock, type FailedMDXBlockEvaluation, type MDXBlockEvaluationResult, type MDXCompileResult, compileMDX, evaluateMDXBlocks, evaluateMDXToComponent };
130
102
  //# sourceMappingURL=node.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.mts","names":[],"sources":["../src/blocks.ts","../src/types.ts","../src/mdx/compile.ts","../src/mdx/evaluate.ts"],"mappings":";;;;;;AAkCA;;;;;;;;;;;;;;;;;;;;;;;AC9BA;;;;i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pB,oBACA;EAAY;IACX;EAAU,WAAW;EAAsB,QAAQ"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Node.js-specific exports for @conloca/mdx
3
+ *
4
+ * These exports require Node.js runtime APIs and should not be imported in browser environments.
5
+ * Import from '@conloca/mdx/node' for server-side MDX operations.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Server-side code (Astro, Next.js, etc.)
10
+ * import { evaluateMDXToComponent } from '@conloca/mdx/node';
11
+ * ```
12
+ */
13
+ export { evaluateMDXBlocks } from './blocks.js';
14
+ export { compileMDX } from './mdx/compile.js';
15
+ export { evaluateMDXToComponent } from './mdx/evaluate.js';
16
+ export type { EvaluatedMDXBlock, FailedMDXBlockEvaluation, MDXBlockEvaluationResult, MDXCompileResult, } from './types.js';
17
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
package/dist/node.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Node.js-specific exports for @conloca/mdx
3
+ *
4
+ * These exports require Node.js runtime APIs and should not be imported in browser environments.
5
+ * Import from '@conloca/mdx/node' for server-side MDX operations.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Server-side code (Astro, Next.js, etc.)
10
+ * import { evaluateMDXToComponent } from '@conloca/mdx/node';
11
+ * ```
12
+ */
13
+ export { evaluateMDXBlocks } from './blocks.js';
14
+ // MDX compilation and evaluation (Node.js only)
15
+ export { compileMDX } from './mdx/compile.js';
16
+ export { evaluateMDXToComponent } from './mdx/evaluate.js';