Skip to content

buttondown/tiptap-footnotes

Repository files navigation

tiptap-footnotes

A footnotes extension for Tiptap

Open in StackBlitz

Getting Started

Installation

npm install tiptap-footnotes

This extension requires the @tiptap/extension-list-item, @tiptap/extension-ordered-list, and the @tiptap/pm extensions, so you need to install them as well:

npm install @tiptap/extension-list-item @tiptap/extension-ordered-list @tiptap/pm

Usage

This package is separated into 3 main extensions:

  • Footnotes: The footnotes ordered list extension
  • Footnote: The footnote list item extension
  • FootnoteReference: the footnote reference extension

Typically, the footnotes should be placed at the bottom of the document, so you should adjust the topNode node (i.e. Document) to have the footnotes placed at the end (as shown below):

import { useEditor, EditorContent } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import { Footnotes, FootnoteReference, Footnote } from "tiptap-footnotes";
import Document from "@tiptap/extension-document";

const Editor = () => {
  const editor = useEditor({
    extensions: [
      StarterKit.configure({
        document: false,
      }),
      Document.extend({
        content: "block+ footnotes?",
      }),
      Footnotes,
      Footnote,
      FootnoteReference,
    ],
    content: "Hello world",
  });

  return <EditorContent editor={editor} />;
};

export default Editor;

If you want the footnotes to look like the example, you can add this CSS to your app:

ol.footnotes {
  margin-top: 20px;
  padding: 20px 0;
  list-style-type: decimal;
  padding-left: 20px;
}

ol.footnotes:has(li) {
  border-top: 1px solid black;
}

About

A footnotes extension for Tiptap

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy