{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rich-text",
  "title": "Rich Text",
  "description": "A paragraph of copy with *italic* and [linked words] markup; links open in a new tab with a small arrow. No dependencies.",
  "files": [
    {
      "path": "registry/mewo/ui/rich-text.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\nexport type MarkupPart = { kind: \"text\" | \"em\" | \"link\"; value: string }\n\n/** Splits copy written with *italic* and [linked words] markup into parts. */\nexport function parseMarkup(text: string): MarkupPart[] {\n  const out: MarkupPart[] = []\n  const re = /\\*([^*]+)\\*|\\[([^\\]]+)\\]/g\n  let last = 0\n  for (const m of text.matchAll(re)) {\n    if (m.index! > last) out.push({ kind: \"text\", value: text.slice(last, m.index) })\n    out.push(m[1] ? { kind: \"em\", value: m[1] } : { kind: \"link\", value: m[2]! })\n    last = m.index! + m[0].length\n  }\n  if (last < text.length) out.push({ kind: \"text\", value: text.slice(last) })\n  return out\n}\n\nexport interface RichTextProps extends React.ComponentProps<\"p\"> {\n  /** Copy with *italic* and [linked words] markup. */\n  text?: string\n  /** Where the linked words point (they open in a new tab). */\n  href?: string\n}\n\n/** A paragraph of story copy: *italic* words, and [linked words] with a small arrow. */\nexport function RichText({ text = \"Story copy with *italic* words and a [linked phrase].\", href = \"#\", className, ...props }: RichTextProps) {\n  return (\n    <p data-slot=\"rich-text\" className={cn(className)} {...props}>\n      {parseMarkup(text).map((p, i) =>\n        p.kind === \"em\" ? (\n          <em key={i}>{p.value}</em>\n        ) : p.kind === \"link\" ? (\n          <a\n            key={i}\n            href={href}\n            target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            className=\"pointer-events-auto underline decoration-[0.06em] underline-offset-[0.12em] transition-opacity hover:opacity-70 motion-reduce:transition-none\"\n          >\n            {p.value}\n            <svg className=\"ml-[0.08em] inline-block size-[0.45em] align-[0.5em]\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n              <path d=\"M3 9 9 3M4.5 3H9v4.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.2\" />\n            </svg>\n          </a>\n        ) : (\n          p.value\n        )\n      )}\n    </p>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "added": "2026-10-27",
    "unlisted": true
  },
  "categories": [
    "text"
  ],
  "type": "registry:ui"
}