'use client';

/**
 * `@djangocfg/ui-tools/markdown-editor` subpath entrypoint.
 *
 * `MarkdownEditor` is a TipTap WYSIWYG with the full ProseMirror + TipTap
 * extension stack — `@tiptap/react`, `starter-kit`, `markdown`, `mention`,
 * `placeholder`, plus our `createMentionSuggestion` (floating-ui anchored
 * dropdown). Together that's ~200 KB minified — wrap it in React.lazy so
 * pages that don't render an editor don't pay.
 *
 * Light surface kept here:
 *   - All public types (erased at compile time).
 *   - `mentionPresets` — pure data describing how to render mentions to
 *     markdown. No TipTap imports at module scope.
 */

import { createLazyComponent, LoadingFallback } from '../../components';
import type { MarkdownEditorProps } from './MarkdownEditor';

export const LazyMarkdownEditor = createLazyComponent<MarkdownEditorProps>(
  () => import('./MarkdownEditor').then((m) => ({ default: m.MarkdownEditor })),
  {
    displayName: 'LazyMarkdownEditor',
    fallback: <LoadingFallback minHeight={140} text="Loading editor…" />,
  },
);

// Light surface — pure helpers + types.
export { mentionPresets } from './mentionPresets';

export type {
  MarkdownEditorProps,
  MarkdownEditorHandle,
} from './MarkdownEditor';

export type {
  MentionItem,
  MentionConfig,
  MentionAttrs,
  MentionMarkdownRenderer,
} from './types';
