tiptap/docs/api/nodes/hard-break.md

60 lines
1.6 KiB
Markdown
Raw Normal View History

---
2021-10-14 17:56:18 +08:00
description: Sometimes we all need a break, even if its just a line break.
2021-10-15 03:20:21 +08:00
icon: text-wrap
---
2020-08-20 21:33:16 +08:00
# HardBreak
2021-01-25 17:35:52 +08:00
[![Version](https://img.shields.io/npm/v/@tiptap/extension-hard-break.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-hard-break)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-hard-break.svg)](https://npmcharts.com/compare/@tiptap/extension-hard-break?minimal=true)
The HardBreak extensions adds support for the `<br>` HTML tag, which forces a line break.
2020-08-20 21:33:16 +08:00
## Installation
```bash
npm install @tiptap/extension-hard-break
```
## Settings
### HTMLAttributes
Custom HTML attributes that should be added to the rendered HTML tag.
```js
HardBreak.configure({
HTMLAttributes: {
class: 'my-custom-class',
},
})
```
### keepMarks
Decides whether to keep marks after a line break. Based on the `keepOnSplit` option for marks.
Default: `true`
```js
HardBreak.configure({
keepMarks: false,
})
```
2020-09-10 17:52:20 +08:00
## Commands
2021-10-02 06:14:44 +08:00
### setHardBreak()
Add a line break.
```js
editor.commands.setHardBreak()
2021-10-02 06:14:44 +08:00
```
## Keyboard shortcuts
| Command | Windows/Linux | macOS |
| ------------ | ---------------------------------------------- | ------------------------------------------ |
| setHardBreak | `Shift`&nbsp;`Enter`<br>`Control`&nbsp;`Enter` | `Shift`&nbsp;`Enter`<br>`Cmd`&nbsp;`Enter` |
2020-09-21 22:59:28 +08:00
## Source code
2021-04-21 21:31:11 +08:00
[packages/extension-hard-break/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-hard-break/)
## Usage
2021-10-19 00:01:47 +08:00
https://embed.tiptap.dev/preview/Nodes/HardBreak