Control paragraph and heading alignment for professional document layouts.
Perfect Word import/export compatibility for all alignment options.
OOXML Structure
<w:p>
<w:pPr>
<w:jc w:val="center"/>
</w:pPr>
<w:r>
<w:t>Centered text</w:t>
</w:r>
</w:p>
Use case
- Titles & Headings - Center important headings for emphasis
- Quotes - Right-align attributions or center block quotes
- Formal Documents - Justify body text for professional appearance
- Letters - Right-align dates and signatures
- Poetry - Center verses for artistic presentation
Options
Configure the extension behavior:
alignments
Array<string>
default:"['left','center','right','justify']"
Available alignment options
Commands
setTextAlign
Set text alignment on the current paragraph.
Example:
editor.commands.setTextAlign('center')
editor.commands.setTextAlign('justify')
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';
const superdoc = new SuperDoc({
selector: '#editor',
document: yourFile,
onReady: (superdoc) => {
const editor = superdoc.activeEditor;
editor.commands.setTextAlign('center')
editor.commands.setTextAlign('justify')
},
});
Parameters:
Alignment value (left, center, right, justify)
unsetTextAlign
Remove text alignment (reset to default)
Resets alignment to the default value
Example:
editor.commands.unsetTextAlign()
import { SuperDoc } from 'superdoc';
import 'superdoc/style.css';
const superdoc = new SuperDoc({
selector: '#editor',
document: yourFile,
onReady: (superdoc) => {
const editor = superdoc.activeEditor;
editor.commands.unsetTextAlign()
},
});
Keyboard shortcuts
| Command | Shortcut | Description |
|---|
| setTextAlign(‘left’)() | ⌘/Ctrl-Shift-l | Align text left |
| setTextAlign(‘center’)() | ⌘/Ctrl-Shift-e | Align text center |
| setTextAlign(‘right’)() | ⌘/Ctrl-Shift-r | Align text right |
| setTextAlign(‘justify’)() | ⌘/Ctrl-Shift-j | Justify text |
Source code