@fusebase/markdown-viewer

中文文档
0.1.8发布于 2026/10/14SEE LICENSE IN LICENSETypeScriptES Module近 30 天下载 1998

The portable half of the FuseBase v3 markdown note editor: everything that knows about our directive syntax without knowing about ProseMirror, the DOM or Next.

原始使用文档
文档目录7 节
  1. What lives here
  2. Entry points
  3. <MarkdownViewer>
  4. The three host-bound directives
  5. Styling
  6. The public view
  7. What deliberately does not

@fusebase/markdown-viewer

The portable half of the FuseBase v3 markdown note editor: everything that knows about our directive syntax without knowing about ProseMirror, the DOM or Next.

What lives here

  • directive-widget-attrs.ts — validation and normalisation of every directive attribute. Import-free on purpose, so it stays usable from Node.
  • directive-mdast.ts — how each directive is written in markdown.
  • directive-dom.ts — how each directive is drawn, as data. The editor's ProseMirror nodes hand these straight back to ProseMirror; <MarkdownViewer> turns them into hast. One description, two renderers.
  • directive-hast.ts + markdown-viewer.tsx — the browser entry point.
  • mermaid.ts — the diagram renderer and its theme, behind await import().

Entry points

ImportWhat it is
@fusebase/markdown-viewerthe dependency-free layer: attributes, mdast specs, DOM specs
@fusebase/markdown-viewer (node condition)the above plus parseMarkdown() / serializeMarkdown()
@fusebase/markdown-viewer (browser condition)the above plus <MarkdownViewer>

They are three separate source files (src/index.ts, src/node.ts, src/browser.ts) rather than one barrel, so a consumer does not load the remark chain unless it imports the entry that needs it.

<MarkdownViewer>

import { MarkdownViewer } from '@fusebase/markdown-viewer';

<MarkdownViewer markdown={note.markdown} className="note-body" />;

Read-only, and read-only by construction rather than by a flag: there is no ProseMirror here at all, so nothing it renders is editable. React is a peer dependency (>=18) and never bundled.

<MarkdownEditor> — full edit mode — is a later iteration.

The three host-bound directives

::fusebase-dashboard, ::fusebase-iframe and :fusebase-mention need the dashboard blot, the user-search API and next-intl, so they stay in the host application. The viewer renders them as a placeholder carrying data-directive and their attributes; a host that can draw them replaces that element through the components prop.

Styling

import '@fusebase/markdown-viewer/viewer.css';

That is the whole stylesheet a note needs: the --md-* brand map, the callouts, the directive widgets, the tone table and a prose base for the viewer's md-note root. It imports tokens.css itself, so a host never needs both.

Every widget rule is scoped to :is(.markdown-note-editor .milkdown .ProseMirror, .md-note) — the editor and the viewer draw the same widgets from the same DomSpec, so one file styles both. The prose base is scoped to .md-note alone, since in the editor Crepe supplies it. Crepe frame overrides stay in the host editor, which imports this one; the widget settings pencil and its popover are here, because the popover mounts on <body> and reads the same token map.

A host that renders math also needs KaTeX's own stylesheet — the viewer calls katex.renderToString but does not ship its CSS:

import 'katex/dist/katex.min.css';

The public view

import { MarkdownViewer, PUBLIC_VIEW_COMPONENTS } from '@fusebase/markdown-viewer';

<MarkdownViewer markdown={note.markdown} components={PUBLIC_VIEW_COMPONENTS} />;

What the three host-bound directives do when the reader is anonymous — a share link, a portal, a published site. A dashboard becomes a static placeholder, an iframe is framed only for an https URL on PUBLIC_EMBED_HOSTS and otherwise shown as its link, and a mention is the display name as text with no lookup. See public-components.tsx.

What deliberately does not

The editor node definitions and the three host-bound directives (::fusebase-dashboard, ::fusebase-iframe, :fusebase-mention) stay in the host application — they pull in the dashboard blot, the user-search API and next-intl.

版本与发布记录

@fusebase/markdown-viewer 共发布 6 个版本,首次发布于 2026/10/14;过去 12 个月发布了 6 个版本。

版本发布日期距今
0.1.8latest2026/10/141 个月前
0.1.72026/10/141 个月前
0.1.62026/10/141 个月前
0.1.42026/10/141 个月前
0.1.52026/10/141 个月前
0.0.0-stage2026/10/141 个月前

关于 @fusebase/markdown-viewer 的常见问题

@fusebase/markdown-viewer 是什么?

The portable half of the FuseBase v3 markdown note editor: everything that knows about our directive syntax without knowing about ProseMirror, the DOM or Next.

如何安装 @fusebase/markdown-viewer?

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

@fusebase/markdown-viewer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fusebase/markdown-viewer 支持 ESM 还是 CommonJS?

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

@fusebase/markdown-viewer 需要什么版本的 Node.js?

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

@fusebase/markdown-viewer 可以商用吗?

@fusebase/markdown-viewer 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@fusebase/markdown-viewer 的下载量有多少?

根据 npm 官方下载统计,@fusebase/markdown-viewer 在 2026/10/16 – 2026/11/14 这 30 天内被下载 1,998 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fusebase/markdown-viewer 还在维护吗?

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