FeaturesTypography
Text Alignment
Control horizontal text alignment with `setTextAlign`.
Type: Functionality
Text Alignment controls how text is horizontally positioned within block elements. Supports left, center, right, and justify alignments.
Demo
Installation
import { createTextAlign } from "@arkpad/extension-alignment";Commands
The extension registers a highly flexible main alignment command along with convenience commands for every specific alignment:
// Main alignment command (accepts string or configuration object)
editor.runCommand("setTextAlign", "center");
editor.runCommand("setTextAlign", { align: "right" });
// Convenience alignment commands
editor.runCommand("setTextAlignLeft");
editor.runCommand("setTextAlignCenter");
editor.runCommand("setTextAlignRight");
editor.runCommand("setTextAlignJustify");Chaining Commands
You can chain commands to set alignment and immediately focus the editor:
editor.chain().focus().setTextAlignCenter().run();Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Mod-Shift-l | Align Left |
Mod-Shift-e | Align Center |
Mod-Shift-r | Align Right |
Active State
Use the active API state with the alignment attribute to check active positioning:
const isCenter = editor.isActive("textAlign", { align: "center" });Configuration
The alignment extension behaves as a Notion-style, modern block tool. By default, alignment settings are automatically suppressed inside lists to maintain high layout readability and visual structure.