tiptap/docs/api/nodes.md
Philipp Kühn 569aa15c4f Merge branch 'main' of https://github.com/ueberdosis/tiptap into docs/remove-gridsome
# Conflicts:
#	docs/experiments/collaboration-annotation.md
#	docs/experiments/global-drag-handle.md
2021-09-17 23:45:04 +02:00

5.1 KiB
Raw Blame History

tableOfContents
true

Nodes

Introduction

If you think of the document as a tree, then nodes are just a type of content in that tree. Examples of nodes are paragraphs, headings, or code blocks. But nodes dont have to be blocks. They can also be rendered inline with the text, for example for @mentions.

List of supported nodes

Title StarterKit (view) Source Code
Blockquote Included GitHub
BulletList Included GitHub
CodeBlock Included GitHub
Document Included GitHub
Emoji GitHub
HardBreak Included GitHub
Hashtag GitHub
Heading Included GitHub
HorizontalRule Included GitHub
Image GitHub
ListItem Included GitHub
Mention Included GitHub
OrderedList Included GitHub
Paragraph Included GitHub
Table GitHub
TableRow GitHub
TableCell GitHub
TaskList GitHub
TaskItem GitHub
Text Included GitHub

Create a new node

Youre free to create your own nodes for tiptap. Here is the boilerplate code thats need to create and register your own node:

import { Node } from '@tiptap/core'

const CustomNode = Node.create({
  // Your code here
})

const editor = new Editor({
  extensions: [
    // Register your custom node with the editor.
    CustomNode,
    // … and dont forget all other extensions.
    Document,
    Paragraph,
    Text,
    // …
  ],
})

Learn more about custom extensions in our guide.