Skip to the content
v1.0.1-beta.17

Footnotes

Premium add-on. This page covers a premium add-on, included in Scriviamo Pro and Pro + Collaboration. See pricing

The footnotes add-on adds footnotes: numbered references in the text, with their notes in a list at the end of the document.

import "scriviamo/dist/addons/scriviamo.footnotes.js"     // and scriviamo.footnotes.css

Using footnotes

While editing text, the Insert Footnote tool (also Ctrl+Alt+N, or Command+Option+N on a Mac) puts a reference at the caret, adds an empty note to the footnotes block at the end of the document, creating the block the first time, and moves the caret into the note. Inserting a footnote is one undo step.

  • Numbers follow the references' order in the document, and change as references are added, moved or deleted. The notes are listed in the same order.
  • Clicking a reference goes to its note and starts editing it; hovering over one shows the note's text.
  • Backspace after a reference, or Delete before it, removes the whole reference.
  • A note whose reference was deleted stays in the block, struck through and marked "Not referenced in the text", until it is removed with its × button, so undoing the deletion brings it straight back. Unreferenced notes are left out of exports.
  • Shift-click a reference to put the caret beside it instead.
  • ↩ beside a note goes back to its reference.
  • Pasting or copying a reference refers to the same note again, with the same number.

In code

import {Footnotes, FootnotesNode} from "scriviamo/dist/addons/scriviamo.footnotes.js"

editor.beginEditing(paragraph, 12)
let footnote = Footnotes.insert(editor, "Smith, 2024, p. 12")   // the Footnote, or null when no text is being edited
MemberDoes
Footnotes.insert(editor, text)Inserts a footnote at the caret, as the tool does
Footnotes.references(editor)Every reference, in document order: {node, host, start, length, id}
Footnotes.numbers(editor)Each referenced footnote's number, by id
Footnotes.block(editor)The footnotes block, or null
Footnotes.reveal(editor, id)Scrolls to a footnote's reference
Footnotes.renumber(editor)Brings the numbers up to date now; the add-on does this after every change

The block is a FootnotesNode, whose notes are Footnotes, each with an id and its text, a RichText. orderedNotes() lists them as shown, with their numbers (0 for unreferenced notes), and removeNote(id) removes one.

A reference is a text tag (see Comments and suggestions) from the "footnote" provider, carrying the note's id, whose text is its number. Numbers are worked out from the document, so renumbering isn't an undo step and isn't sent to collaborators: each editor numbers the same document the same way.

Import and export

FormatReferencesNotes
JSONTagged text in the paragraph{"type": "footnotes", "notes": [{"id", "content"}]}
HTML<sup class="footnote-ref"><a href="#fn-…" role="doc-noteref">1</a></sup><section class="footnotes" role="doc-endnotes"> with a list item per note, each with a link back
Markdown[^1][^1]: The note, as GitHub, Pandoc and most Markdown tools read them
Plain textThe number"1. The note" lines

These are read back, too: Markdown footnotes with any labels, such as [^source], and the HTML the add-on writes. Without the add-on, Markdown references stay as tagged text and the notes as a list, so nothing is lost.