@bendyline/docblocks-react

中文文档
2.7.13发布于 2026/11/06MITTypeScriptES Module构建来源已验证近 30 天下载 1965

React components for DocBlocks — file explorer, workspace picker, and editor shell

原始使用文档
文档目录14 节
  1. Installation
  2. Usage
  3. Components
  4. DocBlocksShell
  5. FileExplorer / FileTreeNode
  6. WorkspacePicker
  7. AppMenu
  8. ExportToolbarControls / ExportDialog
  9. Hooks
  10. useDocumentSession(delay?)
  11. useFileTree(provider)
  12. Styles
  13. Where new UI belongs
  14. License

@bendyline/docblocks-react

React components for DocBlocks — the complete editor shell (file explorer, workspace picker, app menu, export pipeline) plus the individual components and hooks it's built from. This is the package the DocBlocks web app and desktop renderer both mount.

Installation

npm install @bendyline/docblocks-react react react-dom
npm install --save-dev @types/react @types/react-dom

Peer dependencies: React 18 or 19. TypeScript consumers must install the matching @types/react major (and normally @types/react-dom); the React type peer is optional so JavaScript-only consumers do not need type packages. The DocBlocks core (@bendyline/docblocks) and the Squisq editor packages are regular dependencies and install automatically.

Usage

import { DocBlocksShell } from '@bendyline/docblocks-react';
import '@bendyline/docblocks-react/styles';

function App() {
  return <DocBlocksShell theme="auto" />;
}

The video-export worker uses module chunks. Vite consumers must retain the same worker setting used by the DocBlocks site and desktop renderer:

// vite.config.ts
import { defineConfig } from 'vite';

export default defineConfig({ worker: { format: 'es' } });

Formula grids can opt into the full IronCalc engine through the separately built calculation entry point. Publish @ironcalc/wasm/wasm_bg.wasm at a same-origin URL and keep the factory at module scope so the engine remains lazy and reusable:

import { createDocBlocksCalcEngineFactory } from '@bendyline/docblocks-react/calculation';

const calcEngineFactory = createDocBlocksCalcEngineFactory({
  wasmSource: '/ironcalc/wasm_bg.wasm',
});

function App() {
  return <DocBlocksShell calcEngineFactory={calcEngineFactory} />;
}

Components

DocBlocksShell

The canonical DocBlocks experience in one component — file explorer, workspace picker, app menu, the Squisq editor with its Editor / Markdown / Play views, and the export pipeline.

<DocBlocksShell theme="auto" logoUrl="/logo.png" />
  • theme — 'light' | 'dark' | 'auto' (auto follows prefers-color-scheme)
  • logoUrl — brand mark for the app menu button
  • calcEngineFactory — optional lazy calculation backend; use the calculation entry point above to enable IronCalc formulas
  • ffmpegWasm — optional same-origin ffmpeg core URLs; supplying them enables the built-in Animated GIF flow on cross-origin-isolated hosts. No first-party surface supplies this. The @ffmpeg/core WebAssembly build is GPL-2.0-or-later, which cannot be reconciled with Apple's App Store terms, so it was removed from every DocBlocks distribution. The prop remains for hosts that bring their own encoder
  • showCodeCopyButton — shows Copy controls on ordinary fenced code blocks (default: true; Mermaid fences remain diagrams)
  • onCopyCode — optional clipboard adapter for native hosts; browser hosts fall back to navigator.clipboard.writeText

Storage is abstracted behind the byte-authoritative FileSystemProviderV2 contract from @bendyline/docblocks/filesystem: browser-local (IndexedDB), native folders (File System Access API), transient memory workspaces, or the Electron host. Built-in compatibility facades expose it as provider.v2; first-party shell and file-tree operations are v2-first.

FileExplorer / FileTreeNode

File tree browser with inline create (file + folder), rename, and delete. It follows filesystem watch events automatically and re-reads the visible tree when a browser surface resumes. Long names truncate gracefully.

WorkspacePicker

Dropdown for switching between workspaces, creating new ones, and opening local folders, plus the per-workspace settings dialog (rename, download, remove, version-history overrides).

AppMenu

Top-left brand menu with the app-wide Settings dialog (theme preference, global version-history default), optional "Back up all workspaces," a Help group (keyboard shortcuts, documentation), and the About dialog.

ExportToolbarControls / ExportDialog

Consumers that need the export pipeline without the complete shell can use the public, independently built entry point:

import {
  DEFAULT_OPTIONS,
  ExportDialog,
  buildExportFilename,
  runExport,
} from '@bendyline/docblocks-react/export';

The shell overflow also offers Share link with content embedded. It creates a bounded #shared(<base64>) URL containing a compressed, Markdown-only copy and an optional initial Use mode. Opening the URL creates a session-only workspace; generated links warn after 4,096 characters and are capped at 32,768 characters.

The export flow: quick re-export of the last configuration plus the full dialog — format (PDF, Word, PowerPoint, EPUB, HTML, Markdown), visual theme, and page size. Video export is available wherever WebCodecs is, and uses the MIT-licensed mp4-muxer. A host that supplies ffmpegWasm additionally exposes Animated GIF with timing, orientation, captions, looping, and color controls; no first-party surface does. Animated GIF remains available from the CLI and MCP, which use a system FFmpeg binary rather than a distributed one.

Rendered HTML and HTML ZIP exports include Copy controls for ordinary fenced code blocks; Mermaid fences remain diagrams.

Hooks

useDocumentSession(delay?)

React binding for the revisioned DocumentSession. Active-document writes, transitions, conflicts, and close preparation must flow through this session; there is intentionally no independent autosave hook.

useFileTree(provider)

File tree state management over any v2-capable provider — returns the tree, selection, and explicit create/move/remove functions, with a temporary v1 fallback for external providers.

Styles

import '@bendyline/docblocks-react/styles';

One explicit stylesheet import covers the Squisq editor and all DocBlocks components in both themes. Theme fonts are supplied by the host application; this package does not bundle fonts.

Where new UI belongs

Cross-surface UI that lives inside the shell chrome (file tree, workspace picker, app menu, export dialog) belongs here. The VS Code extension is the deliberate exception — its webview mounts Squisq's EditorShell directly because VS Code provides the file explorer, workspace, and theme itself.

License

MIT

版本与发布记录

@bendyline/docblocks-react 共发布 36 个版本,首次发布于 2026/04/04;过去 12 个月发布了 36 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.7.13latest2026/11/062 天前
2.7.122026/11/062 天前
2.7.112026/11/017 天前
2.7.102026/10/318 天前
2.7.92026/10/309 天前
2.7.82026/10/2811 天前

关于 @bendyline/docblocks-react 的常见问题

@bendyline/docblocks-react 是什么?

React components for DocBlocks — file explorer, workspace picker, and editor shell

如何安装 @bendyline/docblocks-react?

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

@bendyline/docblocks-react 支持 TypeScript 吗?

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

@bendyline/docblocks-react 支持 ESM 还是 CommonJS?

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

@bendyline/docblocks-react 需要什么版本的 Node.js?

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

@bendyline/docblocks-react 可以商用吗?

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

@bendyline/docblocks-react 的下载量有多少?

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

@bendyline/docblocks-react 还在维护吗?

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