46 lines
2.0 KiB
Markdown
46 lines
2.0 KiB
Markdown
# TextAlign
|
|
[](https://www.npmjs.com/package/@tiptap/extension-text-align)
|
|
[](https://npmcharts.com/compare/@tiptap/extension-text-align?minimal=true)
|
|
|
|
This extension adds a text align attribute to a specified list of nodes. The attribute is used to align the text.
|
|
|
|
## Installation
|
|
```bash
|
|
# with npm
|
|
npm install @tiptap/extension-text-align
|
|
|
|
# with Yarn
|
|
yarn add @tiptap/extension-text-align
|
|
```
|
|
|
|
## Settings
|
|
| Option | Type | Default | Description |
|
|
| ---------------- | -------- | ---------------------------------------- | -------------------------------------------------------------------- |
|
|
| types | `Array` | `['heading', 'paragraph']` | A list of nodes where the text align attribute should be applied to. |
|
|
| alignments | `Array` | `['left', 'center', 'right', 'justify']` | A list of available options for the text align attribute. |
|
|
| defaultAlignment | `String` | `'left'` | The default text align. |
|
|
|
|
## Commands
|
|
| Command | Parameters | Description |
|
|
| --------- | ---------- | ------------------------------------------ |
|
|
| textAlign | alignment | Set the text align to the specified value. |
|
|
|
|
## Keyboard shortcuts
|
|
### Windows/Linux
|
|
* `Ctrl` `Shift` `L` Left
|
|
* `Ctrl` `Shift` `E` Center
|
|
* `Ctrl` `Shift` `R` Right
|
|
* `Ctrl` `Shift` `J` Justify
|
|
|
|
### macOS
|
|
* `Cmd` `Shift` `L` Left
|
|
* `Cmd` `Shift` `E` Center
|
|
* `Cmd` `Shift` `R` Right
|
|
* `Cmd` `Shift` `J` Justify
|
|
|
|
## Source code
|
|
[packages/extension-text-align/](https://github.com/ueberdosis/tiptap-next/blob/main/packages/extension-text-align/)
|
|
|
|
## Usage
|
|
<demo name="Extensions/TextAlign" highlight="29" />
|