2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
2021-10-14 17:56:18 +08:00
|
|
|
|
description: Sometimes we all need a break, even if it’s just a line break.
|
2021-10-15 03:20:21 +08:00
|
|
|
|
icon: text-wrap
|
2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
|
|
|
|
|
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)
|
|
|
|
|
|
2020-09-10 17:35:56 +08:00
|
|
|
|
The HardBreak extensions adds support for the `<br>` HTML tag, which forces a line break.
|
2020-08-20 21:33:16 +08:00
|
|
|
|
|
2020-09-23 15:52:04 +08:00
|
|
|
|
## Installation
|
|
|
|
|
```bash
|
|
|
|
|
npm install @tiptap/extension-hard-break
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-23 15:34:47 +08:00
|
|
|
|
## Settings
|
2021-10-02 07:20:09 +08:00
|
|
|
|
|
|
|
|
|
### 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,
|
|
|
|
|
})
|
|
|
|
|
```
|
2021-09-23 15:34:47 +08:00
|
|
|
|
|
2020-09-10 17:52:20 +08:00
|
|
|
|
## Commands
|
2021-10-02 06:14:44 +08:00
|
|
|
|
|
|
|
|
|
### setHardBreak()
|
|
|
|
|
Add a line break.
|
|
|
|
|
|
|
|
|
|
```js
|
2021-10-07 19:09:54 +08:00
|
|
|
|
editor.commands.setHardBreak()
|
2021-10-02 06:14:44 +08:00
|
|
|
|
```
|
2020-09-10 17:35:56 +08:00
|
|
|
|
|
2020-09-10 17:24:33 +08:00
|
|
|
|
## Keyboard shortcuts
|
2021-10-02 04:57:27 +08:00
|
|
|
|
| Command | Windows/Linux | macOS |
|
|
|
|
|
| ------------ | ---------------------------------------------- | ------------------------------------------ |
|
|
|
|
|
| setHardBreak | `Shift` `Enter`<br>`Control` `Enter` | `Shift` `Enter`<br>`Cmd` `Enter` |
|
2020-09-10 17:35:56 +08:00
|
|
|
|
|
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/)
|
2020-09-10 17:35:56 +08:00
|
|
|
|
|
|
|
|
|
## Usage
|
2021-10-19 00:01:47 +08:00
|
|
|
|
https://embed.tiptap.dev/preview/Nodes/HardBreak
|