---
title: "段落扩展"
description: "在 Tiptap 中使用段落扩展，以添加对 HTML 标签的段落支持。请在我们的文档中了解更多内容！"
canonical_url: "https://tiptap.zhcndoc.com/editor/extensions/nodes/paragraph"
---

# 段落扩展

在 Tiptap 中使用段落扩展，以添加对 HTML 标签的段落支持。请在我们的文档中了解更多内容！

是的，模式非常严格。如果没有这个扩展，您在编辑器中甚至无法使用段落。

> **重大变化:**
>
> Tiptap v1 尝试将该节点隐藏，但它一直存在。从现在开始，您必须显式导入它（或使用 [StarterKit](https://tiptap.zhcndoc.com/editor/extensions/functionality/starterkit.md)）。

> **Interactive demo:** [Paragraph](https://embed.tiptap.dev/preview/Nodes/Paragraph)

## 安装

```bash
npm install @tiptap/extension-paragraph
```

## 设置

### HTMLAttributes

应添加到渲染的 HTML 标签的自定义 HTML 属性。

```js
Paragraph.configure({
  HTMLAttributes: {
    class: 'my-custom-class',
  },
})
```

## 命令

### setParagraph()

将所有选定的节点转换为段落。

```js
editor.commands.setParagraph()
```

## 快捷键

| 命令             | Windows/Linux     | macOS         |
| -------------- | ----------------- | ------------- |
| setParagraph() | Control + Alt + 0 | Cmd + Alt + 0 |

## 源代码

[packages/extension-paragraph/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-paragraph/)
