@fiduswriter/editor

中文文档
0.2.48发布于 2026/11/12AGPL-3.0TypeScriptES Module近 30 天下载 2336

Fidus Writer browser editor

原始使用文档
文档目录8 节
  1. What it does
  2. Key features
  3. Installation
  4. Usage
  5. Embedding in another application
  6. Demo
  7. Development
  8. License

@fiduswriter/editor

@fiduswriter/editor

The ProseMirror-based editor component of Fidus Writer


What it does

The main browser-based collaborative editor for Fidus Writer. Built on ProseMirror, it provides real-time collaboration, comments, tracked changes, footnotes, citations, end-to-end encryption (E2EE), menus, dialogs, and clipboard import/export.

Key features

  • Real-time collaboration — WebSocket-based collaborative editing with participant carets, diffs, and versioning
  • Track changes — Accept/reject individual changes with full change history
  • Comments — Threaded commenting with annotation marks and resolution
  • Footnotes — Inline footnote editing with proper layout
  • Citations — Citeproc-js based citation rendering with bibliography generation
  • E2EE — End-to-end encryption with key management and passphrase support
  • Spell/grammar checker — Built-in client-side checking (lingotweaker-wasm) with wavy-underline marks and replacement suggestions, manual or continuous
  • Clipboard — Paste from Word, LibreOffice, Google Docs with format preservation
  • Tables, figures & equations — Full editing support for tables, images, math formulas, and code blocks

Installation

npm install @fiduswriter/editor

Usage

The library can be used in two modes: static (no backend server, like the standalone demo) or server-backed (the classic Fidus Writer Django setup).

For a quick start without a backend, import createStaticEditor from the @fiduswriter/editor/static_editor subpath:

import {createStaticEditor} from "@fiduswriter/editor/static_editor"

const editor = await createStaticEditor({
    locale: "en",
    username: "Demo User",
    documentData: async () => ({doc, doc_info, time: Date.now()}),
    documentStyles: [/* style fixtures */],
    exportTemplates: [/* export template fixtures */],
    documentTemplates: {/* document template fixtures */}
})

Full API documentation, configuration options, and a complete server-backed usage example are available on the project site:

https://fiduswriter.pages.fiduswriter.org/fiduswriter-editor-ts/

Embedding in another application

The editor can be embedded directly into a host page (a CMS, a plugin, another application) — no iframe required:

  1. Mount the editor into a container element with the mount option. The editor renders its UI inside a div.fw-editor container (in full-page mode it replaces document.body instead, and that body carries the fw-editor class).
  2. Load the editor's own stylesheets as-is: they are container-safe (fw--prefixed classes, and the editor root targets .fw-editor).
  3. Load fwtoolkit's scoped stylesheets for the host page. fwtoolkit ships scripts/build-scoped-css.js which writes css-scoped/ — copies of its sheets with the page-context body/html rules scoped to a container selector: node node_modules/fwtoolkit/scripts/build-scoped-css.js --prefix "#my-app .fw-editor"
  4. Add an inert reset link (<link rel="stylesheet" href=".../css/reset.css" disabled />) so the editor does not inject the global (unscoped) reset.
  5. If the editor opens dialogs that should stay inside the container, the host can additionally scope stylesheets with bare element selectors (document.css) via scopeCss(css, {prefix, elements: true}) (exported by fwtoolkit).

A working reference implementation is the embedded demo:

https://fiduswriter.pages.fiduswriter.org/fiduswriter-editor-ts/embedded/

demo/embedded/ shows the editor running inside a page that has its own header and content — the pattern that a WordPress/Drupal/Joomla plugin or any other host would use.

Demo

A standalone browser demo is published on Forgejo Pages:

https://fiduswriter.pages.fiduswriter.org/fiduswriter-editor-ts/editor/

The demo loads the editor without a Django backend. On startup it lets you choose a language, import an existing document, or start from a default template. Changes are saved locally and can be downloaded as a .fidus file.

Development

npm install          # Install dependencies
npm run build        # Compile TypeScript to dist/
npm run typecheck    # Check types without emitting
npm run lint         # Lint with ESLint
npm run format:check # Check formatting with Prettier
npm test             # Run the test suite

License

AGPL-3.0 — see LICENSE for details.

版本与发布记录

@fiduswriter/editor 共发布 116 个版本,首次发布于 2026/07/14;过去 12 个月发布了 116 个版本。

版本发布日期距今
0.2.48latest2026/11/122 天前
0.2.472026/10/2322 天前
0.2.462026/10/2124 天前
0.2.452026/10/2125 天前
0.2.442026/10/121 个月前
0.2.432026/10/121 个月前

关于 @fiduswriter/editor 的常见问题

@fiduswriter/editor 是什么?

Fidus Writer browser editor

如何安装 @fiduswriter/editor?

在项目目录运行 npm install @fiduswriter/editor,或使用 pnpm add / yarn add / bun add。

@fiduswriter/editor 支持 TypeScript 吗?

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

@fiduswriter/editor 支持 ESM 还是 CommonJS?

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

@fiduswriter/editor 可以商用吗?

@fiduswriter/editor 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@fiduswriter/editor 的下载量有多少?

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

@fiduswriter/editor 还在维护吗?

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