Whiteboard extensions
WhiteboardKit brings every extension of the board. Import it, and each of these extensions, from @tiptap-pro/extension-whiteboard. BoardCollaboration comes from its own entry.
Editor comes from @tiptap/core, and UndoRedoOptions from @tiptap/extensions.
WhiteboardKit
The whiteboard: the board and its shapes, their text, the selection, the tools, the styles for new shapes, and undo. It brings its own document node and text extensions too, so don't add Document or StarterKit to its editor. Your app provides the stage around the board, see attachStage.
import { Editor } from '@tiptap/core'
import { WhiteboardKit } from '@tiptap-pro/extension-whiteboard'
const editor = new Editor({ element: viewport, extensions: [WhiteboardKit] })Options (WhiteboardKitOptions)
undoRedo(Partial<UndoRedoOptions> | false): The options of Tiptap'sUndoRedo. Set tofalsewhen collaboration handles undo.undoBoardandredoBoardthen use it. Default:{}.shapeElementAttributes(ShapeElementAttributes | null): Extra attributes for the element of every shape, from the shape's node. Values become strings, andnullorundefinedleaves an attribute out. Default:null.docs(BoardDocs | null): Where the documents of doc frames live. Without it, doc frames show no document. Default:null. See Doc frames.colors(readonly ShapeColor[]): The names of the board's colors. Text colors and highlights from pasted HTML keep only these. Default:shapeColors. See Colors.toolKeys(ToolKeys | false): Keys that replace the default keys of their tools, seetoolKeys.nullleaves a tool without a key, andfalseturns all tool keys off. Default:toolKeys.
import { getSuggestionHTMLAttributes } from '@tiptap-pro/extension-tracked-changes'
import { shapeColors, WhiteboardKit } from '@tiptap-pro/extension-whiteboard'
WhiteboardKit.configure({
undoRedo: { depth: 50 },
// Lets CSS show the shapes that a suggestion changes
shapeElementAttributes: getSuggestionHTMLAttributes,
colors: [...shapeColors, 'brand'],
toolKeys: { pen: 'b', eraser: null },
})Included extensions
| Extension | Name | Description |
|---|---|---|
WhiteboardDocument | doc | The top node of a board's editor, which holds the board and nothing else |
Board | board | The board, which holds every shape, with the commands that change shapes |
StickyNote | stickyNote | A sticky note with text |
Geo | geo | A geometric shape with text, like a rectangle or an ellipse |
FreeText | freeText | Text without a shape around it |
Freehand | freehand | A line drawn with the pen |
DocFrame | docFrame | A frame on the board that shows a document of its own, in an editor of its own |
Arrow | arrow | An arrow between shapes or free points |
BoardTextColor | textColor | Colors parts of a shape's text with the name of a board color |
BoardHighlight | highlight | Highlights parts of a shape's text in a board color. Highlights without a board color are yellow |
BoardLink | link | Links in shape text, which open in a new tab with a click with Control, or Cmd on macOS |
BoardTaskItem | taskItem | A task item whose checkbox also toggles while no text is edited |
KeepSelectionInShape | keepSelectionInShape | Stops selections, arrow keys and jumps from leaving the current shape |
ShapeSelection | shapeSelection | Selects shapes by id |
RemoteSelections | remoteSelections | Shows the shapes that other users select |
BoardHistory | boardHistory | Undo and redo for the board, which select the shapes that they change |
BoardTools | boardTools | Keeps the active tool outside of the document, like the selection |
ShapeStyle | shapeStyle | Keeps the styles for new shapes outside of the document |
The kit also adds these Tiptap extensions: Paragraph, Text, Bold, Italic, Strike, Code, BulletList, OrderedList, ListItem, TaskList and ListKeymap, and UndoRedo unless undoRedo is false. Task lists can nest.
See Commands for the commands of each extension.
Board
The board, which holds every shape, with the commands that change shapes. It adds the CSS that the board needs to the page, unless the editor's injectCSS is false. Configure it through WhiteboardKit, which passes on shapeElementAttributes and docs.
Storage (BoardStorage)
Available at editor.storage.board.
shapeElementAttributes(ShapeElementAttributes | null): TheshapeElementAttributesoption, for the node views of the shapes.docs(BoardDocs | null): Thedocsoption, for doc frames and their copies.docEditors(Map<string, Editor>): The editors of the documents that doc frames show, by document id.
To read the document editors, prefer getDocEditors. It returns none once the board's editor is destroyed.
BoardCollaboration
Collaboration that also syncs a first change that leaves the document empty, like deleting the last shape. Plain Collaboration drops that change when the editor starts on content from Yjs. Use it instead of Collaboration, and turn off the kit's own undo.
import { Editor } from '@tiptap/core'
import { WhiteboardKit } from '@tiptap-pro/extension-whiteboard'
import { BoardCollaboration } from '@tiptap-pro/extension-whiteboard/collaboration'
import * as Y from 'yjs'
const editor = new Editor({
element: viewport,
extensions: [
WhiteboardKit.configure({ undoRedo: false }),
BoardCollaboration.configure({ document: new Y.Doc() }),
],
})It comes from @tiptap-pro/extension-whiteboard/collaboration and takes the options of Collaboration. It needs the optional peer dependencies @tiptap/extension-collaboration, @tiptap/y-tiptap and yjs, and y-protocols, which @tiptap/y-tiptap needs.