@ai-matrx/rich-content

中文文档
0.2.336发布于 2026/10/30MITES Module近 30 天下载 9.6万

The AI Matrx formatted-text engine: the one markdown renderer, streaming markdown, the block splitter and renderer, the generic blocks, levels, the rich-document action registry and menus, copy, and the selection toolbar — as portable React

原始使用文档
文档目录4 节
  1. Install
  2. Use
  3. Host
  4. The editor section

@ai-matrx/rich-content

The AI Matrx formatted-text engine as portable React: the one markdown renderer (GFM, math, directives, wikilinks, mentions, footnotes, streaming heal), the block splitter (static and streaming), and — as the extraction completes — the block renderer and generic blocks, <RichContent> levels, the rich-document action registry and menus, copy, and the selection toolbar. The editor is the sibling package @ai-matrx/rich-content/editor.

Install

pnpm add @ai-matrx/rich-content

Peers: react, react-dom (>= 19). Tailwind consumers add the package's dist to their content sources (@source "../node_modules/@ai-matrx/rich-content/dist";).

Use

Import modules by path — one specifier is one module, so client/server boundaries and lazy chunks stay intact:

import MarkdownCore from "@ai-matrx/rich-content/markdown-core/MarkdownCore";
import { splitContentIntoBlocksV2 } from "@ai-matrx/rich-content/display/markdown-classification/processors/utils/content-splitter-v2";

<RichContent> options for a narrow, plain-GFM host (the Chrome extension side panel). Every one is optional and its absence renders exactly as before (types in levels/rich-content-types.ts): density="compact", codeTheme="github", customTags={{ reflection: MyBlock }} (standard level), remoteImages="always", dataImages="allow" (draw data:image svg/png/jpeg/gif/webp as <img src>, ≤4M chars; default refuses), math={false} / rawHtml={false} (inline and standard levels, client render only; ignored with a dev warning at full; fenced ```html stays code), codeHeader="compact" (one-line language + copy header on every fence, code text capped at 12px, no TooltipProvider needed), themeMode="light" | "dark" (overrides the host's useThemeMode binding for everything drawn).

Host

The engine renders with no host at all. Every capability it can ask for has a default that announces itself once on the console and marks degraded elements data-rich-content-host="bare". Configure once at the app root:

import { configureRichContent } from "@ai-matrx/rich-content/host";

configureRichContent({
  toast,                 // your toast (structural: success/error/info/warning/loading/dismiss)
  captureError,          // your error sink
  ErrorActions,          // extra actions beside an error message
  NestedContent,         // nested markdown renderer (standard level)
  wikilinks,             // { resolve, create, loadBody } against your records
  resolvePerson,         // @mentions
  ResourcePeek,          // your record peek
  splitterEnvelopes,     // content-IR envelope hooks for complete regions
  useOpenSaveToTable,    // "save these rows as a table"
});
CapabilityDefault on a bare host
toastthe console
captureErrorconsole.error
ErrorActionsnone (the message always shows)
NestedContentthe source as plain text
wikilinksevery link reads "unavailable"
resolvePersonthe mention label as written
ResourcePeekthe chip is not clickable
splitterEnvelopesregions carry no metadata.__ir
useOpenSaveToTableno "save as table" button

MIT licensed.

The editor section

Visual (Tiptap), Source (CodeMirror), Preview, the markdown formatting command layer and edit-in-place — imported as @ai-matrx/rich-content/editor/<core|in-place|format|islands|panels|source|visual|editor>/<module>, stylesheet @ai-matrx/rich-content/editor.css. Render-only imports never load it. See src/editor/README.md.

版本与发布记录

@ai-matrx/rich-content 共发布 324 个版本,首次发布于 2026/10/07;过去 12 个月发布了 324 个版本。

版本发布日期距今
0.2.336latest2026/10/306 天前
0.2.3352026/10/298 天前
0.2.3342026/10/288 天前
0.2.3332026/10/288 天前
0.2.3322026/10/289 天前
0.2.3312026/10/279 天前

其他发布通道:bootstrap → 0.0.0。

关于 @ai-matrx/rich-content 的常见问题

@ai-matrx/rich-content 是什么?

The AI Matrx formatted-text engine: the one markdown renderer, streaming markdown, the block splitter and renderer, the generic blocks, levels, the rich-document action registry and menus, copy, and the selection toolbar — as portable React

如何安装 @ai-matrx/rich-content?

在项目目录运行 npm install @ai-matrx/rich-content,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)、react-dom(>=19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ai-matrx/rich-content 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ai-matrx__rich-content 是否存在。

@ai-matrx/rich-content 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ai-matrx/rich-content 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ai-matrx/rich-content 可以商用吗?

@ai-matrx/rich-content 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ai-matrx/rich-content 的下载量有多少?

根据 npm 官方下载统计,@ai-matrx/rich-content 在 2026/10/05 – 2026/11/03 这 30 天内被下载 96,257 次,日均约 3,209 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ai-matrx/rich-content 还在维护吗?

最新版本 0.2.336 发布于 2026/10/30(6 天前);至今共发布 324 个版本,其中过去 12 个月发布了 324 个;首次发布于 2026/10/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。