Footnotes and endnotes
Footnotes and endnotes apply to traditional, paginated documents. A footnote is laid out on the page that references it; an endnote is placed according to the document's endnote settings. This API does not support modern documents.
Plugin mode
Installation
pnpm add @univerjs-pro/docs-reference @univerjs-pro/docs-reference-uinpm install @univerjs-pro/docs-reference @univerjs-pro/docs-reference-uiyarn add @univerjs-pro/docs-reference @univerjs-pro/docs-reference-uibun add @univerjs-pro/docs-reference @univerjs-pro/docs-reference-uiUsage
Add these plugins to a Docs editor with a configured license, and load the UI styles and the locale that matches the editor.
import { UniverDocsReferencePlugin } from '@univerjs-pro/docs-reference'import { UniverDocsReferenceUIPlugin } from '@univerjs-pro/docs-reference-ui'import ReferenceLocale from '@univerjs-pro/docs-reference-ui/locale/en-US'import { LocaleType } from '@univerjs/core'import '@univerjs-pro/docs-reference/facade'import '@univerjs-pro/docs-reference-ui/lib/index.css'univerAPI.loadLocales(LocaleType.EN_US, ReferenceLocale)univer.registerPlugin(UniverDocsReferencePlugin)univer.registerPlugin(UniverDocsReferenceUIPlugin)Preset mode
Installation
pnpm add @univerjs/presets @univerjs/preset-docs-core @univerjs/preset-docs-drawing @univerjs/preset-docs-advancednpm install @univerjs/presets @univerjs/preset-docs-core @univerjs/preset-docs-drawing @univerjs/preset-docs-advancedyarn add @univerjs/presets @univerjs/preset-docs-core @univerjs/preset-docs-drawing @univerjs/preset-docs-advancedbun add @univerjs/presets @univerjs/preset-docs-core @univerjs/preset-docs-drawing @univerjs/preset-docs-advancedUsage
UniverDocsAdvancedPreset already includes both plugins. When you use this preset, keep its registration and do not add the plugins again.
Combine the core, drawing, and advanced presets, and merge their locale resources. The client license is configured as described in using a license.
import { UniverDocsAdvancedPreset } from '@univerjs/preset-docs-advanced'import AdvancedLocale from '@univerjs/preset-docs-advanced/locales/en-US'import { UniverDocsCorePreset } from '@univerjs/preset-docs-core'import CoreLocale from '@univerjs/preset-docs-core/locales/en-US'import { UniverDocsDrawingPreset } from '@univerjs/preset-docs-drawing'import DrawingLocale from '@univerjs/preset-docs-drawing/locales/en-US'import { createUniver, LocaleType, mergeLocales } from '@univerjs/presets'import '@univerjs/preset-docs-core/lib/index.css'import '@univerjs/preset-docs-drawing/lib/index.css'import '@univerjs/preset-docs-advanced/lib/index.css'const { univerAPI } = createUniver({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales(CoreLocale, DrawingLocale, AdvancedLocale), }, presets: [ UniverDocsCorePreset({ container: 'app' }), UniverDocsDrawingPreset(), UniverDocsAdvancedPreset(), ],})Preset configuration
UniverDocsCorePreset
containerstring | HTMLElementDefault:'app'The element to mount into, or its DOM ID.
Insert and manage notes
const document = univerAPI.getActiveDocument()if (document) { const noteId = document.insertFootnote(0) if (noteId) console.log(document.getParagraphs(noteId)) console.log(document.getFootnotes(), document.getEndnotes())}The offset is a UTF-16 position in the main body and counts structural tokens. Insertion returns null when the position is invalid, the note content is invalid, the caller lacks permission, or the document is modern. Otherwise it returns a stable note ID. The reference and the note content belong to the same undo step and the same collaboration mutation.
Read notes with getFootnotes() / getEndnotes() and remove them with deleteFootnote(noteId) / deleteEndnote(noteId). setFootnoteSettings() and setEndnoteSettings() control numbering and placement, and passing null clears any explicit settings. Keep the returned note ID for addressing content, because the displayed numbers can change after pagination.
How is this guide?