# createBlockEditorPreset · Block 内容预设

组合 Block 的内容能力并返回扩展数组，供独立 Core 或自定义 Block 产品使用。它本身不挂载 HTML View；子项未设置时使用预设装配，false 才关闭。

组合 Block 的内容能力并返回扩展数组，供独立 Core 或自定义 Block 产品使用。它本身不挂载 HTML View；子项未设置时使用预设装配，false 才关闭。

`@quirekit/block-editor` · **AGPL-3.0-only**

## 编辑器适用范围
层次：**Block 产品适配**
| 编辑器 | 状态 | 所需装配与边界 |
| --- | --- | --- |
| Classic | 未支持 | 该入口面向 Block 连续流，不接入 Classic 分页产品。需要共享语义时选择相应 Word 或通用能力及 Classic 装配。 |
| Block | 直接支持 | createBlockEditor 的 preset 接受配置对象或 false，并在内部调用此函数；独立 Core 才直接展开返回的扩展数组，仍需自行注册 View。 |

“直接支持”指已有上述产品装配；具体交互、宿主服务和格式支持仍有各自条件。[状态与接入规则](/plugins/compatibility)。许可独立显示。

## 接入

```sh
pnpm add @quirekit/block-editor@alpha
```

此入口导出或返回扩展数组。把数组展开合并到 Core 的 `extensions`，不要把整个数组当作一个扩展，也不要把它当作 Classic 产品 preset 对象。

```ts
import { createBlockEditorPreset } from '@quirekit/block-editor'

const extensions = createBlockEditorPreset({ characterCount: { limit: 5000 } })
```

安装时按包声明选择兼容版本，外部可用版本以分发源为准。本站使用工作区 Alpha；许可标签来自入口所属包，使用条件见[支持与许可](/support)。

## 按编辑器接入

以下片段沿用已挂载的宿主元素 `element`，宿主负责容器尺寸与保存；退出页面时调用 `instance.destroy()`。已有预设装配的能力不要再重复追加；需要宿主端口的入口应先完成下方配置。

### Classic

该入口面向 Block 连续流，不接入 Classic 分页产品。需要共享语义时选择相应 Word 或通用能力及 Classic 装配。

### Block

createBlockEditor 的 preset 接受配置对象或 false，并在内部调用此函数；独立 Core 才直接展开返回的扩展数组，仍需自行注册 View。

```ts
import { createBlockEditor } from '@quirekit/block-editor'
import '@quirekit/block-editor/styles.css'

const instance = createBlockEditor({
  element,
  content: { type: 'doc', content: [{ type: 'paragraph' }] },
})
```

## 配置

字段传入创建函数的 options。标为“必填”的端口由宿主提供；undefined 表示未显式配置，下面会说明创建层的回退。

### richContent

配置 BlockRichContent 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<BlockRichContentOptions>`

默认：`{}`

子扩展的具体选项见 [BlockRichContent](/plugins/reference/block-rich-content)。是否可以设为 false，以本字段类型为准。

### bodyContent

脚注、定义列表、日期与表情这组正文能力（BlockFootnotes、BlockDefinitions、BlockInlineContent）。设为 false 时一并关闭。

类型：`false`

默认：`undefined`

### math

配置 BlockMath 子扩展；允许 false 时可关闭此项。

类型：`false`

默认：`undefined`

### paragraphFormat

配置 createBlockParagraphExtensions 子扩展；允许 false 时可关闭此项。

类型：`false`

默认：`undefined`

### containers

配置 BlockContainer 子扩展；允许 false 时可关闭此项。

类型：`false`

默认：`undefined`

### image

设为 false 关闭 Block 内置图片块；未设置时按预设装配。

类型：`false`

默认：`undefined`

### search

配置 Search 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<SearchExtensionOptions>`

默认：`undefined`

子扩展的具体选项见 [Search](/plugins/reference/search)。是否可以设为 false，以本字段类型为准。

### formatting

配置 Formatting 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<FormattingOptions>`

默认：`undefined`

子扩展的具体选项见 [Formatting](/plugins/reference/formatting)。是否可以设为 false，以本字段类型为准。

### blockInteraction

配置 BlockInteraction 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<BlockInteractionOptions>`

默认：`undefined`

子扩展的具体选项见 [BlockInteraction](/plugins/reference/block-interaction)。是否可以设为 false，以本字段类型为准。

### dataView

配置 DataView 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<DataViewOptions>`

默认：`undefined`

子扩展的具体选项见 [DataView](/plugins/reference/data-view)。是否可以设为 false，以本字段类型为准。

### textDiagram

配置 TextDiagram 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<TextDiagramOptions>`

默认：`undefined`

子扩展的具体选项见 [TextDiagram](/plugins/reference/text-diagram)。是否可以设为 false，以本字段类型为准。

### mindMap

配置 MindMap 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<MindMapOptions>`

默认：`undefined`

子扩展的具体选项见 [MindMap](/plugins/reference/mind-map)。是否可以设为 false，以本字段类型为准。

### flowchart

配置 Flowchart 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<FlowchartOptions>`

默认：`undefined`

子扩展的具体选项见 [Flowchart](/plugins/reference/flowchart)。是否可以设为 false，以本字段类型为准。

### whiteboard

配置 Whiteboard 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<WhiteboardOptions>`

默认：`undefined`

子扩展的具体选项见 [Whiteboard](/plugins/reference/whiteboard)。是否可以设为 false，以本字段类型为准。

### starterKit

配置 StarterKit 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<StarterKitOptions>`

默认：`undefined`

子扩展的具体选项见 [StarterKit](/plugins/reference/starter-kit)。是否可以设为 false，以本字段类型为准。

### textStyle

配置整个 TextStyleKit 子组合，而不是只配置 TextStyle 标记。设为 false 会同时关闭预设中的文字样式组合与相应字体接线。

类型：`false | Partial<TextStyleKitOptions>`

默认：`undefined`

子扩展的具体选项见 [TextStyleKit](/plugins/reference/text-style-kit)。是否可以设为 false，以本字段类型为准。

### link

配置 Link 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<LinkOptions>`

默认：`undefined`

子扩展的具体选项见 [Link](/plugins/reference/link)。是否可以设为 false，以本字段类型为准。

### characterCount

配置 CharacterCount 子扩展；允许 false 时可关闭此项。

类型：`false | Partial<CharacterCountOptions>`

默认：`undefined`

子扩展的具体选项见 [CharacterCount](/plugins/reference/character-count)。是否可以设为 false，以本字段类型为准。

## 命令与运行方式

此入口没有直接声明可枚举的命令。组合扩展的命令由子扩展提供；产品插件通过 contribution 或文件服务工作。不能把安装入口名称当作命令调用。

此处返回的是内容扩展数组，不是 ClassicEditorPreset 对象。各子项未设置时启用预设默认装配；配置只覆盖指定子项。图片、图形工作区和完整 Block 产品仍有各自的媒体、挂载与保存合同。

## 下一步

返回[全部插件](/plugins)，或阅读[配置插件](/plugins/configuration)区分配置、文档属性与命令。

自己定义能力时见[扩展开发](/build/extension)；搭建完整宿主时见[构建产品](/build)。
