What is @tiptap/extension-text-align?
@tiptap/extension-text-align is an extension for the Tiptap editor that allows you to align text within your editor. It provides functionalities to align text to the left, center, right, or justify it. This extension is useful for creating rich text editors where text alignment is a necessary feature.
What are @tiptap/extension-text-align's main functionalities?
Align Text Left
This feature allows you to align text to the left. The code sample demonstrates how to configure the TextAlign extension to apply to headings and paragraphs, and then align the text to the left.
import { TextAlign } from '@tiptap/extension-text-align';
const editor = new Editor({
extensions: [
TextAlign.configure({
types: ['heading', 'paragraph'],
}),
],
});
editor.chain().focus().setTextAlign('left').run();
Align Text Center
This feature allows you to align text to the center. The code sample demonstrates how to configure the TextAlign extension to apply to headings and paragraphs, and then align the text to the center.
import { TextAlign } from '@tiptap/extension-text-align';
const editor = new Editor({
extensions: [
TextAlign.configure({
types: ['heading', 'paragraph'],
}),
],
});
editor.chain().focus().setTextAlign('center').run();
Align Text Right
This feature allows you to align text to the right. The code sample demonstrates how to configure the TextAlign extension to apply to headings and paragraphs, and then align the text to the right.
import { TextAlign } from '@tiptap/extension-text-align';
const editor = new Editor({
extensions: [
TextAlign.configure({
types: ['heading', 'paragraph'],
}),
],
});
editor.chain().focus().setTextAlign('right').run();
Justify Text
This feature allows you to justify text. The code sample demonstrates how to configure the TextAlign extension to apply to headings and paragraphs, and then justify the text.
import { TextAlign } from '@tiptap/extension-text-align';
const editor = new Editor({
extensions: [
TextAlign.configure({
types: ['heading', 'paragraph'],
}),
],
});
editor.chain().focus().setTextAlign('justify').run();
Other packages similar to @tiptap/extension-text-align
quill
Quill is a powerful, free, open-source WYSIWYG editor with a rich API. It provides text alignment functionalities similar to @tiptap/extension-text-align, but it is a standalone editor rather than an extension.
draft-js
Draft.js is a framework for building rich text editors in React. It offers text alignment features through its API, similar to @tiptap/extension-text-align, but it requires more setup and configuration.
slate
Slate is a completely customizable framework for building rich text editors. It provides text alignment capabilities similar to @tiptap/extension-text-align, but it is more flexible and requires more manual configuration.
@tiptap/extension-text-align
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.