Skip to content

Commit

Permalink
Merge branch 'main' into import/html
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 committed Jan 11, 2025
2 parents 2f05b21 + 309533a commit b92ed85
Show file tree
Hide file tree
Showing 2,153 changed files with 41,085 additions and 37,444 deletions.
626 changes: 626 additions & 0 deletions BREAKING_CHANGES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/www/content/docs/cn/ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
BaseCodeLinePlugin,
BaseCodeSyntaxPlugin,
} from '@udecode/plate-code-block';
import { BaseParagraphPlugin, createSlateEditor } from '@udecode/plate-common';
import { BaseParagraphPlugin, createSlateEditor } from '@udecode/plate';
import { BaseHeadingPlugin, HEADING_LEVELS } from '@udecode/plate-heading';
import { BaseHorizontalRulePlugin } from '@udecode/plate-horizontal-rule';
import { BaseIndentListPlugin } from '@udecode/plate-indent-list';
Expand Down Expand Up @@ -393,7 +393,7 @@ AI 聊天是否打开。
插入带有 AI 标记的 AI 生成节点。

<APIParameters>
<APIItem name="nodes" type="TDescendant[]">
<APIItem name="nodes" type="Descendant[]">
要插入带有 AI 标记的节点。
</APIItem>
<APIItem name="options" type="object" optional>
Expand Down
4 changes: 2 additions & 2 deletions apps/www/content/docs/cn/alignment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ npm install @udecode/plate-alignment

```tsx
// ...
import { createPlateEditor } from '@udecode/plate-common/react';
import { createPlateEditor } from '@udecode/plate/react';
import { AlignPlugin } from '@udecode/plate-alignment/react';
import { ParagraphPlugin } from '@udecode/plate-common/react';
import { ParagraphPlugin } from '@udecode/plate/react';
import { HeadingPlugin } from '@udecode/plate-heading/react';

const editor = createPlateEditor({
Expand Down
11 changes: 0 additions & 11 deletions apps/www/content/docs/cn/api/common.mdx

This file was deleted.

24 changes: 21 additions & 3 deletions apps/www/content/docs/cn/api/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ description: udecode/plate-core的 API 参考。

有关更多详细信息,请参阅[调试](/docs/debugging)

### SlateNextPlugin
### SlateExtensionPlugin & SlateReactExtensionPlugin
扩展核心 API 并改进默认功能。

### DOMPlugin & ReactPlugin
Expand Down Expand Up @@ -485,5 +485,23 @@ description: udecode/plate-core的 API 参考。
### EventEditorPlugin
管理编辑器事件,如焦点和模糊。

### PlateApiPlugin
提供 Plate 编辑器功能的核心 API。
## Utils

### isType

检查节点是否匹配提供的类型。

<APIParameters>
<APIItem name="editor" type="PlateEditor<V>">
节点所在的编辑器。
</APIItem>
<APIItem name="node" type="any">
要检查的节点。
</APIItem>
<APIItem name="key" type="string | string[]" optional>
用于匹配节点的类型。可以是字符串或字符串数组。
</APIItem>
</APIParameters>
<APIReturns>
一个布尔值,指示节点的类型是否匹配提供的类型。
</APIReturns>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Plate
title: Plate Components
description: Plate 组件的 API 参考。
---

Expand Down Expand Up @@ -36,10 +36,10 @@ description: Plate 组件的 API 参考。
<APIItem name="readOnly" type="boolean" optional>
如果为 true,编辑器处于只读模式。
</APIItem>
<APIItem name="renderElement" type="FC<TRenderElementProps>" optional>
<APIItem name="renderElement" type="FC<RenderElementProps>" optional>
元素的自定义渲染函数。
</APIItem>
<APIItem name="renderLeaf" type="FC<TRenderLeafProps>" optional>
<APIItem name="renderLeaf" type="FC<RenderLeafProps>" optional>
叶子节点的自定义渲染函数。
</APIItem>
</APIParameters>
Expand All @@ -65,8 +65,8 @@ description: Plate 组件的 API 参考。
<APIItem name="onKeyDown" type="(event: KeyboardEvent) => void" optional />
<APIItem name="placeholder" type="string" optional />
<APIItem name="readOnly" type="boolean" optional />
<APIItem name="renderElement" type="FC<TRenderElementProps>" optional />
<APIItem name="renderLeaf" type="FC<TRenderLeafProps>" optional />
<APIItem name="renderElement" type="FC<RenderElementProps>" optional />
<APIItem name="renderLeaf" type="FC<RenderLeafProps>" optional />
<APIItem name="renderPlaceholder" type="FC<RenderPlaceholderProps>" optional />
<APIItem name="role" type="string" optional />
<APIItem name="scrollSelectionIntoView" type="(editor: ReactEditor, domRange: DOMRange) => void" optional />
Expand Down
6 changes: 3 additions & 3 deletions apps/www/content/docs/cn/api/core/plate-controller.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: PlateController
title: Plate Controller
description: PlateController 组件的 API 参考。
---

Expand Down Expand Up @@ -119,7 +119,7 @@ const App = withHoc(PlateController, () => {

const toggleBold = () => {
if (activeEditor.isFallback) return;
toggleMark(activeEditor, { key: BoldPlugin.key });
activeEditor.tf.toggleMark(BoldPlugin.key);
};

return (
Expand All @@ -146,7 +146,7 @@ const App = withHoc(PlateController, () => {
const isFallback = !useEditorMounted();

const toggleBold = () => {
toggleMark(activeEditor, { key: BoldPlugin.key });
activeEditor.tf.toggleMark(BoldPlugin.key);
};

return (
Expand Down
41 changes: 15 additions & 26 deletions apps/www/content/docs/cn/api/core/plate-editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Plate Editor
description: Plate 编辑器的 API 参考。
---

一个自定义的编辑器接口,扩展了基础的 **`TEditor`** 接口,并包含 Plate 库特有的属性和方法。
一个自定义的编辑器接口,扩展了基础的 **`Editor`** 接口,并包含 Plate 库特有的属性和方法。

## Core Properties

Expand Down Expand Up @@ -36,55 +36,55 @@ description: Plate 编辑器的 API 参考。
## API Methods

<APIParameters>
<APIItem name="getApi" type="<C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => InferApi<C>">
<APIItem name="getApi" type="(plugin: PlatePlugin) => EditorApi & PlatePlugin['api']">
获取插件的类型化 API。
</APIItem>
<APIItem name="getTransforms" type="<C extends AnyPluginConfig = PluginConfig>(plugin?: WithRequiredKey<C>) => InferTransforms<C>">
<APIItem name="getTransforms" type="(plugin: PlatePlugin) => EditorTransforms & PlatePlugin['transforms']">
获取插件的类型化变换。
</APIItem>
<APIItem name="getPlugin" type="<C extends AnyPluginConfig = PluginConfig>(plugin: WithRequiredKey<C>) => C extends { node: any } ? C : EditorPlatePlugin<C>">
<APIItem name="getPlugin" type="(plugin: PlatePlugin) => PlatePlugin">
通过键或基础插件获取编辑器插件实例。
</APIItem>
<APIItem name="getType" type="(plugin: WithRequiredKey) => string">
<APIItem name="getType" type="(plugin: PlatePlugin) => string">
获取插件的节点类型。
</APIItem>
</APIParameters>

## Option Methods

<APIParameters>
<APIItem name="getOption" type="<C extends AnyPluginConfig, K extends keyof InferOptions<C>, F extends InferOptions<C>[K]>(plugin: WithRequiredKey<C>, optionKey: K, ...args: F extends (...args: infer A) => any ? A : never) => F extends (...args: any[]) => infer R ? R : F">
<APIItem name="getOption" type="(plugin: PlatePlugin, optionKey: string) => any">
获取插件的特定选项值。
</APIItem>
<APIItem name="getOptions" type="<C extends AnyPluginConfig = PluginConfig>(plugin: WithRequiredKey<C>) => InferOptions<C>">
<APIItem name="getOptions" type="(plugin: PlatePlugin) => any">
获取插件的所有选项。
</APIItem>
<APIItem name="setOption" type="<C extends AnyPluginConfig, K extends keyof InferOptions<C>>(plugin: WithRequiredKey<C>, optionKey: K, value: InferOptions<C>[K]) => void">
<APIItem name="setOption" type="(plugin: PlatePlugin, optionKey: string, value: any) => void">
设置插件的特定选项值。
</APIItem>
<APIItem name="setOptions" type="<C extends AnyPluginConfig>(plugin: WithRequiredKey<C>, options: Parameters<SetImmerState<InferOptions<C>>>[0] | Partial<InferOptions<C>>) => void">
<APIItem name="setOptions" type="(plugin: PlatePlugin, options: (draft: object) => void | Partial<object>) => void">
设置插件的多个选项。
</APIItem>
<APIItem name="getOptionsStore" type="<C extends AnyPluginConfig>(plugin: WithRequiredKey<C>) => StoreApi<C['key'], InferOptions<C>>">
<APIItem name="getOptionsStore" type="(plugin: PlatePlugin) => any">
获取插件的 zustand-x 选项存储。
</APIItem>
</APIParameters>

## React Hooks

<APIParameters>
<APIItem name="useOption" type="<C extends AnyPluginConfig, K extends keyof InferOptions<C>, F extends InferOptions<C>[K], Args extends Parameters<((...args: any[]) => any) & F>>(plugin: WithRequiredKey<C>, optionKey: K, ...args: Args) => F extends (...args: any[]) => any ? ReturnType<F> : F">
<APIItem name="useOption" type="(plugin: PlatePlugin, optionKey: string) => any">
在 React 组件中订阅特定选项值。
</APIItem>
<APIItem name="useOptions" type="<C extends AnyPluginConfig, U>(plugin: WithRequiredKey<C>, selector?: (s: InferOptions<C>) => U, equalityFn?: EqualityChecker<U>) => U | InferOptions<C>">
<APIItem name="useOptions" type="(plugin: PlatePlugin) => any">
在 React 组件中订阅插件选项或派生自选项的值。
</APIItem>
</APIParameters>

## Plate Store Methods

<APIParameters>
<APIItem name="setPlateState" type="<K extends (typeof EXPOSED_STORE_KEYS)[number]>(optionKey: K, value: PlateStoreState[K]) => void">
<APIItem name="setPlateState" type="(optionKey: string, value: PlateStoreState[K]) => void">
更新全局 Plate 状态。
</APIItem>
</APIParameters>
Expand All @@ -108,21 +108,10 @@ description: Plate 编辑器的 API 参考。
</APIItem>
</APIParameters>

### SlateNextPlugin

<APIParameters>
<APIItem name="editor.tf.toggle.block" type="(options: ToggleBlockOptions) => void">
切换一个块元素。
</APIItem>
<APIItem name="editor.tf.toggle.mark" type="(options: ToggleMarkOptions) => void">
切换选中文本上的标记。
</APIItem>
</APIParameters>

### HtmlPlugin

<APIParameters>
<APIItem name="editor.api.html.deserialize" type="(options: { element: HTMLElement }) => TDescendant[]">
<APIItem name="editor.api.html.deserialize" type="(options: { element: HTMLElement }) => Descendant[]">
将 HTML 内容反序列化为 Slate 节点。
</APIItem>
</APIParameters>
Expand All @@ -135,7 +124,7 @@ description: Plate 编辑器的 API 参考。
</APIItem>
</APIParameters>

### PlateApiPlugin
### SlateReactExtensionPlugin

<APIParameters>
<APIItem name="editor.api.redecorate" type="() => void">
Expand Down
Loading

0 comments on commit b92ed85

Please sign in to comment.