Skip to content

Commit 21200ff

Browse files
committed
refactor: plugin keys
1 parent 6465c42 commit 21200ff

File tree

425 files changed

+2591
-3235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

425 files changed

+2591
-3235
lines changed

.github/workflows/lint-typecheck.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
run: yarn lint
7474

7575
- name: 🕵️ Typecheck
76-
run: yarn typecheck && yarn g:typecheck:apps
76+
run: yarn typecheck:all
7777

7878
notify-lint-typecheck-failure:
7979
name: Discord Notification

BREAKING_CHANGES.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# 34.0.0
22

33
## @udecode/plate-selection@34.0.0
4+
45
- Breaking Change: The `selectedColor` option for `BlockSelectable` has been deprecated. Please use `useBlockSelected` to customize the style of each node component.
56

67
- [#3241](https://github.com/udecode/plate/pull/3241) by [@felixfeng33](https://github.com/felixfeng33) – Add logic for the `block-context-menu` and improved the user experience for `block-selection`, such as interactions related to keyboard shortcuts, bug fixes.
@@ -193,10 +194,10 @@ None (CI release issue)
193194
- Caption is now a separate plugin. Install `@udecode/plate-caption` and add it to your plugins:
194195

195196
```ts
196-
import { ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED } from '@udecode/plate-media';
197+
import { ImagePlugin, MediaEmbedPlugin } from '@udecode/plate-media';
197198

198199
createCaptionPlugin({
199-
options: { pluginKeys: [ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED] },
200+
options: { pluginKeys: [ImagePlugin.key, ELEMENT_MEDIA_EMBED] },
200201
});
201202
```
202203

@@ -623,7 +624,7 @@ Migration:
623624
### Major Changes
624625

625626
- [#1871](https://github.com/udecode/plate/pull/1871) by [@zbeyens](https://github.com/zbeyens)
626-
- Removed `[ELEMENT_CODE_BLOCK]: CodeBlockElement` from Plate UI. You can define it in your app.
627+
- Removed `[CodeBlockPlugin.key]: CodeBlockElement` from Plate UI. You can define it in your app.
627628

628629
# 16.0.0
629630

@@ -658,7 +659,7 @@ Migration:
658659

659660
- [#1721](https://github.com/udecode/plate/pull/1721) by [@zbeyens](https://github.com/zbeyens)
660661
- `TableElementBase` props:
661-
- replace `onRenderContainer` by `floatingOptions` or by replacing `ELEMENT_TABLE` in the `createPlateUI` function.
662+
- replace `onRenderContainer` by `floatingOptions` or by replacing `TablePlugin.key` in the `createPlateUI` function.
662663
- `TablePopover` is now a floating instead of tippy
663664
- deps:
664665
- replaced `plate-ui-popover` by `plate-floating`
@@ -1025,7 +1026,7 @@ getEmptyTableNode(editor, { rowCount: 2, colCount: 2 });
10251026
// option 2: use createPlugins
10261027
plugins = createPlugins(plugins, {
10271028
components: {
1028-
[ELEMENT_PARAGRAPH]: ParagraphElement,
1029+
[ParagraphPlugin.key]: ParagraphElement,
10291030
},
10301031
});
10311032

@@ -1049,7 +1050,7 @@ getEmptyTableNode(editor, { rowCount: 2, colCount: 2 });
10491050
// option 2: use createPlugins
10501051
plugins = createPlugins(plugins, {
10511052
overrideByKey: {
1052-
[ELEMENT_PARAGRAPH]: {
1053+
[ParagraphPlugin.key]: {
10531054
type: 'paragraph',
10541055
},
10551056
},
@@ -1401,11 +1402,11 @@ getEmptyTableNode(editor, { rowCount: 2, colCount: 2 });
14011402
## `@udecode/plate-alignment`
14021403

14031404
- `setAlign`: option `align` renamed to `value`
1404-
- removed `getAlignOverrideProps()` in favor of `getOverrideProps(KEY_ALIGN)`
1405+
- removed `getAlignOverrideProps()` in favor of `getOverrideProps(AlignPlugin.key)`
14051406

14061407
## `@udecode/plate-indent`
14071408

1408-
- removed `getIndentOverrideProps()` in favor of `getOverrideProps(KEY_INDENT)`
1409+
- removed `getIndentOverrideProps()` in favor of `getOverrideProps(IndentPlugin.key)`
14091410
- rename `onKeyDownHandler` to `getIndentOnKeyDown()`
14101411
- `IndentPluginOptions`
14111412
- rename `types` to `validTypes`
@@ -1415,7 +1416,7 @@ getEmptyTableNode(editor, { rowCount: 2, colCount: 2 });
14151416
## `@udecode/plate-line-height`
14161417

14171418
- `setLineHeight`: option `lineHeight` renamed to `value`
1418-
- removed `getLineHeightOverrideProps` in favor of `getOverrideProps(KEY_LINE_HEIGHT)`
1419+
- removed `getLineHeightOverrideProps` in favor of `getOverrideProps(LineHeightPlugin.key)`
14191420

14201421
## `@udecode/plate-mention`
14211422

@@ -1457,7 +1458,7 @@ The align plugin is no longer wrapping a block, but instead setting an `align` p
14571458
- `ELEMENT_ALIGN_CENTER`
14581459
- `ELEMENT_ALIGN_RIGHT`
14591460
- `ELEMENT_ALIGN_JUSTIFY`
1460-
- `KEYS_ALIGN` in favor of `KEY_ALIGN`
1461+
- `KEYS_ALIGN` in favor of `AlignPlugin.key`
14611462
- `getAlignDeserialize`
14621463
- `upsertAlign` in favor of `setAlign`
14631464

apps/www/content/docs/accessing-editor.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use the first argument of the handler function.
1515

1616
```ts showLineNumbers {4,7}
1717
const createMyPlugin = createPlugin({
18-
key: KEY_MY_PLUGIN,
18+
key: 'my',
1919
handlers: {
2020
onKeyDown: (editor) => (event) => {
2121
// Do something with editor
@@ -35,7 +35,7 @@ For example, suppose you had this code and wanted to access the **`editor`** ins
3535

3636
```ts showLineNumbers
3737
const MyPlugin = createPlugin({
38-
key: KEY_MY_PLUGIN,
38+
key: 'my',
3939
deserializeHtml: {
4040
// Need editor here
4141
},
@@ -46,7 +46,7 @@ You would wrap the **`deserializeHtml`** option inside **`then`**.
4646

4747
```ts showLineNumbers {3,7}
4848
const MyPlugin = createPlugin({
49-
key: KEY_MY_PLUGIN,
49+
key: 'my',
5050
then: (editor) => ({
5151
deserializeHtml: {
5252
// Do something with editor
@@ -77,7 +77,7 @@ You can call these hooks from any React component that is rendered as a descenda
7777

7878
```tsx showLineNumbers {2}
7979
const Toolbar = () => {
80-
const boldActive = useEditorSelector((editor) => isMarkActive(editor, MARK_BOLD), []);
80+
const boldActive = useEditorSelector((editor) => isMarkActive(editor, BoldPlugin.key), []);
8181
// ...
8282
};
8383

apps/www/content/docs/alignment.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const plugins = [
3434
inject: {
3535
props: {
3636
validPlugins: [
37-
ELEMENT_PARAGRAPH,
37+
ParagraphPlugin.key,
3838
ELEMENT_H1,
3939
ELEMENT_H2,
4040
ELEMENT_H3,
@@ -65,7 +65,7 @@ The editor instance.
6565
<APISubListItem parent="options" name="key" type="string" optional>
6666
The plugin key.
6767

68-
- **Default:** `KEY_ALIGN`
68+
- **Default:** `AlignPlugin.key`
6969

7070
</APISubListItem>
7171
<APISubListItem parent="options" name="value" type="Alignment" optional>

apps/www/content/docs/api/core/plate-controller.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const App = withHoc(PlateController, () => {
119119

120120
const toggleBold = () => {
121121
if (activeEditor.isFallback) return;
122-
toggleMark(activeEditor, { key: MARK_BOLD });
122+
toggleMark(activeEditor, { key: BoldPlugin.key });
123123
};
124124

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

148148
const toggleBold = () => {
149-
toggleMark(activeEditor, { key: MARK_BOLD });
149+
toggleMark(activeEditor, { key: BoldPlugin.key });
150150
};
151151

152152
return (

apps/www/content/docs/api/core/plate-editor.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A custom editor interface that extends the base **`TEditor`**, **`THistoryEditor
1111
type="(node?: Partial<TElement>, path?: Path) => EElement"
1212
>
1313
A factory function that generates a default block, which by default is a
14-
block of type `ELEMENT_DEFAULT` with a single empty text child.
14+
block of type `ParagraphPlugin.key` with a single empty text child.
1515
</APIItem>
1616
<APIItem name="childrenFactory" type="() => V">
1717
A factory function that generates the children of the editor, which by

apps/www/content/docs/api/core/plate-plugin.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ Property used by Plate to inject a component below other plugins `component`, i.
326326
Property that can be used by a plugin to allow other plugins to inject code.
327327
- Differs from `overrideByKey` as this is not overriding any plugin.
328328
- For example, if multiple plugins have defined
329-
`inject.editor.insertData.transformData` for `key=KEY_DESERIALIZE_HTML`,
330-
`insertData` plugin will call all of these `transformData` for `KEY_DESERIALIZE_HTML` plugin.
329+
`inject.editor.insertData.transformData` for `key=DeserializeHtmlPlugin.key`,
330+
`insertData` plugin will call all of these `transformData` for `DeserializeHtmlPlugin.key` plugin.
331331
- The value of this property is an object with keys being the plugin keys and values being the injected code.
332332
```ts
333333
Record<PluginKey, Partial<AnyPlatePlugin>>
@@ -391,7 +391,7 @@ List of supported node values.
391391

392392
Plugin keys required to inject the props.
393393

394-
- Default: `[ELEMENT_DEFAULT]`
394+
- Default: `[ParagraphPlugin.key]`
395395

396396
</APISubListItem>
397397
</APISubList>

apps/www/content/docs/autoformat.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ If using the [List plugin](/docs/list), you can use the following rules:
8989

9090
### createAutoformatPlugin
9191

92-
[//]: # '- **`key: KEY_AUTOFORMAT`**'
92+
[//]: # '- **`key: AutoformatPlugin.key`**'
9393

9494
<APIOptions>
9595

apps/www/content/docs/basic-elements.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ docs:
3838
```bash
3939
npm install @udecode/plate-basic-elements
4040
# or
41-
npm install @udecode/plate-block-quote @udecode/plate-code-block @udecode/plate-heading @udecode/plate-paragraph
41+
npm install @udecode/plate-block-quote @udecode/plate-code-block @udecode/plate-heading
4242
```
4343

4444
## Usage

apps/www/content/docs/caption.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { createCaptionPlugin } from '@udecode/plate-caption';
3030
const plugins = [
3131
// ...otherPlugins,
3232
createCaptionPlugin({
33-
options: { pluginKeys: [ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED] },
33+
options: { pluginKeys: [ImagePlugin.key, MediaEmbedPlugin.key] },
3434
}),
3535
];
3636
```

apps/www/content/docs/combobox.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: Utilities for adding comboboxes to your editor.
77

88
The TriggerComboboxPluginOptions mixin configures your plugin to insert a combobox input element when the user types a specified trigger character is typed.
99

10-
For example, the [Mention](/docs/mention) plugin uses TriggerComboboxPluginOptions to insert an `ELEMENT_MENTION_INPUT` whenever the user types `@`.
10+
For example, the [Mention](/docs/mention) plugin uses TriggerComboboxPluginOptions to insert an `MentionInputPlugin.key` whenever the user types `@`.
1111

1212
### Usage
1313

apps/www/content/docs/excalidraw.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ npm install @udecode/plate-excalidraw
2727
```tsx
2828
import {
2929
createExcalidrawPlugin,
30-
ELEMENT_EXCALIDRAW,
30+
ExcalidrawPlugin,
3131
ExcalidrawElement,
3232
} from '@udecode/plate-excalidraw';
3333
import { createSelectOnBackspacePlugin } from '@udecode/plate-select';
@@ -36,7 +36,7 @@ const plugins = [
3636
// ...otherPlugins
3737
createExcalidrawPlugin(),
3838
createSelectOnBackspacePlugin({
39-
options: { query: { allow: [ELEMENT_EXCALIDRAW] } },
39+
options: { query: { allow: [ExcalidrawPlugin.key] } },
4040
}),
4141
];
4242
```
@@ -63,7 +63,7 @@ The props and key for the Excalidraw element.
6363
<APISubListItem parent="props" name="key" type="string">
6464
The key for the Excalidraw element.
6565

66-
- **Default:** `ELEMENT_EXCALIDRAW`
66+
- **Default:** `ExcalidrawPlugin.key`
6767

6868
</APISubListItem>
6969

apps/www/content/docs/exit-break.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ If true, exit relative to the selection.
141141
<APISubListItem parent="options" name="defaultType" type="function" optional>
142142
The default type of the node to be inserted upon exit.
143143

144-
- **Default:** `getPluginType(editor, ELEMENT_DEFAULT)`
144+
- **Default:** `getPluginType(editor, ParagraphPlugin.key)`
145145

146146
</APISubListItem>
147147
<APISubListItem parent="options" name="query" type="object" optional>

apps/www/content/docs/forced-layout.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
2727

2828
const plugins = [
2929
// ...otherPlugins
30-
createTrailingBlockPlugin({ options: { type: ELEMENT_PARAGRAPH } }),
30+
createTrailingBlockPlugin({ options: { type: ParagraphPlugin.key } }),
3131
createNormalizeTypesPlugin({
3232
options: {
3333
rules: [{ path: [0], strictType: ELEMENT_H1 }],

apps/www/content/docs/getting-started.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ import {
177177
import { createBlockquotePlugin } from '@udecode/plate-block-quote';
178178
import { createPlugins, Plate } from '@udecode/plate-common';
179179
import { createHeadingPlugin } from '@udecode/plate-heading';
180-
import { createParagraphPlugin } from '@udecode/plate-paragraph';
180+
import { createParagraphPlugin } from '@udecode/plate-common';
181181

182182
import { createPlateUI } from '@/lib/create-plate-ui';
183183

apps/www/content/docs/horizontal-rule.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ npm install @udecode/plate-horizontal-rule
2727

2828
```tsx
2929
import { createAutoformatPlugin } from '@udecode/plate-autoformat';
30-
import { ELEMENT_DEFAULT, insertNodes, setNodes } from '@udecode/plate-common';
30+
import { ParagraphPlugin, insertNodes, setNodes } from '@udecode/plate-common';
3131
import {
32-
ELEMENT_HR,
32+
HorizontalRulePlugin,
3333
createHorizontalRulePlugin,
3434
} from '@udecode/plate-horizontal-rule';
3535
import { createSelectOnBackspacePlugin } from '@udecode/plate-select';
@@ -38,19 +38,19 @@ const plugins = [
3838
// ...otherPlugins,
3939
createHorizontalRulePlugin(),
4040
createSelectOnBackspacePlugin({
41-
options: { query: { allow: [ELEMENT_HR] } },
41+
options: { query: { allow: [HorizontalRulePlugin.key] } },
4242
}),
4343
createAutoformatPlugin({
4444
options: {
4545
rules: [
4646
{
4747
mode: 'block',
48-
type: ELEMENT_HR,
48+
type: HorizontalRulePlugin.key,
4949
match: ['---', '—-', '___ '],
5050
format: (editor) => {
51-
setNodes(editor, { type: ELEMENT_HR });
51+
setNodes(editor, { type: HorizontalRulePlugin.key });
5252
insertNodes(editor, {
53-
type: ELEMENT_DEFAULT,
53+
type: ParagraphPlugin.key,
5454
children: [{ text: '' }],
5555
});
5656
},

apps/www/content/docs/indent-list.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ const plugins = [
4141
createIndentPlugin({
4242
inject: {
4343
props: {
44-
validPlugins: [ELEMENT_PARAGRAPH, ELEMENT_H1],
44+
validPlugins: [ParagraphPlugin.key, ELEMENT_H1],
4545
},
4646
},
4747
}),
4848
createIndentListPlugin({
4949
inject: {
5050
props: {
51-
validPlugins: [ELEMENT_PARAGRAPH, ELEMENT_H1],
51+
validPlugins: [ParagraphPlugin.key, ELEMENT_H1],
5252
},
5353
},
5454
}),

apps/www/content/docs/indent.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const plugins = [
3737
createIndentPlugin({
3838
inject: {
3939
props: {
40-
validPlugins: [ELEMENT_PARAGRAPH, ELEMENT_H1],
40+
validPlugins: [ParagraphPlugin.key, ELEMENT_H1],
4141
},
4242
},
4343
}),

apps/www/content/docs/list.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ const plugins = [
7373

7474
- `key: 'list'`
7575
- Contains the following element plugins:
76-
- `ELEMENT_UL`: plugin options below.
77-
- `ELEMENT_OL`: plugin options below.
78-
- `ELEMENT_LI`
79-
- `ELEMENT_LIC`
76+
- `ListUnorderedPlugin.key`: plugin options below.
77+
- `ListOrderedPlugin.key`: plugin options below.
78+
- `ListItemPlugin.key`
79+
- `ListItemContentPlugin.key`
8080

8181
<APIOptions>
8282
<APIItem name="validLiChildrenTypes" type="string[]" optional>
@@ -730,7 +730,7 @@ The pressed state of the button.
730730
<APIItem name="nodeType" type="string">
731731
The node type of the list.
732732

733-
- **Default:** `ELEMENT_UL`
733+
- **Default:** `ListUnorderedPlugin.key`
734734

735735
</APIItem>
736736
</APIState>

0 commit comments

Comments
 (0)