What is @tiptap/extension-underline?
@tiptap/extension-underline is an extension for the Tiptap editor that allows you to add underline formatting to your text. It integrates seamlessly with Tiptap's modular architecture, enabling you to easily add underline functionality to your rich text editor.
What are @tiptap/extension-underline's main functionalities?
Add Underline Extension
This code demonstrates how to add the Underline extension to a Tiptap editor instance. The Underline extension is imported and included in the editor's extensions array.
import Underline from '@tiptap/extension-underline';
import { Editor } from '@tiptap/core';
const editor = new Editor({
extensions: [
Underline,
],
content: '<p>Hello World!</p>',
});
Toggle Underline
This code shows how to programmatically toggle the underline formatting on the selected text in the editor. The `toggleUnderline` method is chained with other editor commands.
editor.chain().focus().toggleUnderline().run();
Check Underline State
This code snippet checks if the current selection in the editor is underlined. The `isActive` method returns a boolean indicating the underline state.
const isUnderlined = editor.isActive('underline');
Other packages similar to @tiptap/extension-underline
prosemirror-schema-basic
The `prosemirror-schema-basic` package provides a basic schema for ProseMirror, including underline functionality. It is more low-level compared to Tiptap and requires more manual setup.
draft-js
Draft.js is a rich text editor framework for React. It includes built-in support for underline formatting, but it is more complex to integrate compared to Tiptap's modular approach.
quill
Quill is a powerful, free, open-source WYSIWYG editor with built-in support for underline formatting. It offers a more comprehensive out-of-the-box experience but is less modular than Tiptap.
@tiptap/extension-underline
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.