开源、端到端加密的 Google 文档替代方案。
ddocs.new is your privacy-focused, open-source alternative to Google Docs. It is an end-to-end encrypted document editor that is optimized for multiplayer collaboration without compromising on speed or people's control over their data.
This repository contains:
/package – The core package code.Your app runs Tailwind CSS 3.4 and owns the @tailwind base/components/utilities entry. The package ships only editor CSS; preflight, utilities, the @fileverse/ui styles, and the KaTeX stylesheet come from your build.
import { DdocEditor } from '@fileverse-dev/ddoc';Load stylesheets in this order (Vite emits CSS in import order; in Next put the first two in the root layout and the last two in the editor route):
import './globals.css'; // your tailwind entry
import '@fileverse/ui/styles/base'; // tokens and base rules
import 'katex/dist/katex.min.css'; // math; fonts are served as files
import '@fileverse-dev/ddoc/styles'; // editor CSSThis package requires the following peer dependencies to be installed in your project:
npm install @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities @fileverse/ui @fileverse/crypto viem framer-motion frimousse| Package | Version |
|---|---|
@dnd-kit/core |
>=6.3.1 |
@dnd-kit/sortable |
>=10.0.0 |
@dnd-kit/utilities |
>=3.2.2 |
@fileverse/ui |
^5.4.2 |
@fileverse/crypto |
>=0.0.21 |
viem |
>=2.13.8 |
framer-motion |
>=11.2.10 |
frimousse |
>=0.3.0 |
The peer range is @fileverse/ui@^5.4.2. If you ever test a prerelease pairing, pin both packages exactly: a prerelease never satisfies a caret range.
These are externalized from the bundle to avoid duplication when your app already uses them. If you don't have them installed, npm (v7+) will auto-install them for you.
module.exports = {
presets: [require('@fileverse-dev/ddoc/tailwind')],
content: [
'./src/**/*.{js,ts,jsx,tsx}',
'./node_modules/@fileverse-dev/ddoc/dist/**/*.{js,mjs}',
'./node_modules/@fileverse/ui/dist/**/*.{js,mjs}',
],
};Both dist globs are required, not the single index.es.js entry: the dist is chunked (index.es.js
statically imports use-headless-editor-.mjs), so a single-file entry leaves that chunk's
classes ungenerated.
The preset composes @fileverse/ui/tailwind (class-based dark mode, animate plugin, design-system classes) and adds the mobile: 960px screen the editor uses.
tailwindcss@^3.4.0 is an optional peer: the preset runs inside your own Tailwind build, which also supplies the postcss and postcss-js the ui preset loads. Tailwind 4 is not supported.
5.0 stops shipping preflight, Tailwind utilities, the ui stylesheet, the KaTeX stylesheet, and the html, body, and * resets. To upgrade:
Add the preset and the two content entries above.
Import @fileverse/ui/styles/base and katex/dist/katex.min.css yourself, in the order above.
The package no longer ships these global declarations:
* { margin: 0; padding: 0 }html, body { height: 100%; width: 100% }html, body { overflow: hidden }body { position: static; user-select: none; -moz-osx-font-smoothing: grayscale }*, ::before, ::after { border-color: hsl(var(--color-border-default)) }If your shell relied on overflow: hidden or user-select: none, add them to your own
global stylesheet. The rest are covered by Tailwind preflight or the @fileverse/ui/styles/base
sheet.
Remove any workaround that re-declared mobile: classes; the preset generates them.
Add katex to your own dependencies (npm install katex@^0.16.11); the package no longer guarantees it is hoisted.
If you styled anything from the old bundle by class name: .custom-scrollbar is now .ddoc-scrollbar, and .highlight-comment-bg, .is-active, .custom-border-bg, .animate-fade-in-out, .placeholder-disabled, .tooltip:before were removed as unused.
The composed @fileverse/ui preset defines rounded-sm as calc(var(--radius) - 4px) (4px)
instead of Tailwind's default 2px, so any surface using ddoc's rounded-sm utilities now
renders 4px corners.
Third-party CSS ddoc imports (the highlight.js theme, tippy) still ships global .hljs* and
.tippy-box selectors — this is outside the package's own selector-ownership guarantee.
List rules (ul, ol, and the nested-list counters) are now scoped to
:where(.ProseMirror, .presentation-mode) and no longer style ol/ul outside the editor or
presentation surfaces. If your app relied on ddoc's global list rules elsewhere, own them yourself.
You should now be set to use dDocs!
The DdocProps interface is a TypeScript interface that defines the properties for a page-related component. It includes properties for handling preview mode, managing publishing data, and optionally storing metadata and content associated with the page.
| Property | Type | Description |
|---|---|---|
initialContent |
JSONContent |
Initial content of the editor |
onChange |
(changes: JSONContent, chunk?: any) => void |
Callback triggered on editor content changes |
ref |
React.RefObject |
Reference to access editor instance |
isPreviewMode |
boolean |
Controls if editor is in preview/read-only mode |
editorCanvasClassNames |
string |
Additional CSS classes for editor canvas |
ignoreCorruptedData |
boolean |
Whether to ignore corrupted data during loading |
onInvalidContentError |
(error: any) => void |
Callback for handling invalid content errors |
| Property | Type | Description |
|---|---|---|
enableCollaboration |
boolean |
Enables real-time collaboration features |
collaborationId |
string |
Unique ID for collaboration session (required when collaboration enabled) |
username |
string |
User's display name for collaboration |
setUsername |
(username: string) => void |
Function to update username |
walletAddress |
string |
User's wallet address |
onCollaboratorChange |
(collaborators?: IDocCollabUsers[]) => void |
Callback when collaborators change |
enableIndexeddbSync |
boolean |
Enables IndexedDB sync for offline support |
ddocId |
string |
Unique document ID (required for IndexedDB sync) |
| Property | Type | Description |
|---|---|---|
zoomLevel |
string |
Current zoom level of the editor |
setZoomLevel |
React.Dispatch> |
Function to update zoom level |
isNavbarVisible |
boolean |
Controls navbar visibility |
setIsNavbarVisible |
React.Dispatch |
Function to toggle navbar visibility |
renderNavbar |
() => JSX.Element |
Custom navbar renderer |
renderThemeToggle |
() => JSX.Element |
Custom theme toggle renderer |
isPresentationMode |
boolean |
Controls presentation mode |
setIsPresentationMode |
React.Dispatch |
Function to toggle presentation mode |
sharedSlidesLink |
string |
Link for shared presentation slides |
documentStyling |
DocumentStyling |
Custom styling for document appearance |
fonts |
FontDescriptor[] |
Consumer-provided font catalog (see Custom Fonts) |
The documentStyling prop allows you to customize the visual appearance of your document with three distinct styling areas:
…Note: Document styling works in both regular editor mode and presentation mode. In presentation mode, only canvasBackground, textColor, and fontFamily are applied to maintain clean slide appearance.
The editor ships with a system-font baseline only (Arial, Calibri, Georgia, Times New Roman, etc.) and makes no third-party font requests — there is no Google Fonts @import. To offer additional fonts, pass a fonts catalog. Each font is self-hosted by your app and loaded on demand via the CSS Font Loading API: a font's woff2 is fetched only when it's selected in the picker or when a document (including a remote collaborator's change) actually renders text in it.
…import { DdocEditor, FontDescriptor } from '@fileverse-dev/ddoc';
// Self-host the woff2 files however your bundler prefers (e.g. @fontsource/*).
import poppins400 from '@fontsource/poppins/files/poppins-latin-400-normal.woff2';
import poppins700 from '@fontsource/poppins/files/poppins-latin-700-normal.woff2';
const fonts: FontDescriptor[] = [
{
name: 'Poppins',
family: 'Poppins, sans-serif',
url: { 400: poppins400, 700: poppins700 },
preview: , // optional SVG
},
];
;Notes:
family, so name is purely cosmetic and can differ (e.g. name: 'Poppins (Brand)', family: 'Poppins, sans-serif').@font-face rules for the registered fonts.woff2 files **s暂无开放 Issues,或尚未同步最近议题。