Skip to content

Commit

Permalink
Merge pull request #2514 from udecode/docs/api
Browse files Browse the repository at this point in the history
API Plugin docs
  • Loading branch information
zbeyens authored Jul 17, 2023
2 parents b7d4bc2 + 62dae72 commit c577275
Show file tree
Hide file tree
Showing 52 changed files with 5,236 additions and 1,121 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-coins-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-excalidraw': patch
---

Fix useExcalidrawElement typo
60 changes: 60 additions & 0 deletions apps/www/content/docs/alignment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,66 @@ const plugins = [

### setAlign

Sets the alignment for the specified block elements in the editor.

<APIParameters>
<APIItem name="editor" type="PlateEditor">
The editor instance.
</APIItem>
<APIItem name="options" type="object" optional>
<APISubList>
<APISubListItem parent="options" name="key" type="string" optional>
The plugin key.

- **Default:** `KEY_ALIGN`

</APISubListItem>
<APISubListItem parent="options" name="value" type="Alignment" optional>
The alignment value.
</APISubListItem>
<APISubListItem parent="options" name="setNodesOptions" type="SetNodesOptions" optional>
</APISubListItem>

</APISubList>
</APIItem>
</APIParameters>

## API Components

### useAlignDropdownMenuState

<APIReturns>
<APIItem name="value" type="'left' | 'center' | 'right' | 'justify'">
The alignment value.
</APIItem>
</APIReturns>

### useAlignDropdownMenu

<APIState>
<APIItem name="value" type="'left' | 'center' | 'right' | 'justify'">
The alignment value.
</APIItem>
</APIState>

<APIReturns>
<APIItem name="radioGroupProps" type="object">
Props for the radio group.
<APISubList>
<APISubListItem
parent="radioGroupProps"
name="value"
type="'left' | 'center' | 'right' | 'justify'"
>
The alignment value.
</APISubListItem>
<APISubListItem
parent="radioGroupProps"
name="onValueChange"
type="function"
>
Callback to set the alignment value.
</APISubListItem>
</APISubList>
</APIItem>
</APIReturns>
8 changes: 4 additions & 4 deletions apps/www/content/docs/api/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ Get an editor reference which is never updated.

<APIParameters>
<APIItem name="id" type="PlateId" optional>
The id of the plate editor. Useful only when nesting editors.
The ID of the plate editor. Useful only when nesting editors.
</APIItem>
</APIParameters>
<APIReturns>
Expand All @@ -382,7 +382,7 @@ Get the Slate editor reference. Re-renders on editor change.

<APIParameters>
<APIItem name="id" type="PlateId" optional>
The id of the plate editor.
The ID of the plate editor.
</APIItem>
</APIParameters>
<APIReturns>
Expand All @@ -397,7 +397,7 @@ Get the editor's `readOnly` state.

<APIParameters>
<APIItem name="id" type="PlateId" optional>
The id of the plate editor.
The ID of the plate editor.
</APIItem>
</APIParameters>
<APIReturns>
Expand All @@ -412,7 +412,7 @@ Get the editor's selection which is updated on each editor change.

<APIParameters>
<APIItem name="id" type="PlateId" optional>
The id of the plate editor.
The ID of the plate editor.
</APIItem>
</APIParameters>
<APIReturns>The current selection in the editor.</APIReturns>
Expand Down
2 changes: 1 addition & 1 deletion apps/www/content/docs/api/core/plate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: API reference for Plate component.

<APIParameters>
<APIItem name="id" type="symbol | string | number" optional>
A unique identifier to store the editor state by id. This is mandatory when nesting **`Plate`** instances but optional otherwise.
A unique ID to store the editor state by ID. This is mandatory when nesting **`Plate`** instances but optional otherwise.

- **Default:** `'main'`.

Expand Down
24 changes: 12 additions & 12 deletions apps/www/content/docs/api/core/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ description: API reference for Plate store.

### State

The PlateStoreState object stores the state of the Plate editor. It contains information about the editor's id, its current value, its plugins, and other settings.
The PlateStoreState object stores the state of the Plate editor. It contains information about the editor's ID, its current value, its plugins, and other settings.

<APIAttributes>
<APIItem name="id" type="PlateId">

A unique id used as a provider scope. Use it if you have multiple `PlateProvider` in the same React tree.
A unique ID used as a provider scope. Use it if you have multiple `PlateProvider` in the same React tree.

- **Default:** `PLATE_SCOPE`

Expand Down Expand Up @@ -135,7 +135,7 @@ Redecorate the editor.

<APIParameters>
<APIItem name="id" type="string" optional>
Editor id.
Editor ID.
</APIItem>
</APIParameters>

Expand All @@ -146,14 +146,14 @@ Reset an editor with the same plugins.
<APIParameters>

<APIItem name="id" type="string" optional>
Editor id.
Editor ID.
</APIItem>

</APIParameters>

## Event Editor Store

This store is an object whose property keys are event names (e.g. `'focus'`) and whose property values are [editor ids](Plate#id).
This store is an object whose property keys are event names (e.g. `'focus'`) and whose property values are [editor IDs](Plate#id).

- This is useful when having [multiple editors](multiple-editors) and get one based on DOM events (e.g. the last focused editor).
- One of the core plugins of [Plate](Plate) will store the following events.
Expand All @@ -163,19 +163,19 @@ This store is an object whose property keys are event names (e.g. `'focus'`) and
<APIAttributes>
<APIItem name="blur" type="PlateId | null">

Last editor id that has been blurred.
Last editor ID that has been blurred.

</APIItem>

<APIItem name="focus" type="PlateId | null">

Editor id that is currently being focused.
Editor ID that is currently being focused.

</APIItem>

<APIItem name="last" type="PlateId | null">

Last editor id.
Last editor ID.

</APIItem>
</APIAttributes>
Expand All @@ -185,21 +185,21 @@ Last editor id.
Hook selectors.

- **Example:** `useEventEditorSelectors().focus()` will get the
last focused editor id.
last focused editor ID.

### `useEventPlateId`

Get the last event editor id.
Get the last event editor ID.

<APIParameters>
<APIItem name="id" type="PlateId | null">

Returned id if defined.
Returned ID if defined.

</APIItem>
</APIParameters>

<APIReturns>
The `PlateId` from the context if available, otherwise the last event editor
id or `PLATE_SCOPE`.
ID or `PLATE_SCOPE`.
</APIReturns>
51 changes: 41 additions & 10 deletions apps/www/content/docs/autoformat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,49 @@ import { createAutoformatPlugin } from '@udecode/plate-autoformat';
const plugins = [
// ...otherPlugins,
createAutoformatPlugin({
// options
rules: autoformatRules,
enableUndoOnDelete: true,
}),
];
```

## Examples

### `autoformatRules`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatRules.ts" />

### `autoformatBlocks`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatBlocks.ts" />

### `autoformatIndentLists`

If using the [Indent List plugin](/docs/indent-list), you can use the following rules:

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatIndentLists.ts" />

### `autoformatLists`

If using the [List plugin](/docs/list), you can use the following rules:

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatLists.ts" />

### `autoformatMarks`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatMarks.ts" />

### `autoformatUtils`

<ComponentSource src="../../templates/plate-playground-template/src/lib/plate/autoformatUtils.ts" />

## API

### createAutoformatPlugin

<APIAttributes>
[//]: # '- **`key: KEY_AUTOFORMAT`**'

Options.
<APIOptions>

<APIItem name="rules" type="AutoformatRule[]" optional>

Expand All @@ -73,7 +104,7 @@ A list of triggering rules.
Enable undo on delete.

</APIItem>
</APIAttributes>
</APIOptions>

### Rules

Expand All @@ -91,12 +122,12 @@ You can import the following rules:
| | Converts `<-` to ``. |
| | Converts `=>` to ``. |
| | Converts `<=` and `≤=` to ``. |
| `autoformatLegal` | Converts `(tm)` and `(TM)` to ``. |
| | Converts `(r)` and `(R)` to `®`. |
| | Converts `(c)` and `(C)` to `©`. |
| `autoformatLegalHtml` | Converts `&trade;` to ``. |
| | Converts `&reg;` to `®`. |
| | Converts `&copy;` to `©`. |
| `autoformatLegal` | Converts `(tm)` and `(TM)` to ``. |
| | Converts `(r)` and `(R)` to `®`. |
| | Converts `(c)` and `(C)` to `©`. |
| `autoformatLegalHtml` | Converts `&trade;` to ``. |
| | Converts `&reg;` to `®`. |
| | Converts `&copy;` to `©`. |
| | Converts `&sect;` to `§`. |
| `autoformatComparison` | Converts `!>` to `!>`. |
| | Converts `!<` to ``. |
Expand Down
Loading

0 comments on commit c577275

Please sign in to comment.