What is @tiptap/extension-history?
@tiptap/extension-history is an extension for the Tiptap editor that provides undo and redo functionality. It allows users to revert changes or reapply them, enhancing the editing experience by providing a way to navigate through the history of changes made to the document.
What are @tiptap/extension-history's main functionalities?
Undo
This feature allows users to undo the last action performed in the editor. The configuration options allow setting the maximum number of history events and the delay for creating a new group of actions.
import { Editor } from '@tiptap/core';
import History from '@tiptap/extension-history';
const editor = new Editor({
extensions: [
History.configure({
depth: 100, // Maximum number of history events
newGroupDelay: 500 // Time in ms to create a new group
})
]
});
// To undo the last action
editor.commands.undo();
Redo
This feature allows users to redo the last undone action in the editor. Similar to the undo feature, it can be configured with options for the maximum number of history events and the delay for creating a new group of actions.
import { Editor } from '@tiptap/core';
import History from '@tiptap/extension-history';
const editor = new Editor({
extensions: [
History.configure({
depth: 100, // Maximum number of history events
newGroupDelay: 500 // Time in ms to create a new group
})
]
});
// To redo the last undone action
editor.commands.redo();
Other packages similar to @tiptap/extension-history
prosemirror-history
prosemirror-history is a package for ProseMirror that provides undo and redo functionality. It is similar to @tiptap/extension-history as Tiptap is built on top of ProseMirror. The main difference is that @tiptap/extension-history is specifically designed to integrate seamlessly with the Tiptap editor, while prosemirror-history is a more general solution for any ProseMirror-based editor.
slate-history
slate-history is an extension for the Slate editor that provides undo and redo functionality. It is similar to @tiptap/extension-history in that it allows users to navigate through the history of changes made to the document. However, it is designed specifically for the Slate editor, which has a different architecture and API compared to Tiptap.
@tiptap/extension-history
Introduction
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Official Documentation
Documentation can be found on the Tiptap website.
License
Tiptap is open sourced software licensed under the MIT license.