Reference Components and hooks
Components and hooks
Everything @rebodocs/react exports — four components, thirteen hooks, the functions beside them, and a way to use it without React.
Which one do I need?
Pick what you want to build. The editor on the right shows which part comes from Rebodocs and which part is yours.
'use client';
import { DocsEditor } from '@rebodocs/react';
export function Receipt({ file }: { file: Uint8Array }) {
return (
<div className="h-screen">
<DocsEditor docx={file} name="receipt.docx" onSave={save} />
</div>
);
}Give it a height. The editor and the pages fill their container and scroll themselves. Use h-full, or flex-1 min-h-0 inside a column.
Components
The whole editor — toolbar, ruler, side panel, pages and status bar.
- Fills its container
- Needs a height
- Takes DocsProvider props
ADDS THESE PROPS
featuresversionsclassNamestyleonReadyrefPlus every prop except bubble, onLinkKey and onFindKey: it answers those itself. Changing features, versions or whether there is an onSave makes it again with the document as it is, unsaved changes and all; another docx or room opens that one. What features switches.
THE HANDLE (ref / onReady)
exportDocx()save()dirtynameeditorcollabsetNamesetAuthorsetLocalesetThemesetLetterheadshowPanelhidePanelfocusUSE IT
'use client';
import { useRef } from 'react';
import { DocsEditor, type DocsHandle } from '@rebodocs/react';
export function Contract({ file }: { file: Uint8Array }) {
const editor = useRef<DocsHandle>(undefined);
// The handle, for what your own buttons do with the document.
const send = () => upload(editor.current!.exportDocx(), 'contract.docx');
return (
<div className="flex h-screen flex-col">
<button onClick={send}>Send for signature</button>
<div className="min-h-0 flex-1">
<DocsEditor ref={editor} docx={file} name="contract.docx" locale="en" onReady={(handle) => handle?.focus()} />
</div>
</div>
);
}Holds one document for its children. It draws nothing.
- Wrap your own UI with it
- Keep docx stable
- Latest callback wins
docxUint8Array | ArrayBufferunsavedbooleannamestringlocalestringlocalesRecord<string, Texts>letterheadBlob | { bytes, type } | string | nullfontsFontSource[]embedFontsboolean | 'subset'spellcheckSpellCheckertheme'light' | 'dark' | 'auto'languagestringonSave(docx, name) => voidonChange(editor) => voidonError(message) => voidonLinkKey() => voidonFindKey(replace) => voidbubblebooleanslashboolean | { builtIns?, commands? }variableSuggestionsboolean | { variables?, fromDocument?, allowNew? }formsbooleancollab{ url, room, ticket? }onCollab(state, peers) => voidWhy did my document reset?
The document is made again — and what was typed and not saved is gone — when docx changes, when the room of collab does (its url, room or ticket), or when there is an onSave where there was none, or the other way round. Keep docx the same value between renders: a Uint8Array held in state, not one built in the body of the component. The functions you pass may be new at each render; the last one given is the one called.
USE IT
// State a key must reach lives outside the provider, or in a child of it.
function Editor({ file }: { file: Uint8Array }) {
const [finding, setFinding] = useState(false);
return (
<DocsProvider docx={file} name="contract.docx" onSave={upload} onFindKey={() => setFinding(true)}>
<MyToolbar />
{finding && <FindBar onClose={() => setFinding(false)} />}
<DocsSurface className="h-full" />
</DocsProvider>
);
}The pages of the document. Exactly one per provider.
- Scrolls itself
- Needs a height
- className · style
STYLE IT WITH CSS VARIABLES
--dx-canvasBehind the pages#efede8--dx-page-shadowThe shadow of each page0 1px 2px rgba(47,46,43,.08), 0 10px 28px -10px rgba(47,46,43,.22)--dx-selectionThe selectionrgba(11,87,208,.2)--dx-caretThe caret#000--dx-handleThe handles on a touch screen#0b57d0
- Give it a height: h-full in something that has one, or flex-1 min-h-0 inside a column.
- Set the variables on the surface or on anything above it, in CSS or in style.
- The pages themselves are not for styling: where each letter goes is worked out, not left to the browser.
USE IT
<DocsSurface
className="min-h-0 flex-1"
style={{ '--dx-canvas': '#f6eedf', '--dx-selection': '#fbe3a6', '--dx-caret': '#b07a00' } as CSSProperties}
/>/* Or in your CSS, on the surface or on anything above it */
.editor {
--dx-canvas: #f6eedf;
--dx-page-shadow: 0 2px 10px rgb(120 80 20 / 0.16);
}The ruler: the page in centimetres, with margins and indents you can drag.
- Drawn on a canvas
- className · style
- Leave it out on narrow windows
STYLE IT WITH CSS VARIABLES
--dx-rulerBehind it#fbfaf8--dx-ruler-lineThe line under it#e6e3dc--dx-ruler-marginThe page outside the text#e6e3dc--dx-ruler-textThe room of the text#fff--dx-ruler-inkNumbers and markers#5f5d58--dx-ruler-onThe marker being dragged#0b57d0
- Put it right above the surface, as wide as it: it lines itself up with the page under it.
- After setLocale, give it a key that changes with the language to have its markers in the new one.
- A narrow window has no room for it; leave it out there.
USE IT
function Pages() {
const { narrow } = useDocsResponsive();
const locale = useSyncExternalStore(onLocaleChange, getLocale);
return (
<div className="flex h-full flex-col" style={{ '--dx-ruler': '#fffbf2', '--dx-ruler-on': '#b07a00' } as CSSProperties}>
{!narrow && <DocsRuler key={locale} />}
<DocsSurface className="min-h-0 flex-1" />
</div>
);
}Hooks
Use them inside a DocsProvider to build your own interface. Pick one and play with it — the values on the right are what the hook returns.
useDocs()
DocumentOpen the full demo →What every piece of an interface starts from: what to show, what buttons call, and the document as a whole.
Try it
Opening the editor…
What the hook returns — live
All it gives you
- ready
- False on the server and until the pages are on the page
- state
- What to show, as plain values — neutral until ready
- commands
- What buttons call: toggleMark(mark), setRunProps(props)…
- docs
- save(), download(), exportDocx(), openFile(), share(), setName()…
- editor
- The Editor itself — exportPdf(), exportMarkdown()…
Taking it apart
const { ready, state, commands, docs, editor } = useDocs();Colours are hex without #, sizes are points. Each command gives the keyboard back to the document.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocs } from '@rebodocs/react';
const button = 'rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm aria-pressed:bg-blue-100 disabled:opacity-40';
function Bold() {
const { state, commands } = useDocs();
return (
<button className={`${button} font-bold`} aria-pressed={state.bold} onClick={() => commands.toggleMark('bold')}>
B
</button>
);
}
function FontSize() {
const { state, commands } = useDocs();
return (
<select aria-label="Font size" className={button} value={state.fontSize} onChange={(e) => commands.setRunProps({ fontSize: Number(e.target.value) })}>
{[10, 11, 12, 14, 18, 24, 26].map((size) => (
<option key={size}>{size}</option>
))}
</select>
);
}
function Save() {
const { state, docs } = useDocs();
return (
<>
<button className={button} disabled={!state.dirty} onClick={() => docs?.save()}>
Save
</button>
<button className={button} disabled={!docs} onClick={() => docs?.download()}>
Word
</button>
</>
);
}useDocsValue(select, fallback)
DocumentOpen the full demo →Anything of the document that state does not carry, kept up to date. Your component is drawn again only when what select gives is different.
Try it
What the hook returns — live
All it gives you
- value
- Whatever select gives, compared as JSON
Taking it apart
const pages = useDocsValue((editor) => editor.pageCount, 1);
const hasToc = useDocsValue((editor) => editor.hasToc, false);
const cell = useDocsValue((editor) => editor.activeCellProps() ?? null, null);Give back plain data, and null where the editor says undefined. The first fallback given is kept.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocs, useDocsValue } from '@rebodocs/react';
function SpaceAfter() {
const { commands } = useDocs();
const spaced = useDocsValue((e) => e.activeParagraphProps().spacingAfter > 0, false);
return (
<button
className="rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm aria-pressed:bg-blue-100"
aria-pressed={spaced}
onClick={() => commands.setParagraphProps({ spacingAfter: spaced ? 0 : 8 })}
>
Space after
</button>
);
}useDocsCount()
DocumentOpen the full demo →How long the document is, and the selection. The whole is counted again only when the document changes.
Try it
What the hook returns — live
All it gives you
- words
- Words in the document
- characters
- Characters in the document
- selected
- The same for the selection, or undefined
Taking it apart
const { words, characters, selected } = useDocsCount();Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsCount } from '@rebodocs/react';
function Count() {
const { words, characters, selected } = useDocsCount();
return (
<span className="text-sm text-neutral-600">
{selected ? `${selected.words} of ${words} words` : `${words} words`} · {characters} characters
</span>
);
}useDocsFind()
WritingOpen the full demo →Everything a find-and-replace bar of your own needs. The keyboard stays in your field while it searches.
Try it
What the hook returns — live
All it gives you
- query · setQuery(text)
- What is looked for
- options · setOptions(o)
- { matchCase, wholeWord }
- count · index
- How many places, and which one is selected, from 1
- next() · previous()
- Go to another
- replace(text) · replaceAll(text)
- The one selected, or all as one step to undo
- close()
- Stops and gives the keyboard back
Taking it apart
const { query, setQuery, options, setOptions, count, index, next, previous, replace, replaceAll, close } = useDocsFind();query and options are kept by the component that calls it: call it once, in your find bar, and pass it down. count and index are the document’s. Open the bar from ⌘F with onFindKey on the provider.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsFind } from '@rebodocs/react';
import { useState } from 'react';
const field = 'w-32 rounded-md border border-neutral-300 px-2 py-1 text-sm';
const button = 'rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm aria-pressed:bg-blue-100 disabled:opacity-40';
function FindBar({ onClose }: { onClose: () => void }) {
const find = useDocsFind();
const [replacement, setReplacement] = useState('');
const close = () => {
find.close();
onClose();
};
return (
<div role="search" className="flex flex-wrap items-center gap-1.5">
<input
aria-label="Find"
className={field}
value={find.query}
onChange={(e) => find.setQuery(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') (e.shiftKey ? find.previous : find.next)();
if (e.key === 'Escape') close();
}}
/>
<button className={button} aria-pressed={!!find.options.matchCase} onClick={() => find.setOptions({ ...find.options, matchCase: !find.options.matchCase })}>
Aa
</button>
<span className="text-sm text-neutral-600">{find.count ? `${find.index} of ${find.count}` : 'Nothing found'}</span>
<input aria-label="Replace with" className={field} value={replacement} onChange={(e) => setReplacement(e.target.value)} />
<button className={button} disabled={!find.count} onClick={() => find.replace(replacement)}>
Replace
</button>
<button className={button} disabled={!find.count} onClick={() => find.replaceAll(replacement)}>
All
</button>
<button className={button} onClick={close}>
Close
</button>
</div>
);
}Try it
What the hook returns — live
All it gives you
- active
- { href, text } of the link at the caret
- possible
- Whether there is something to link
- set(address)
- Links the selection; false for what is not an address
- remove() · open()
- Unlink it; open it in another tab
Taking it apart
const { active, possible, set, remove, open } = useDocsLink();Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsLink } from '@rebodocs/react';
function LinkButton() {
const link = useDocsLink();
const ask = () => {
const address = window.prompt('Address', link.active?.href ?? 'https://');
if (address === null) return;
if (address === '') link.remove();
else if (!link.set(address)) window.alert('That is not an address.');
};
return (
<button
className="rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm aria-pressed:bg-blue-100 disabled:opacity-40"
aria-pressed={!!link.active}
disabled={!link.possible}
onClick={ask}
>
Link
</button>
);
}useDocsNotes()
WritingOpen the full demo →The notes of the document (Word’s comments), to show them your way.
Try it
What the hook returns — live
All it gives you
- notes
- Each { id, author, date, text, excerpt, color }
- active
- The id of the note the caret is in
- add(text)
- Puts one on the selection; gives its id
- setText(id, text) · setColor(id, color) · remove(id)
- Change one
- removeAll()
- Takes every note away, in one step to undo
- select(id)
- Selects its text and brings it into view
Taking it apart
const { notes, active, add, setText, setColor, remove, removeAll, select } = useDocsNotes();NOTE_COLORS is exported too. commands.setShowNotes(true) shows notes beside the page.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { NOTE_COLORS, useDocsNotes } from '@rebodocs/react';
function Notes() {
const notes = useDocsNotes();
return (
<div className="grid gap-2">
<button className="rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm" onClick={() => notes.add('Check this')}>
Note on the selection
</button>
{notes.notes.length > 0 && (
<button className="rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm text-red-700" onClick={() => notes.removeAll()}>
Delete all notes
</button>
)}
{notes.notes.map((note) => (
<article key={note.id} className="grid gap-1.5 rounded-md border border-neutral-200 p-2" style={{ borderLeft: `4px solid #${note.color}` }}>
<button className="truncate text-left text-xs text-neutral-600" onClick={() => notes.select(note.id)}>
“{note.excerpt}”
</button>
<textarea aria-label="Note" className="rounded border border-neutral-300 p-1 text-sm" value={note.text} onChange={(e) => notes.setText(note.id, e.target.value)} />
<div className="flex gap-1">
{NOTE_COLORS.map((color) => (
<button key={color} aria-label={`#${color}`} className="size-5 rounded-full" style={{ background: `#${color}` }} onClick={() => notes.setColor(note.id, color)} />
))}
<button className="ml-auto text-xs text-red-700" onClick={() => notes.remove(note.id)}>
Delete
</button>
</div>
</article>
))}
</div>
);
}useDocsVariables()
WritingOpen the full demo →The variables of a template — {{client}} in the text — with their formats and a preview of each value.
Try it
What the hook returns — live
All it gives you
- names · active
- Each variable once, and the one at the caret
- insert(name) · select(name)
- Put one at the caret; go to where one is
- fill(values)
- Fill them all, as one step to undo
- blocks
- The {{#name}} … {{/name}} blocks: each with its name and kind
- formats · uses
- By name: its formats, and how many times it is used
- setFormat(name, id, on, arg?)
- date, number, currency, upper, bold…
- preview(name, value)
- { text, bad }: how the value would come out
Taking it apart
const { names, active, insert, select, fill, blocks, formats, uses, setFormat, preview } = useDocsVariables();Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsVariables } from '@rebodocs/react';
import { useState } from 'react';
function Variables() {
const variables = useDocsVariables();
const [values, setValues] = useState<Record<string, string>>({});
return (
<form
className="grid gap-2"
onSubmit={(e) => {
e.preventDefault();
variables.fill(values);
}}
>
{variables.names.map((name) => {
const money = variables.formats[name]?.some((format) => format.id === 'currency') ?? false;
const { text, bad } = variables.preview(name, values[name] ?? '');
return (
<label key={name} className="grid gap-0.5 text-xs text-neutral-600">
{name}
<span className="flex gap-1">
<input
className="min-w-0 flex-1 rounded border border-neutral-300 px-1.5 py-0.5 text-sm text-black"
value={values[name] ?? ''}
onFocus={() => variables.select(name)}
onChange={(e) => setValues({ ...values, [name]: e.target.value })}
/>
<button type="button" className="rounded border border-neutral-300 px-1.5 aria-pressed:bg-blue-100" aria-pressed={money} onClick={() => variables.setFormat(name, 'currency', !money)}>
$
</button>
</span>
<small className={bad ? 'text-red-700' : ''}>{bad ? 'Not what its format is for' : text}</small>
</label>
);
})}
<button className="rounded-md bg-blue-700 px-2.5 py-1 text-sm text-white">Fill</button>
</form>
);
}useDocsStyles()
WritingOpen the full demo →The paragraph styles of the document — Normal, Title, Heading 1… — and the one of the selection.
Try it
What the hook returns — live
All it gives you
- styles
- Each { id, name }, the default first
- active
- The style of the selection; undefined when mixed
- set(id)
- Gives the paragraphs a style
Taking it apart
const { styles, active, set } = useDocsStyles();Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsStyles } from '@rebodocs/react';
function Style() {
const { styles, active, set } = useDocsStyles();
return (
<select aria-label="Style" className="rounded-md border border-neutral-300 bg-white px-2 py-1 text-sm" value={active ?? ''} onChange={(e) => set(e.target.value)}>
{active === undefined && <option value="">Mixed</option>}
{styles.map((style) => (
<option key={style.id} value={style.id}>
{style.name}
</option>
))}
</select>
);
}useDocsOutline()
WritingOpen the full demo →The title and the headings of the document, for a panel to move around in.
Try it
What the hook returns — live
All it gives you
- items
- Each { para, level, text }; level 0 is the title
- active
- Which one the caret is under, or -1
- goTo(item)
- Puts the caret there
- move(item, before?)
- Moves a heading with everything under it
Taking it apart
const { items, active, goTo, move } = useDocsOutline();commands.insertToc() and commands.updateToc() handle the table of contents.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsOutline } from '@rebodocs/react';
function Outline() {
const { items, active, goTo } = useDocsOutline();
return (
<nav className="grid">
{items.map((item, i) => (
<button
key={item.para}
aria-current={i === active}
className="truncate rounded px-1.5 py-1 text-left text-sm aria-[current=true]:bg-blue-100 aria-[current=true]:font-semibold"
style={{ paddingLeft: 6 + item.level * 12 }}
onClick={() => goTo(item)}
>
{item.text}
</button>
))}
</nav>
);
}useDocsPage()
PageOpen the full demo →The page: its size and margins, its sections, header and footer, its number, its notes at the end and its letterhead.
Try it
What the hook returns — live
All it gives you
- page · set(patch, everywhere?)
- Width, height and margins, in points
- sections · section
- How many, and which one is being edited
- ownHeaders · setOwnHeaders(on)
- A header and footer for this section alone
- numbering · setNumbering(n)
- { place, align, format }, or undefined
- firstPageDifferent · setFirstPageDifferent(on)
- Another header for the first page
- endnotesAt · setEndnotesAt(at)
- 'document' or 'sections': where the endnotes go
- noteNumbering · setNoteNumbering(kind, n)
- How the section numbers its footnotes and endnotes: { format, start, restart }, or undefined
- letterhead · setLetterhead(file, fit?)
- Whether there is one; set it from a PNG or JPG
- fitLetterheadMargins() · removeLetterhead() · letterheadFile()
- Margins that clear it; take it away; the picture it is, to download
Taking it apart
const { page, set, sections, section, ownHeaders, setOwnHeaders, numbering, setNumbering, firstPageDifferent, setFirstPageDifferent, endnotesAt, setEndnotesAt, noteNumbering, setNoteNumbering, letterhead, setLetterhead, fitLetterheadMargins, removeLetterhead, letterheadFile } = useDocsPage();Letter is 612 × 792 pt, A4 is 595.3 × 841.9 pt.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsPage } from '@rebodocs/react';
const CM = 72 / 2.54;
const button = 'rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm aria-pressed:bg-blue-100';
function PageSetup() {
const { page, set, numbering, setNumbering } = useDocsPage();
if (!page) return null;
return (
<div className="flex flex-wrap items-center gap-1.5">
<button className={button} onClick={() => set({ width: page.height, height: page.width })}>
Turn
</button>
<label className="text-sm text-neutral-600">
Left margin, cm{' '}
<input
type="number"
step="0.1"
className="w-16 rounded border border-neutral-300 px-1 py-0.5"
value={(page.marginLeft / CM).toFixed(1)}
onChange={(e) => set({ marginLeft: e.target.valueAsNumber * CM })}
/>
</label>
<button className={button} aria-pressed={!!numbering} onClick={() => setNumbering(numbering ? undefined : { place: 'footer', align: 'center', format: 'pageOfTotal' })}>
Page numbers
</button>
</div>
);
}useDocsSelectionBox()
InterfaceOpen the full demo →Where the selection is in the window, to put something of your own beside it. It follows scrolling and resizing.
Try it
What the hook returns — live
All it gives you
- top · left · width · height
- In pixels; undefined while there is none
Taking it apart
const box = useDocsSelectionBox();
if (!box) return null;
// put your popover at box.top - 44, box.leftonMouseDown={(e) => e.preventDefault()} on your bar keeps a press from taking the selection away.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocs, useDocsSelectionBox } from '@rebodocs/react';
function FloatingBar() {
const box = useDocsSelectionBox();
const { state, commands } = useDocs();
if (!box || state.collapsed) return null;
return (
<div className="fixed z-10 flex gap-1 rounded-lg bg-neutral-900 p-1 shadow-lg" style={{ top: box.top - 44, left: box.left }} onMouseDown={(e) => e.preventDefault()}>
<button className="rounded px-2 py-0.5 text-sm font-bold text-white hover:bg-white/15" onClick={() => commands.toggleMark('bold')}>
B
</button>
<button className="rounded px-2 py-0.5 text-sm text-white hover:bg-white/15" onClick={() => commands.copy()}>
Copy
</button>
</div>
);
}useDocsBubble()
InterfaceOpen the full demo →The bar beside the selection that the included interface has. For a document made with <DocsProvider bubble>; undefined without it.
Try it
What the hook returns — live
All it gives you
- open() · close() · toggle()
- Show it and hide it
- ask(kind)
- 'variable', 'note' or 'link'
Taking it apart
const bubble = useDocsBubble(); // undefined without bubble
bubble?.ask('note');It comes with a look, and is put in document.body: give it your colours with the --dx-ui-… variables there (see Styling).
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { useDocsBubble } from '@rebodocs/react';
const button = 'rounded-md border border-neutral-300 bg-white px-2.5 py-1 text-sm';
function Insert() {
const bubble = useDocsBubble();
return (
<div className="flex gap-1.5">
<button className={button} onClick={() => bubble?.ask('variable')}>
Variable
</button>
<button className={button} onClick={() => bubble?.ask('note')}>
Note
</button>
<button className={button} onClick={() => bubble?.ask('link')}>
Link
</button>
</div>
);
}
// Its colours, through variables on the body, where it is put:
// body { --dx-ui-bg: #323232; --dx-ui-ink: #eee; --dx-ui-line: #505050; --dx-ui-active: #4a4a4a; }useDocsResponsive(600)
InterfaceOpen the full demo →What a narrow window asks of an interface: below the width given, the pages fit the surface.
Try it
What the hook returns — live
All it gives you
- narrow
- true while the surface is under the width given
- keyboard
- Pixels the on-screen keyboard covers
Taking it apart
const { narrow, keyboard } = useDocsResponsive(600);Decide your layout with a media query, not with narrow: otherwise each change undoes the other.
Use it
The piece running above, as its file has it: it goes anywhere inside a DocsProvider.
import { DocsSurface, useDocsResponsive } from '@rebodocs/react';
import type { ReactNode } from 'react';
function Editor({ toolbar }: { toolbar: ReactNode }) {
const { keyboard } = useDocsResponsive(600);
return (
<div className="flex h-dvh flex-col" style={{ paddingBottom: keyboard }}>
{toolbar}
<DocsSurface className="min-h-0 flex-1" />
</div>
);
}Languages and fonts
Not hooks, but used beside them: the language of what the library writes, and the fonts there are. See languages and fonts.
setLocale(code)getLocale()onLocaleChange(fn)addLocale(code, texts)locales()messages(locale)t(key)plural(key, n)fontFamilies()addFont(source)addFonts(sources)onFontsChange(fn)createSpellChecker(options)Versions and assistants
With versions on DocsEditor, the side panel compares and goes back. To draw that panel yourself, or to open a DOCX as one more change of a shared room, use these; createAssistantChat puts Claude in a chat of your own, working on the document. See versions and AI assistants.
createVersionView(editor, versions)loadVersion(versions, id)compareDocs(before, after)createAssistantChat(editor, options)Without React
mountDocs (from @rebodocs/react/mount) puts the whole editor in an element and gives back a handle with destroy(). createDocs puts only the pages, with state(), commands, editor, subscribe(fn) and setKeys.