2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
2021-10-16 04:48:57 +08:00
|
|
|
|
description: Mom, look! I wrote a paragraph on the Internet.
|
2021-10-15 03:20:21 +08:00
|
|
|
|
icon: paragraph
|
2021-10-14 06:13:50 +08:00
|
|
|
|
---
|
|
|
|
|
|
2020-09-02 21:20:35 +08:00
|
|
|
|
# Paragraph
|
2021-01-25 17:35:52 +08:00
|
|
|
|
[![Version](https://img.shields.io/npm/v/@tiptap/extension-paragraph.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-paragraph)
|
|
|
|
|
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-paragraph.svg)](https://npmcharts.com/compare/@tiptap/extension-paragraph?minimal=true)
|
|
|
|
|
|
2020-09-09 22:16:57 +08:00
|
|
|
|
Yes, the schema is very strict. Without this extension you won’t even be able to use paragraphs in the editor.
|
2020-09-09 22:12:39 +08:00
|
|
|
|
|
2020-09-23 18:03:03 +08:00
|
|
|
|
:::warning Breaking Change from 1.x → 2.x
|
2021-05-07 00:41:22 +08:00
|
|
|
|
tiptap 1 tried to hide that node from you, but it has always been there. You have to explicitly import it from now on (or use `StarterKit`).
|
2020-09-23 18:03:03 +08:00
|
|
|
|
:::
|
|
|
|
|
|
2020-09-23 15:52:04 +08:00
|
|
|
|
## Installation
|
|
|
|
|
```bash
|
2020-10-30 21:24:16 +08:00
|
|
|
|
# with npm
|
2020-09-23 15:52:04 +08:00
|
|
|
|
npm install @tiptap/extension-paragraph
|
|
|
|
|
|
2020-10-30 21:24:16 +08:00
|
|
|
|
# with Yarn
|
2020-09-23 15:52:04 +08:00
|
|
|
|
yarn add @tiptap/extension-paragraph
|
|
|
|
|
```
|
|
|
|
|
|
2020-09-23 18:03:03 +08:00
|
|
|
|
## Settings
|
2021-10-02 05:27:39 +08:00
|
|
|
|
|
|
|
|
|
### HTMLAttributes
|
|
|
|
|
Custom HTML attributes that should be added to the rendered HTML tag.
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
Paragraph.configure({
|
|
|
|
|
HTMLAttributes: {
|
|
|
|
|
class: 'my-custom-class',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
```
|
2020-09-09 22:12:39 +08:00
|
|
|
|
|
|
|
|
|
## Commands
|
2021-10-02 06:14:44 +08:00
|
|
|
|
|
|
|
|
|
### setParagraph()
|
|
|
|
|
Transforms all selected nodes to paragraphs.
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
editor.commands.setParagraph()
|
|
|
|
|
```
|
2020-09-09 22:12:39 +08:00
|
|
|
|
|
2020-09-10 17:24:33 +08:00
|
|
|
|
## Keyboard shortcuts
|
2021-10-02 04:57:27 +08:00
|
|
|
|
| Command | Windows/Linux | macOS |
|
|
|
|
|
| -------------- | ----------------------------- | ------------------------- |
|
|
|
|
|
| setParagraph() | `Control` `Alt` `0` | `Cmd` `Alt` `0` |
|
2020-09-09 22:12:39 +08:00
|
|
|
|
|
2020-09-21 22:59:28 +08:00
|
|
|
|
## Source code
|
2021-04-21 21:31:11 +08:00
|
|
|
|
[packages/extension-paragraph/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-paragraph/)
|
2020-09-09 22:12:39 +08:00
|
|
|
|
|
|
|
|
|
## Usage
|
2021-10-19 00:01:47 +08:00
|
|
|
|
https://embed.tiptap.dev/preview/Nodes/Paragraph
|