Skip to content

Commit 6465c42

Browse files
committed
V -> E
1 parent 964f3d0 commit 6465c42

File tree

133 files changed

+543
-769
lines changed

Some content is hidden

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

133 files changed

+543
-769
lines changed

apps/www/content/docs/api/slate-utils.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Retrieves the start point of the next node at a specified path in the editor.
148148
Retrieves the sibling nodes following a specified path in the ancestor node.
149149

150150
<APIParameters>
151-
<APIItem name="ancestorEntry" type="EAncestorEntry">
151+
<APIItem name="ancestorEntry" type="AncestorEntryOf<E>">
152152
The ancestor node of the sibling nodes.
153153
</APIItem>
154154
<APIItem name="path" type="Path">
@@ -758,7 +758,7 @@ Sets marks to selected text.
758758
<APIItem name="editor" type="TEditor">
759759
The editor instance.
760760
</APIItem>
761-
<APIItem name="marks" type="EMarks">
761+
<APIItem name="marks" type="MarksOf<E>">
762762
The marks to set.
763763
</APIItem>
764764
<APIItem name="clear" type="string | string[]" optional>

apps/www/content/docs/api/utils.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Replaces the children of an editor with default blocks.
257257
</APIItem>
258258
<APIItem
259259
name="options"
260-
type="Omit<ReplaceNodeChildrenOptions<EElement<V>, V>, 'at' | 'nodes'>"
260+
type="Omit<ReplaceNodeChildrenOptions<ElementOf<E>, V>, 'at' | 'nodes'>"
261261
optional
262262
>
263263
Options for replacing the children of the node. Excludes `at` and `nodes`

apps/www/content/docs/emoji.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const plugins = [
4646
Extends [TriggerComboboxPlugin](/docs/combobox#options)
4747

4848
<APIOptions>
49-
<APIItem name="createEmojiNode" type="(emoji: TEmoji): EElementOrText<any>" optional>
49+
<APIItem name="createEmojiNode" type="(emoji: TEmoji): ElementOrTextOf<any>" optional>
5050
A function to specify the node inserted when an emoji is selected. The default behavior is to insert a text node containing the emoji as a Unicode character.
5151
</APIItem>
5252
</APIOptions>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const plugins = [
8282
<APIItem name="editor" type="TEditor">
8383
The editor instance.
8484
</APIItem>
85-
<APIItem name="entry" type="EElementEntry">
85+
<APIItem name="entry" type="ElementEntryOf">
8686
The entry of the current element.
8787
</APIItem>
8888
<APIItem
@@ -107,7 +107,7 @@ Gets the previous sibling entry with an indent list.
107107
<APIItem name="editor" type="TEditor">
108108
The editor instance.
109109
</APIItem>
110-
<APIItem name="entry" type="EElementEntry">
110+
<APIItem name="entry" type="ElementEntryOf">
111111
The entry of the current element.
112112
</APIItem>
113113
<APIItem

apps/www/content/docs/serializing-html.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ The Slate editor instance.
7878
Options to control the HTML serialization process.
7979

8080
<APISubList>
81-
<APISubListItem parent="options" name="nodes" type="EDescendant[]">
81+
<APISubListItem parent="options" name="nodes" type="DescendantOf<E>[]">
8282

8383
The Slate nodes to convert into HTML.
8484

apps/www/src/types/plate-types.ts

+7-21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import type {
66
ELEMENT_CODE_LINE,
77
} from '@udecode/plate-code-block';
88
import type { TCommentText } from '@udecode/plate-comments';
9+
import type {
10+
ElementOf,
11+
TElement,
12+
TPlateEditor,
13+
TText,
14+
} from '@udecode/plate-common';
915
import type {
1016
ELEMENT_EXCALIDRAW,
1117
TExcalidrawElement,
@@ -48,30 +54,10 @@ import type {
4854
} from '@udecode/plate-table';
4955
import type { ELEMENT_TOGGLE, TToggleElement } from '@udecode/plate-toggle';
5056

51-
import {
52-
type EElement,
53-
type TElement,
54-
type TPlateEditor,
55-
type TText,
56-
createPlugin,
57-
} from '@udecode/plate-common';
5857
import { useEditorRef } from '@udecode/plate-common/react';
5958

6059
/** Text */
6160

62-
const MyCustomPlugin = createPlugin({
63-
api: {
64-
myCustomMethod: () => {},
65-
},
66-
key: 'myCustom',
67-
});
68-
69-
// const editor = withPlate<Value, typeof MyCustomPlugin>(createTEditor(), {
70-
// plugins: [MyCustomPlugin],
71-
// });
72-
// const b: TPlateEditor<Value, typeof MyCustomPlugin> = {};
73-
// b.api.myCustomMethod();
74-
7561
export type EmptyText = {
7662
text: '';
7763
};
@@ -268,7 +254,7 @@ export interface MyExcalidrawElement
268254

269255
export type MyNestableBlock = MyParagraphElement;
270256

271-
export type MyElement = EElement<MyValue>;
257+
export type MyElement = ElementOf<MyEditor>;
272258

273259
export type MyBlock = Exclude<MyElement, MyInlineElement>;
274260

packages/alignment/src/shared/transforms/setAlign.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import {
2-
type ENode,
32
type PlateEditor,
43
type SetNodesOptions,
54
type TNodeMatch,
6-
type Value,
7-
type ValueOf,
85
getKeyByType,
96
getPluginInjectProps,
107
isBlock,
@@ -24,7 +21,7 @@ export const setAlign = <E extends PlateEditor>(
2421
value,
2522
}: {
2623
key?: string;
27-
setNodesOptions?: SetNodesOptions<ValueOf<E>>;
24+
setNodesOptions?: SetNodesOptions<E>;
2825
value: Alignment;
2926
}
3027
) => {
@@ -33,7 +30,7 @@ export const setAlign = <E extends PlateEditor>(
3330
key
3431
);
3532

36-
const match: TNodeMatch<ENode<Value>> = (n) => {
33+
const match: TNodeMatch = (n) => {
3734
return (
3835
isBlock(editor, n) &&
3936
!!validPlugins &&

packages/callout/src/transforms/insertCallout.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
type InsertNodesOptions,
33
type PlateEditor,
4-
type ValueOf,
54
insertNodes,
65
} from '@udecode/plate-common';
76

@@ -11,7 +10,7 @@ import { ELEMENT_CALLOUT } from '../CalloutPlugin';
1110

1211
export const insertCallout = <E extends PlateEditor>(
1312
editor: E,
14-
options?: InsertNodesOptions<ValueOf<E>>
13+
options?: InsertNodesOptions<E>
1514
) => {
1615
insertNodes<TCalloutElement>(
1716
editor,

packages/code-block/src/lib/queries/getCodeLineEntry.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { ValueOf } from '@udecode/plate-common';
21
import type { Location } from 'slate';
32

43
import {
5-
type EElement,
4+
type ElementOf,
65
type PlateEditor,
76
type TElement,
87
type TNodeEntry,
@@ -15,10 +14,7 @@ import {
1514
import { getCodeLineType } from '../options';
1615

1716
/** If at (default = selection) is in ul>li>p, return li and ul node entries. */
18-
export const getCodeLineEntry = <
19-
N extends EElement<ValueOf<E>>,
20-
E extends PlateEditor,
21-
>(
17+
export const getCodeLineEntry = <N extends ElementOf<E>, E extends PlateEditor>(
2218
editor: E,
2319
{ at = editor.selection }: { at?: Location | null } = {}
2420
) => {

packages/code-block/src/lib/transforms/insertCodeBlock.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { ValueOf } from '@udecode/plate-common';
2-
31
import {
42
type InsertNodesOptions,
53
type PlateEditor,
@@ -21,7 +19,7 @@ import { getCodeLineType } from '../options';
2119
*/
2220
export const insertCodeBlock = <E extends PlateEditor>(
2321
editor: E,
24-
insertNodesOptions: Omit<InsertNodesOptions<ValueOf<E>>, 'match'> = {}
22+
insertNodesOptions: Omit<InsertNodesOptions<E>, 'match'> = {}
2523
) => {
2624
if (!editor.selection || isExpanded(editor.selection)) return;
2725

packages/code-block/src/lib/transforms/insertEmptyCodeBlock.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { ValueOf } from '@udecode/plate-common';
2-
31
import {
42
ELEMENT_DEFAULT,
53
type PlateEditor,
@@ -22,7 +20,7 @@ export const insertEmptyCodeBlock = <E extends PlateEditor>(
2220
{
2321
defaultType = getPluginType(editor, ELEMENT_DEFAULT),
2422
insertNodesOptions,
25-
}: CodeBlockInsertOptions<ValueOf<E>> = {}
23+
}: CodeBlockInsertOptions<E> = {}
2624
) => {
2725
if (!editor.selection) return;
2826
if (isExpanded(editor.selection) || !isBlockAboveEmpty(editor)) {

packages/code-block/src/lib/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {
22
HotkeyPluginOptions,
33
InsertNodesOptions,
4+
TEditor,
45
TElement,
5-
Value,
66
} from '@udecode/plate-common';
77
import type { Token, languages, tokenize } from 'prismjs';
88

@@ -23,7 +23,7 @@ export interface TCodeBlockElement extends TElement {
2323
lang?: string;
2424
}
2525

26-
export interface CodeBlockInsertOptions<V extends Value = Value> {
26+
export interface CodeBlockInsertOptions<E extends TEditor = TEditor> {
2727
defaultType?: string;
28-
insertNodesOptions?: Omit<InsertNodesOptions<V>, 'match'>;
28+
insertNodesOptions?: Omit<InsertNodesOptions<E>, 'match'>;
2929
}

packages/core/src/lib/plugins/editor-protocol/SlateNextPlugin.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import type { Path } from 'slate';
22

33
import {
4-
type EAncestor,
4+
type AncestorOf,
55
type GetAboveNodeOptions,
66
type TEditor,
77
type TElement,
88
type TRange,
99
type Value,
10-
type ValueOf,
1110
getAboveNode,
1211
getMarks,
1312
isExpanded,
@@ -22,21 +21,18 @@ import { getPluginType } from '../../plugin';
2221
import { createPlugin } from '../../plugin/createPlugin';
2322
import { resetEditor } from '../../transforms';
2423

25-
const getBlockAbove = <
26-
N extends EAncestor<ValueOf<E>>,
27-
E extends TEditor = TEditor,
28-
>(
24+
const getBlockAbove = <N extends AncestorOf<E>, E extends TEditor = TEditor>(
2925
editor: E,
30-
options: GetAboveNodeOptions<ValueOf<E>> = {}
26+
options: GetAboveNodeOptions<E> = {}
3127
) =>
32-
getAboveNode<N, ValueOf<E>>(editor, {
28+
getAboveNode<N, E>(editor, {
3329
...options,
3430
block: true,
3531
});
3632

37-
const isSelectionAtBlockStart = <E extends TEditor = TEditor>(
33+
const isSelectionAtBlockStart = <E extends TEditor>(
3834
editor: E,
39-
options?: GetAboveNodeOptions<ValueOf<E>>
35+
options?: GetAboveNodeOptions<E>
4036
) => {
4137
const { selection } = editor;
4238

packages/core/src/lib/transforms/resetEditorChildren.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EElement, ValueOf } from '@udecode/slate';
1+
import type { ElementOf } from '@udecode/slate';
22

33
import {
44
type ReplaceNodeChildrenOptions,
@@ -10,12 +10,9 @@ import type { PlateEditor } from '../editor';
1010
/** Replace editor children by default block. */
1111
export const resetEditorChildren = <E extends PlateEditor = PlateEditor>(
1212
editor: E,
13-
options?: Omit<
14-
ReplaceNodeChildrenOptions<EElement<ValueOf<E>>, ValueOf<E>>,
15-
'at' | 'nodes'
16-
>
13+
options?: Omit<ReplaceNodeChildrenOptions<ElementOf<E>, E>, 'at' | 'nodes'>
1714
) => {
18-
replaceNodeChildren<EElement<ValueOf<E>>>(editor, {
15+
replaceNodeChildren<ElementOf<E>>(editor, {
1916
at: [],
2017
nodes: editor.api.childrenFactory(),
2118
...options,

packages/core/src/lib/transforms/toggleNodeType.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
type GetNodeEntriesOptions,
3-
type ValueOf,
43
setElements,
54
someNode,
65
} from '@udecode/slate';
@@ -31,7 +30,7 @@ export interface ToggleNodeTypeOptions {
3130
export const toggleNodeType = <E extends PlateEditor = PlateEditor>(
3231
editor: E,
3332
options: ToggleNodeTypeOptions,
34-
editorNodesOptions?: Omit<GetNodeEntriesOptions<ValueOf<E>>, 'match'>
33+
editorNodesOptions?: Omit<GetNodeEntriesOptions<E>, 'match'>
3534
) => {
3635
const { activeType, inactiveType = getPluginType(editor, ELEMENT_DEFAULT) } =
3736
options;

packages/dnd/src/queries/getBlocksWithId.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {
22
type GetNodeEntriesOptions,
33
type TEditor,
4-
type Value,
54
getNodeEntries,
65
isBlock,
76
} from '@udecode/plate-common';
87

98
/** Get blocks with an id */
10-
export const getBlocksWithId = <V extends Value>(
11-
editor: TEditor<V>,
12-
options: GetNodeEntriesOptions<V>
9+
export const getBlocksWithId = <E extends TEditor>(
10+
editor: E,
11+
options: GetNodeEntriesOptions<E>
1312
) => {
1413
const _nodes = getNodeEntries(editor, {
1514
match: (n) => isBlock(editor, n) && !!n.id,

packages/dnd/src/transforms/removeBlocksAndFocus.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
type GetNodeEntriesOptions,
3-
type Value,
43
getNodesRange,
54
removeNodes,
65
unhangRange,
@@ -10,9 +9,9 @@ import { type TReactEditor, focusEditor } from '@udecode/plate-common/react';
109
import { getBlocksWithId } from '../queries/getBlocksWithId';
1110

1211
/** Remove blocks with an id and focus the editor. */
13-
export const removeBlocksAndFocus = <V extends Value>(
14-
editor: TReactEditor<V>,
15-
options: GetNodeEntriesOptions<V>
12+
export const removeBlocksAndFocus = <E extends TReactEditor = TReactEditor>(
13+
editor: E,
14+
options: GetNodeEntriesOptions<E>
1615
) => {
1716
unhangRange(editor, options?.at, options);
1817

packages/excalidraw/src/transforms/insertExcalidraw.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
type InsertNodesOptions,
33
type PlateEditor,
44
type TNodeProps,
5-
type ValueOf,
65
getParentNode,
76
insertNodes,
87
} from '@udecode/plate-common';
@@ -17,7 +16,7 @@ export const insertExcalidraw = <E extends PlateEditor>(
1716
key = ELEMENT_EXCALIDRAW,
1817
...props
1918
}: { key?: string } & TNodeProps<TExcalidrawElement> = {},
20-
options: InsertNodesOptions<ValueOf<E>> = {}
19+
options: InsertNodesOptions<E> = {}
2120
): void => {
2221
if (!editor.selection) return;
2322

packages/heading/src/toc/transforms/insertToc.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import {
22
type InsertNodesOptions,
33
type PlateEditor,
44
type TElement,
5-
type ValueOf,
65
insertNodes,
76
} from '@udecode/plate-common';
87

98
import { ELEMENT_TOC } from '../TocPlugin';
109

1110
export const insertToc = <E extends PlateEditor>(
1211
editor: E,
13-
options?: InsertNodesOptions<ValueOf<E>>
12+
options?: InsertNodesOptions<E>
1413
) => {
1514
insertNodes<TElement>(
1615
editor,
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { ENode, Value } from '@udecode/plate-common';
1+
import type { TNode } from '@udecode/plate-common';
22

33
import { KEYS_HEADING } from '../heading';
44

5-
export const isHeading = (node: ENode<Value>) => {
5+
export const isHeading = (node: TNode) => {
66
return node.type && KEYS_HEADING.includes(node.type as string);
77
};

0 commit comments

Comments
 (0)