From 124bc5ce0508755b86ca683cf7b21ec9fcf8528f Mon Sep 17 00:00:00 2001 From: kudlajz Date: Thu, 16 Jan 2025 11:38:16 +0100 Subject: [PATCH] Remove 'slate' imports from the main codebase --- .../src/commands/findDescendants.ts | 5 ++-- .../src/commands/isBlockActive.ts | 11 +++++--- .../src/commands/isTopLevelNode.ts | 2 +- .../src/commands/isTopLevelNodeSelected.ts | 5 ++-- .../slate-commons/src/commands/unsetMark.ts | 4 +-- .../src/lib/createDeserializeElement.ts | 2 +- .../slate-commons/src/lib/withoutNodes.ts | 5 ++-- .../slate-commons/src/selection/highest.ts | 14 ++++++++--- packages/slate-commons/src/types/Extension.ts | 2 +- .../src/extensions/allowed-blocks/types.ts | 2 +- .../extensions/heading/HeadingExtension.tsx | 2 +- .../inline-links/lib/autolinkPlaintext.ts | 2 +- .../extensions/mentions/MentionsExtension.ts | 5 ++-- .../placeholders/lib/removePlaceholder.ts | 5 ++-- .../src/extensions/placeholders/types.ts | 2 +- .../src/extensions/tables/TablesExtension.tsx | 3 +-- .../components/elements/TableCellElement.tsx | 2 +- .../components/elements/TableElement.tsx | 2 +- .../components/elements/TableRowElement.tsx | 2 +- .../src/extensions/tables/onKeyDown.ts | 18 ++++++------- .../components/UserMentionsDropdown.tsx | 2 +- .../components/VariablesDropdown.tsx | 2 +- .../src/lib/encodeSlateFragment.ts | 2 +- .../modules/editor/getEnabledExtensions.ts | 6 ++--- .../createDeserialize/createDeserializer.ts | 2 +- .../createElementsDeserializer.ts | 2 +- .../createMarksDeserializer.ts | 7 +++--- .../createTextDeserializer.ts | 2 +- .../deserializeHtml/deserializeHtml.ts | 2 +- .../nodes-hierarchy/fixers/insertTextNode.ts | 6 ++--- .../nodes-hierarchy/fixers/removeNode.ts | 11 ++++---- .../normilizers/disallowMark.ts | 6 ++--- .../src/modules/nodes-hierarchy/types.ts | 8 +++--- .../rich-formatting-menu/lib/useRangeRef.ts | 2 +- .../src/modules/rich-formatting-menu/types.ts | 2 +- packages/slate-lists/src/lib/getListType.ts | 5 ++-- .../src/lib/isContainingTextNodes.ts | 5 ++-- .../slate-lists/src/lib/pickSubtreesRoots.ts | 9 +++---- .../slate-tables/src/core/Matrix/Matrix.ts | 2 +- .../src/core/Matrix/MatrixCell.ts | 2 +- .../slate-tables/src/core/Matrix/MatrixRow.ts | 2 +- .../src/core/Matrix/createGridWithSpans.ts | 7 +++--- .../src/core/Traverse/Traverse.ts | 16 +++++------- packages/slate-tables/src/core/onKeyDown.ts | 12 ++++----- .../src/core/withTablesDeleteBehavior.ts | 9 +++---- .../src/normalization/insertMissingCells.ts | 15 ++++++----- .../src/normalization/removeEmptyRows.ts | 11 ++++---- .../src/normalization/splitColSpanCells.ts | 15 ++++++----- .../src/normalization/splitRowSpanCells.ts | 25 +++++++++---------- .../src/queries/findParentCell.ts | 6 ++--- .../src/queries/findParentTable.ts | 6 ++--- .../slate-tables/src/queries/isInTable.ts | 5 ++-- 52 files changed, 147 insertions(+), 162 deletions(-) diff --git a/packages/slate-commons/src/commands/findDescendants.ts b/packages/slate-commons/src/commands/findDescendants.ts index 3e6139dd6..b4b88d564 100644 --- a/packages/slate-commons/src/commands/findDescendants.ts +++ b/packages/slate-commons/src/commands/findDescendants.ts @@ -1,10 +1,9 @@ -import type { Descendant, NodeEntry, Path } from 'slate'; -import { Node } from 'slate'; +import { type Descendant, type Node, NodeApi, type NodeEntry, type Path } from '@udecode/plate'; export function findDescendants( node: N, match: (descendant: Descendant, path: Path) => boolean, ): NodeEntry[] { - const descendants = Array.from(Node.descendants(node)); + const descendants = Array.from(NodeApi.descendants(node)); return descendants.filter(([element, path]) => match(element, path)); } diff --git a/packages/slate-commons/src/commands/isBlockActive.ts b/packages/slate-commons/src/commands/isBlockActive.ts index e6177837d..fd1d13206 100644 --- a/packages/slate-commons/src/commands/isBlockActive.ts +++ b/packages/slate-commons/src/commands/isBlockActive.ts @@ -1,11 +1,14 @@ import type { ElementNode } from '@prezly/slate-types'; import { isElementNode } from '@prezly/slate-types'; -import type { Location } from 'slate'; -import { Editor } from 'slate'; +import { type Location, type SlateEditor } from '@udecode/plate'; -export function isBlockActive(editor: Editor, type: ElementNode['type'], at?: Location): boolean { +export function isBlockActive( + editor: SlateEditor, + type: ElementNode['type'], + at?: Location, +): boolean { const [match] = Array.from( - Editor.nodes(editor, { + editor.api.nodes({ match: (node) => isElementNode(node, type), at, }), diff --git a/packages/slate-commons/src/commands/isTopLevelNode.ts b/packages/slate-commons/src/commands/isTopLevelNode.ts index f47f89660..1b08f39db 100644 --- a/packages/slate-commons/src/commands/isTopLevelNode.ts +++ b/packages/slate-commons/src/commands/isTopLevelNode.ts @@ -1,4 +1,4 @@ -import type { Node, Path } from 'slate'; +import { type Node, type Path } from '@udecode/plate'; export function isTopLevelNode(_node: Node, path: Path): boolean { return path.length === 1; diff --git a/packages/slate-commons/src/commands/isTopLevelNodeSelected.ts b/packages/slate-commons/src/commands/isTopLevelNodeSelected.ts index 53b83c3d0..ae015010c 100644 --- a/packages/slate-commons/src/commands/isTopLevelNodeSelected.ts +++ b/packages/slate-commons/src/commands/isTopLevelNodeSelected.ts @@ -1,5 +1,4 @@ -import type { Node } from 'slate'; -import { Editor } from 'slate'; +import { type Editor, type Node } from '@udecode/plate'; import { isTopLevelNode } from './isTopLevelNode'; @@ -11,7 +10,7 @@ export function isTopLevelNodeSelected( const selection = editor.selection; if (!selection) return false; - const selectedNodes = Array.from(Editor.nodes(editor, { match: isTopLevelNode })); + const selectedNodes = Array.from(editor.api.nodes({ match: isTopLevelNode })); for (const [selectedNode] of selectedNodes) { if (selectedNode === node) { diff --git a/packages/slate-commons/src/commands/unsetMark.ts b/packages/slate-commons/src/commands/unsetMark.ts index 316125896..e65bd7619 100644 --- a/packages/slate-commons/src/commands/unsetMark.ts +++ b/packages/slate-commons/src/commands/unsetMark.ts @@ -1,7 +1,7 @@ -import type { NodeEntry, SlateEditor, Text } from '@udecode/plate'; +import { type Editor, type NodeEntry, type Text } from '@udecode/plate'; export function unsetMark( - editor: SlateEditor, + editor: Editor, entry: NodeEntry, mark: keyof Omit, ) { diff --git a/packages/slate-commons/src/lib/createDeserializeElement.ts b/packages/slate-commons/src/lib/createDeserializeElement.ts index b95a7a773..c125044b0 100644 --- a/packages/slate-commons/src/lib/createDeserializeElement.ts +++ b/packages/slate-commons/src/lib/createDeserializeElement.ts @@ -1,4 +1,4 @@ -import type { Node } from 'slate'; +import { type Node } from '@udecode/plate'; type Parse = (serialized: string) => E | undefined; diff --git a/packages/slate-commons/src/lib/withoutNodes.ts b/packages/slate-commons/src/lib/withoutNodes.ts index 14d85f8b4..7bafb8e60 100644 --- a/packages/slate-commons/src/lib/withoutNodes.ts +++ b/packages/slate-commons/src/lib/withoutNodes.ts @@ -1,5 +1,4 @@ -import type { Node } from 'slate'; -import { Text } from 'slate'; +import { type Node, TextApi } from '@udecode/plate'; export function withoutNodes(nodes: T[], match: (node: Node) => boolean): T[] { return nodes @@ -7,7 +6,7 @@ export function withoutNodes(nodes: T[], match: (node: Node) => if (match(node)) { return null; } - if (Text.isText(node)) { + if (TextApi.isText(node)) { return node; } return { ...node, children: withoutNodes(node.children, match) }; diff --git a/packages/slate-commons/src/selection/highest.ts b/packages/slate-commons/src/selection/highest.ts index 8dcbbb187..00dc50285 100644 --- a/packages/slate-commons/src/selection/highest.ts +++ b/packages/slate-commons/src/selection/highest.ts @@ -1,14 +1,20 @@ -import type { Location, Range } from 'slate'; -import { Path, Point } from 'slate'; +import { + type Location, + type Path, + PathApi, + type Point, + PointApi, + type Range, +} from '@udecode/plate'; export function highest(selection: Path): Path; export function highest(selection: Point): Path; export function highest(selection: Range): Path; export function highest(selection: Location): Path { - if (Path.isPath(selection)) { + if (PathApi.isPath(selection)) { return selection.slice(0, 1) as Path; } - if (Point.isPoint(selection)) { + if (PointApi.isPoint(selection)) { return highest(selection.path); } return highest(selection.focus); diff --git a/packages/slate-commons/src/types/Extension.ts b/packages/slate-commons/src/types/Extension.ts index 265b73ff7..00bbd2c73 100644 --- a/packages/slate-commons/src/types/Extension.ts +++ b/packages/slate-commons/src/types/Extension.ts @@ -1,4 +1,4 @@ -import type { Node } from 'slate'; +import { type Node } from '@udecode/plate'; import type { DecorateFactory } from './DecorateFactory'; import type { DeserializeHtml } from './DeserializeHtml'; diff --git a/packages/slate-editor/src/extensions/allowed-blocks/types.ts b/packages/slate-editor/src/extensions/allowed-blocks/types.ts index d9f40ba9c..f5c3b2e47 100644 --- a/packages/slate-editor/src/extensions/allowed-blocks/types.ts +++ b/packages/slate-editor/src/extensions/allowed-blocks/types.ts @@ -1,4 +1,4 @@ -import type { Node, Path } from 'slate'; +import { type Node, type Path } from '@udecode/plate'; export interface AllowedBlocksExtensionConfiguration { /** diff --git a/packages/slate-editor/src/extensions/heading/HeadingExtension.tsx b/packages/slate-editor/src/extensions/heading/HeadingExtension.tsx index 6238cb72f..788873906 100644 --- a/packages/slate-editor/src/extensions/heading/HeadingExtension.tsx +++ b/packages/slate-editor/src/extensions/heading/HeadingExtension.tsx @@ -8,8 +8,8 @@ import { isSubtitleHeadingNode, isTitleHeadingNode, } from '@prezly/slate-types'; +import { type Node } from '@udecode/plate'; import React from 'react'; -import type { Node } from 'slate'; import { onBackspaceResetFormattingAtDocumentStart, withResetFormattingOnBreak } from '#lib'; diff --git a/packages/slate-editor/src/extensions/inline-links/lib/autolinkPlaintext.ts b/packages/slate-editor/src/extensions/inline-links/lib/autolinkPlaintext.ts index eb6713633..9be32dfb6 100644 --- a/packages/slate-editor/src/extensions/inline-links/lib/autolinkPlaintext.ts +++ b/packages/slate-editor/src/extensions/inline-links/lib/autolinkPlaintext.ts @@ -1,4 +1,4 @@ -import type { Node } from 'slate'; +import { type Node } from '@udecode/plate'; import validator from 'validator'; import { matchUrls } from '#lib'; diff --git a/packages/slate-editor/src/extensions/mentions/MentionsExtension.ts b/packages/slate-editor/src/extensions/mentions/MentionsExtension.ts index 4f5242cc0..e711d92ed 100644 --- a/packages/slate-editor/src/extensions/mentions/MentionsExtension.ts +++ b/packages/slate-editor/src/extensions/mentions/MentionsExtension.ts @@ -1,7 +1,6 @@ import type { Extension } from '@prezly/slate-commons'; import { createDeserializeElement } from '@prezly/slate-commons'; -import type { Node } from 'slate'; -import { Element } from 'slate'; +import { ElementApi, type Node } from '@udecode/plate'; import { composeElementDeserializer } from '#modules/html-deserialization'; @@ -23,7 +22,7 @@ export function MentionsExtension({ type, }: Options): Extension { function isMention(node: Node) { - return Element.isElementType(node, type); + return ElementApi.isElementType(node, type); } return { diff --git a/packages/slate-editor/src/extensions/placeholders/lib/removePlaceholder.ts b/packages/slate-editor/src/extensions/placeholders/lib/removePlaceholder.ts index 912ceef42..adc0ffbc3 100644 --- a/packages/slate-editor/src/extensions/placeholders/lib/removePlaceholder.ts +++ b/packages/slate-editor/src/extensions/placeholders/lib/removePlaceholder.ts @@ -1,10 +1,9 @@ -import type { Editor } from 'slate'; -import { Transforms } from 'slate'; +import { type Editor } from '@udecode/plate'; import { PlaceholderNode } from '../PlaceholderNode'; export function removePlaceholder(editor: Editor, placeholder: PlaceholderNode): void { - Transforms.removeNodes(editor, { + editor.tf.removeNodes({ match: (node) => PlaceholderNode.isPlaceholderNode(node) && node.type === placeholder.type && diff --git a/packages/slate-editor/src/extensions/placeholders/types.ts b/packages/slate-editor/src/extensions/placeholders/types.ts index 9f9fa411a..1b9384926 100644 --- a/packages/slate-editor/src/extensions/placeholders/types.ts +++ b/packages/slate-editor/src/extensions/placeholders/types.ts @@ -1,5 +1,5 @@ import type { NewsroomRef, OEmbedInfo } from '@prezly/sdk'; -import type { Path } from 'slate'; +import { type Path } from '@udecode/plate'; import type { PlaceholderNode } from './PlaceholderNode'; diff --git a/packages/slate-editor/src/extensions/tables/TablesExtension.tsx b/packages/slate-editor/src/extensions/tables/TablesExtension.tsx index d79cf124a..767a371b3 100644 --- a/packages/slate-editor/src/extensions/tables/TablesExtension.tsx +++ b/packages/slate-editor/src/extensions/tables/TablesExtension.tsx @@ -15,9 +15,8 @@ import { isTableCellNode, } from '@prezly/slate-types'; import { flow } from '@technically/lodash'; +import { type Element, type RenderElementProps } from '@udecode/plate'; import React from 'react'; -import type { Element } from 'slate'; -import type { RenderElementProps } from 'slate-react'; import { composeElementDeserializer } from '#modules/html-deserialization'; diff --git a/packages/slate-editor/src/extensions/tables/components/elements/TableCellElement.tsx b/packages/slate-editor/src/extensions/tables/components/elements/TableCellElement.tsx index 61ea612ba..466511428 100644 --- a/packages/slate-editor/src/extensions/tables/components/elements/TableCellElement.tsx +++ b/packages/slate-editor/src/extensions/tables/components/elements/TableCellElement.tsx @@ -1,8 +1,8 @@ import { TablesEditor } from '@prezly/slate-tables'; import type { TableCellNode } from '@prezly/slate-types'; +import { type RenderElementProps } from '@udecode/plate'; import classNames from 'classnames'; import React from 'react'; -import type { RenderElementProps } from 'slate-react'; import styles from './elements.module.scss'; import { TableContext } from './TableContext'; diff --git a/packages/slate-editor/src/extensions/tables/components/elements/TableElement.tsx b/packages/slate-editor/src/extensions/tables/components/elements/TableElement.tsx index 1446ee70a..5af1fe929 100644 --- a/packages/slate-editor/src/extensions/tables/components/elements/TableElement.tsx +++ b/packages/slate-editor/src/extensions/tables/components/elements/TableElement.tsx @@ -1,7 +1,7 @@ import type { TableNode } from '@prezly/slate-types'; +import { type RenderElementProps } from '@udecode/plate'; import classNames from 'classnames'; import React from 'react'; -import type { RenderElementProps } from 'slate-react'; import { EditorBlock } from '#components'; diff --git a/packages/slate-editor/src/extensions/tables/components/elements/TableRowElement.tsx b/packages/slate-editor/src/extensions/tables/components/elements/TableRowElement.tsx index f19b7ed20..dd3766665 100644 --- a/packages/slate-editor/src/extensions/tables/components/elements/TableRowElement.tsx +++ b/packages/slate-editor/src/extensions/tables/components/elements/TableRowElement.tsx @@ -1,6 +1,6 @@ import type { TableRowNode } from '@prezly/slate-types'; +import { type RenderElementProps } from '@udecode/plate'; import React from 'react'; -import type { RenderElementProps } from 'slate-react'; import styles from './elements.module.scss'; diff --git a/packages/slate-editor/src/extensions/tables/onKeyDown.ts b/packages/slate-editor/src/extensions/tables/onKeyDown.ts index c1e1754dd..3fe04c28c 100644 --- a/packages/slate-editor/src/extensions/tables/onKeyDown.ts +++ b/packages/slate-editor/src/extensions/tables/onKeyDown.ts @@ -1,7 +1,7 @@ import { TablesEditor } from '@prezly/slate-tables'; +import { type Element, RangeApi } from '@udecode/plate'; import { isHotkey } from 'is-hotkey'; import type { KeyboardEvent } from 'react'; -import { type Element, Range } from 'slate'; const isClipboardCopy = isHotkey(['mod+c', 'ctrl+insert']); const isClipboardCut = isHotkey(['mod+x', 'shift+delete']); @@ -13,7 +13,7 @@ export function onClipboardHotkey( ) { const selection = editor.selection; - if (!selection || Range.isExpanded(selection)) return; + if (!selection || RangeApi.isExpanded(selection)) return; if (isClipboardCopy(event)) { const entry = TablesEditor.findParentTable(editor, selection); @@ -22,7 +22,7 @@ export function onClipboardHotkey( } const [, path] = entry; - editor.select(path); // Select the table + editor.tf.select(path); // Select the table document.execCommand('copy'); @@ -36,16 +36,16 @@ export function onClipboardHotkey( } const [, path] = entry; - editor.withoutNormalizing(() => { - editor.select(path); // Select the table - const ref = editor.pathRef(path); + editor.tf.withoutNormalizing(() => { + editor.tf.select(path); // Select the table + const ref = editor.api.pathRef(path); if (document.execCommand('cut')) { - editor.insertNodes(createDefaultElement(), { at: path }); + editor.tf.insertNodes(createDefaultElement(), { at: path }); if (ref.current) { - editor.removeNodes({ at: ref.current }); + editor.tf.removeNodes({ at: ref.current }); } - editor.select(path); + editor.tf.select(path); } ref.unref(); diff --git a/packages/slate-editor/src/extensions/user-mentions/components/UserMentionsDropdown.tsx b/packages/slate-editor/src/extensions/user-mentions/components/UserMentionsDropdown.tsx index abe7686d6..47c368aae 100644 --- a/packages/slate-editor/src/extensions/user-mentions/components/UserMentionsDropdown.tsx +++ b/packages/slate-editor/src/extensions/user-mentions/components/UserMentionsDropdown.tsx @@ -1,5 +1,5 @@ +import { type Range } from '@udecode/plate'; import React from 'react'; -import type { Range } from 'slate'; import { Avatar } from '#components'; diff --git a/packages/slate-editor/src/extensions/variables/components/VariablesDropdown.tsx b/packages/slate-editor/src/extensions/variables/components/VariablesDropdown.tsx index 833f17cf3..49294dcd8 100644 --- a/packages/slate-editor/src/extensions/variables/components/VariablesDropdown.tsx +++ b/packages/slate-editor/src/extensions/variables/components/VariablesDropdown.tsx @@ -1,5 +1,5 @@ +import { type Range } from '@udecode/plate'; import React from 'react'; -import type { Range } from 'slate'; import type { Option } from '#extensions/mentions'; import { MentionsDropdown } from '#extensions/mentions'; diff --git a/packages/slate-editor/src/lib/encodeSlateFragment.ts b/packages/slate-editor/src/lib/encodeSlateFragment.ts index c02448c5c..aa28cf743 100644 --- a/packages/slate-editor/src/lib/encodeSlateFragment.ts +++ b/packages/slate-editor/src/lib/encodeSlateFragment.ts @@ -1,4 +1,4 @@ -import type { Node } from 'slate'; +import { type Node } from '@udecode/plate'; export function encodeSlateFragment(fragment: Node[]): string { return window.btoa(encodeURIComponent(JSON.stringify(fragment))); diff --git a/packages/slate-editor/src/modules/editor/getEnabledExtensions.ts b/packages/slate-editor/src/modules/editor/getEnabledExtensions.ts index 2e33fa87c..d6e30d6dd 100644 --- a/packages/slate-editor/src/modules/editor/getEnabledExtensions.ts +++ b/packages/slate-editor/src/modules/editor/getEnabledExtensions.ts @@ -2,7 +2,7 @@ import { EditorCommands, type Extension } from '@prezly/slate-commons'; import { TablesEditor } from '@prezly/slate-tables'; import type { Alignment } from '@prezly/slate-types'; import { CalloutNode, isImageNode, isQuoteNode } from '@prezly/slate-types'; -import { Node } from 'slate'; +import { NodeApi } from '@udecode/plate'; import { AllowedBlocksExtension } from '#extensions/allowed-blocks'; import { BlockquoteExtension } from '#extensions/blockquote'; @@ -312,7 +312,7 @@ export function* getEnabledExtensions(parameters: Parameters): Generator Descendant[]; @@ -20,12 +19,12 @@ export function createMarksDeserializer(deserialize: DeserializeMarks): MarksDes * Recursively apply the given style marks to all descendant Text nodes. */ function applyStylingProps(node: T, styles: Record): T { - if (Text.isText(node)) { + if (TextApi.isText(node)) { const { text, ...props } = node; return { ...props, ...styles, text } as T; } - if (Element.isElement(node)) { + if (ElementApi.isElement(node)) { const { children, ...props } = node; return { diff --git a/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/createDeserialize/createTextDeserializer.ts b/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/createDeserialize/createTextDeserializer.ts index 0afa75957..2093ed6a7 100644 --- a/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/createDeserialize/createTextDeserializer.ts +++ b/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/createDeserialize/createTextDeserializer.ts @@ -1,4 +1,4 @@ -import type { Text } from 'slate'; +import { type Text } from '@udecode/plate'; import type { HTMLText } from './dom'; diff --git a/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/deserializeHtml/deserializeHtml.ts b/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/deserializeHtml/deserializeHtml.ts index ac201775d..9d9ed01a8 100644 --- a/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/deserializeHtml/deserializeHtml.ts +++ b/packages/slate-editor/src/modules/editor/plugins/withDeserializeHtml/deserializeHtml/deserializeHtml.ts @@ -1,5 +1,5 @@ import type { Extension } from '@prezly/slate-commons'; -import type { Descendant } from 'slate'; +import { type Descendant } from '@udecode/plate'; import { createDeserializer } from '../createDeserialize'; import { diff --git a/packages/slate-editor/src/modules/nodes-hierarchy/fixers/insertTextNode.ts b/packages/slate-editor/src/modules/nodes-hierarchy/fixers/insertTextNode.ts index d311521b5..99a6d8ec6 100644 --- a/packages/slate-editor/src/modules/nodes-hierarchy/fixers/insertTextNode.ts +++ b/packages/slate-editor/src/modules/nodes-hierarchy/fixers/insertTextNode.ts @@ -1,8 +1,6 @@ -import { Transforms } from 'slate'; -import type { NodeEntry } from 'slate'; -import type { Editor } from 'slate'; +import { type Editor, type NodeEntry } from '@udecode/plate'; export function insertTextNode(editor: Editor, [node, path]: NodeEntry) { - Transforms.insertNodes(editor, [{ text: '' }], { at: path, match: (n) => n === node }); + editor.tf.insertNodes([{ text: '' }], { at: path, match: (n) => n === node }); return true; } diff --git a/packages/slate-editor/src/modules/nodes-hierarchy/fixers/removeNode.ts b/packages/slate-editor/src/modules/nodes-hierarchy/fixers/removeNode.ts index 0d290cc5f..840a232a5 100644 --- a/packages/slate-editor/src/modules/nodes-hierarchy/fixers/removeNode.ts +++ b/packages/slate-editor/src/modules/nodes-hierarchy/fixers/removeNode.ts @@ -1,9 +1,8 @@ -import { Editor, Element, Path, Transforms } from 'slate'; -import type { NodeEntry } from 'slate'; +import { type Editor, ElementApi, type NodeEntry, PathApi } from '@udecode/plate'; export function removeNode(editor: Editor, [, path]: NodeEntry) { - const targetPath = Path.parent(path); - const ancestor = Editor.above(editor, { at: targetPath }); + const targetPath = PathApi.parent(path); + const ancestor = editor.api.above({ at: targetPath }); if (!ancestor) { return false; @@ -11,11 +10,11 @@ export function removeNode(editor: Editor, [, path]: NodeEntry) { const [ancestorNode] = ancestor; - if (!Element.isElement(ancestorNode)) { + if (!ElementApi.isElement(ancestorNode)) { return false; } - Transforms.removeNodes(editor, { at: targetPath, voids: true }); + editor.tf.removeNodes({ at: targetPath, voids: true }); return true; } diff --git a/packages/slate-editor/src/modules/nodes-hierarchy/normilizers/disallowMark.ts b/packages/slate-editor/src/modules/nodes-hierarchy/normilizers/disallowMark.ts index 07ac3ba32..bdbd7cccf 100644 --- a/packages/slate-editor/src/modules/nodes-hierarchy/normilizers/disallowMark.ts +++ b/packages/slate-editor/src/modules/nodes-hierarchy/normilizers/disallowMark.ts @@ -1,6 +1,6 @@ import { EditorCommands } from '@prezly/slate-commons'; import type { TextNode } from '@prezly/slate-types'; -import { Text } from 'slate'; +import { TextApi } from '@udecode/plate'; import type { HierarchyNormalizer, HierarchyNodeQuery } from '../types'; @@ -9,7 +9,7 @@ export function disallowMark( match: HierarchyNodeQuery, ): HierarchyNormalizer { return (editor, node, path) => { - if (Text.isText(node)) { + if (TextApi.isText(node)) { if (!node[mark]) { return false; } @@ -18,7 +18,7 @@ export function disallowMark( return false; } - return EditorCommands.unsetMark(editor, [node, path], mark); + return EditorCommands.unsetMark(editor, [node, path], mark as string); } return false; diff --git a/packages/slate-editor/src/modules/nodes-hierarchy/types.ts b/packages/slate-editor/src/modules/nodes-hierarchy/types.ts index a9ff03622..a84f30361 100644 --- a/packages/slate-editor/src/modules/nodes-hierarchy/types.ts +++ b/packages/slate-editor/src/modules/nodes-hierarchy/types.ts @@ -1,8 +1,8 @@ -import type { Node, NodeEntry, Path, SlateEditor } from '@udecode/plate'; +import type { Editor, Node, NodeEntry, Path } from '@udecode/plate'; -export type HierarchyNodeQuery = (node: Node, path: Path, editor: SlateEditor) => boolean; -export type HierarchyNormalizer = (editor: SlateEditor, node: Node, path: Path) => boolean; -export type HierarchyFixer = (editor: SlateEditor, entry: NodeEntry) => boolean; +export type HierarchyNodeQuery = (node: Node, path: Path, editor: Editor) => boolean; +export type HierarchyNormalizer = (editor: Editor, node: Node, path: Path) => boolean; +export type HierarchyFixer = (editor: Editor, entry: NodeEntry) => boolean; export const EDITOR_NODE_TYPE = Symbol('EDITOR'); export const TEXT_NODE_TYPE = Symbol('TEXT'); diff --git a/packages/slate-editor/src/modules/rich-formatting-menu/lib/useRangeRef.ts b/packages/slate-editor/src/modules/rich-formatting-menu/lib/useRangeRef.ts index f225e1378..c2ac6289f 100644 --- a/packages/slate-editor/src/modules/rich-formatting-menu/lib/useRangeRef.ts +++ b/packages/slate-editor/src/modules/rich-formatting-menu/lib/useRangeRef.ts @@ -1,5 +1,5 @@ +import { type RangeRef } from '@udecode/plate'; import { useState } from 'react'; -import type { RangeRef } from 'slate'; type Value = RangeRef | null; diff --git a/packages/slate-editor/src/modules/rich-formatting-menu/types.ts b/packages/slate-editor/src/modules/rich-formatting-menu/types.ts index e300146f5..184ca6c82 100644 --- a/packages/slate-editor/src/modules/rich-formatting-menu/types.ts +++ b/packages/slate-editor/src/modules/rich-formatting-menu/types.ts @@ -16,7 +16,7 @@ import { isTableRowNode, isTableCellNode, } from '@prezly/slate-types'; -import type { Node } from 'slate'; +import { type Node } from '@udecode/plate'; export type FetchOEmbedFn = (url: string) => Promise; diff --git a/packages/slate-lists/src/lib/getListType.ts b/packages/slate-lists/src/lib/getListType.ts index f743d9479..f29db5151 100644 --- a/packages/slate-lists/src/lib/getListType.ts +++ b/packages/slate-lists/src/lib/getListType.ts @@ -1,5 +1,4 @@ -import type { Node } from 'slate'; -import { Element } from 'slate'; +import { ElementApi, type Node } from '@udecode/plate'; import type { ListsSchema } from '../types'; import { ListType } from '../types'; @@ -8,7 +7,7 @@ import { ListType } from '../types'; * Returns the "type" of a given list node. */ export function getListType(schema: ListsSchema, node: Node): ListType { - const isElement = Element.isElement(node); + const isElement = ElementApi.isElement(node); if (isElement && schema.isListNode(node, ListType.ORDERED)) { return ListType.ORDERED; diff --git a/packages/slate-lists/src/lib/isContainingTextNodes.ts b/packages/slate-lists/src/lib/isContainingTextNodes.ts index 21b928d32..c2ffbe16e 100644 --- a/packages/slate-lists/src/lib/isContainingTextNodes.ts +++ b/packages/slate-lists/src/lib/isContainingTextNodes.ts @@ -1,6 +1,5 @@ -import type { Element } from 'slate'; -import { Text } from 'slate'; +import { type Element, TextApi } from '@udecode/plate'; export function isContainingTextNodes(element: Element): boolean { - return element.children.some(Text.isText); + return element.children.some(TextApi.isText); } diff --git a/packages/slate-lists/src/lib/pickSubtreesRoots.ts b/packages/slate-lists/src/lib/pickSubtreesRoots.ts index f85b6b6ca..e6b969cbf 100644 --- a/packages/slate-lists/src/lib/pickSubtreesRoots.ts +++ b/packages/slate-lists/src/lib/pickSubtreesRoots.ts @@ -1,5 +1,4 @@ -import type { Node, NodeEntry } from 'slate'; -import { Path } from 'slate'; +import { type NodeEntry, PathApi } from '@udecode/plate'; /** * Will return a minimal subset of the given nodes that includes the rest of the given nodes as descendants. @@ -26,12 +25,12 @@ import { Path } from 'slate'; * A and B are the subtree roots that include every other node: * - pickSubtreesRoots([A, A1, A2, A3, A31, B, B1, B2, B3, B31]) === [A, B] */ -export function pickSubtreesRoots(entries: NodeEntry[]): NodeEntry[] { +export function pickSubtreesRoots(entries: NodeEntry[]): NodeEntry[] { return entries.filter(([, nodePath]) => { - const ancestors = Path.ancestors(nodePath); + const ancestors = PathApi.ancestors(nodePath); return !ancestors.some((ancestor) => { - return entries.some(([, path]) => Path.equals(path, ancestor)); + return entries.some(([, path]) => PathApi.equals(path, ancestor)); }); }); } diff --git a/packages/slate-tables/src/core/Matrix/Matrix.ts b/packages/slate-tables/src/core/Matrix/Matrix.ts index 67e935dfb..b1f306962 100644 --- a/packages/slate-tables/src/core/Matrix/Matrix.ts +++ b/packages/slate-tables/src/core/Matrix/Matrix.ts @@ -1,4 +1,4 @@ -import type { NodeEntry } from 'slate'; +import { type NodeEntry } from '@udecode/plate'; import type { TableNode } from '../../nodes'; import type { TablesEditor } from '../../TablesEditor'; diff --git a/packages/slate-tables/src/core/Matrix/MatrixCell.ts b/packages/slate-tables/src/core/Matrix/MatrixCell.ts index 0e3ec024e..47ea699ce 100644 --- a/packages/slate-tables/src/core/Matrix/MatrixCell.ts +++ b/packages/slate-tables/src/core/Matrix/MatrixCell.ts @@ -1,4 +1,4 @@ -import type { NodeEntry } from 'slate'; +import { type NodeEntry } from '@udecode/plate'; import { TableCellNode } from '../../nodes'; import { compareNumbers } from '../../utils/comparators'; diff --git a/packages/slate-tables/src/core/Matrix/MatrixRow.ts b/packages/slate-tables/src/core/Matrix/MatrixRow.ts index 9d87a2ee0..f668cb7bb 100644 --- a/packages/slate-tables/src/core/Matrix/MatrixRow.ts +++ b/packages/slate-tables/src/core/Matrix/MatrixRow.ts @@ -1,4 +1,4 @@ -import type { NodeEntry } from 'slate'; +import { type NodeEntry } from '@udecode/plate'; import type { TableRowNode } from '../../nodes'; diff --git a/packages/slate-tables/src/core/Matrix/createGridWithSpans.ts b/packages/slate-tables/src/core/Matrix/createGridWithSpans.ts index 90ac7b84f..3fda96fae 100644 --- a/packages/slate-tables/src/core/Matrix/createGridWithSpans.ts +++ b/packages/slate-tables/src/core/Matrix/createGridWithSpans.ts @@ -1,5 +1,4 @@ -import type { NodeEntry } from 'slate'; -import { Node } from 'slate'; +import { NodeApi, type NodeEntry } from '@udecode/plate'; import type { TableNode } from '../../nodes'; import { type TableRowNode, TableCellNode } from '../../nodes'; @@ -18,7 +17,7 @@ export interface GridWithSpansCell { export function createGridWithSpans(editor: TablesEditor, [, tablePath]: NodeEntry) { const grid: GridWithSpansRow[] = []; - const rows = Array.from(Node.children(editor, tablePath)); + const rows = Array.from(NodeApi.children(editor, tablePath)); let rowIdx = 0; rows.forEach(([row, rowPath]) => { @@ -26,7 +25,7 @@ export function createGridWithSpans(editor: TablesEditor, [, tablePath]: NodeEnt return; } - const cells = Array.from(Node.children(editor, rowPath)); + const cells = Array.from(NodeApi.children(editor, rowPath)); let colIdx = 0; cells.forEach(([cell, cellPath]) => { diff --git a/packages/slate-tables/src/core/Traverse/Traverse.ts b/packages/slate-tables/src/core/Traverse/Traverse.ts index 837de7f50..48562cc47 100644 --- a/packages/slate-tables/src/core/Traverse/Traverse.ts +++ b/packages/slate-tables/src/core/Traverse/Traverse.ts @@ -1,5 +1,4 @@ -import type { Location, NodeEntry } from 'slate'; -import { Node } from 'slate'; +import { NodeApi, type Location, type NodeEntry } from '@udecode/plate'; import type { MatrixRow, MatrixColumn, MatrixCell } from '../../core'; import { Matrix } from '../../core'; @@ -29,17 +28,14 @@ export class Traverse { return undefined; } - const cellPath = editor.path(cellLocation); - const ancestors = Node.ancestors(editor, cellPath, { reverse: true }); + const cellPath = editor.api.path(cellLocation); + const ancestors = NodeApi.ancestors(editor, cellPath, { reverse: true }); - const cellNode = Node.get(editor, cellPath); + const cellNode = NodeApi.get(editor, cellPath); let currentTableEntry: NodeEntry | undefined = undefined; let currentRowEntry: NodeEntry | undefined = undefined; - let currentCellEntry: NodeEntry | undefined = editor.isTableCellNode( - cellNode, - ) - ? [cellNode, cellPath] - : undefined; + let currentCellEntry: NodeEntry | undefined = + cellNode && editor.isTableCellNode(cellNode) ? [cellNode, cellPath] : undefined; for (const [node, path] of ancestors) { if (editor.isTableNode(node)) { diff --git a/packages/slate-tables/src/core/onKeyDown.ts b/packages/slate-tables/src/core/onKeyDown.ts index 3138189c8..100626737 100644 --- a/packages/slate-tables/src/core/onKeyDown.ts +++ b/packages/slate-tables/src/core/onKeyDown.ts @@ -1,7 +1,7 @@ import { EditorCommands } from '@prezly/slate-commons'; +import { type Location, type Point } from '@udecode/plate'; import { isHotkey } from 'is-hotkey'; import type { KeyboardEvent } from 'react'; -import { type Location, type Point } from 'slate'; import { TablesEditor } from '../TablesEditor'; @@ -27,7 +27,7 @@ export function onKeyDown(event: KeyboardEvent, editor: TablesEditor) { } if (locationToSelect) { - editor.select(locationToSelect); + editor.tf.select(locationToSelect); return true; } @@ -47,7 +47,7 @@ function onUpPress(editor: TablesEditor): Point | undefined { const { activeCell, matrix } = traverse; - const cellStart = editor.start(activeCell.path); + const cellStart = editor.api.start(activeCell.path); const isCursorOnFirstLine = EditorCommands.isCursorOnFirstLine( editor, @@ -57,7 +57,7 @@ function onUpPress(editor: TablesEditor): Point | undefined { if (isCursorOnFirstLine) { if (activeCell.row.isFirst) { - return editor.before(matrix.path, { unit: 'block' }); + return editor.api.before(matrix.path, { unit: 'block' }); } const { cellAbove } = activeCell; @@ -90,7 +90,7 @@ function onDownPress(editor: TablesEditor): Point | undefined { const { activeCell, matrix } = traverse; - const cellEnd = editor.end(activeCell.path); + const cellEnd = editor.api.end(activeCell.path); const isCursorOnLastLine = EditorCommands.isCursorOnLastLine( editor, @@ -100,7 +100,7 @@ function onDownPress(editor: TablesEditor): Point | undefined { if (isCursorOnLastLine) { if (activeCell.row.isLast) { - return editor.after(matrix.path, { unit: 'block' }); + return editor.api.after(matrix.path, { unit: 'block' }); } const { cellBelow } = activeCell; diff --git a/packages/slate-tables/src/core/withTablesDeleteBehavior.ts b/packages/slate-tables/src/core/withTablesDeleteBehavior.ts index 98d7dce41..354ed5c7f 100644 --- a/packages/slate-tables/src/core/withTablesDeleteBehavior.ts +++ b/packages/slate-tables/src/core/withTablesDeleteBehavior.ts @@ -1,5 +1,4 @@ -import type { Location } from 'slate'; -import { Range, Point } from 'slate'; +import { type Location, type Point, PointApi, RangeApi } from '@udecode/plate'; import type { TablesEditor } from '../TablesEditor'; @@ -25,8 +24,8 @@ function canDeleteInTableCell( editor: T, getEdgePoint: (at: Location) => Point, ) { - if (editor.selection && Range.isCollapsed(editor.selection)) { - const [cell] = editor.nodes({ + if (editor.selection && RangeApi.isCollapsed(editor.selection)) { + const [cell] = editor.api.nodes({ match: editor.isTableCellNode, }); @@ -34,7 +33,7 @@ function canDeleteInTableCell( const [, cellPath] = cell; const edge = getEdgePoint(cellPath); - if (Point.equals(editor.selection.anchor, edge)) { + if (PointApi.equals(editor.selection.anchor, edge)) { return false; } } diff --git a/packages/slate-tables/src/normalization/insertMissingCells.ts b/packages/slate-tables/src/normalization/insertMissingCells.ts index af3cec4fa..4ef369b3b 100644 --- a/packages/slate-tables/src/normalization/insertMissingCells.ts +++ b/packages/slate-tables/src/normalization/insertMissingCells.ts @@ -1,14 +1,13 @@ import { times } from '@technically/lodash'; -import { Node } from 'slate'; -import { Path } from 'slate'; +import { NodeApi, type Path, PathApi } from '@udecode/plate'; import type { TableRowNode } from '../nodes'; import { TablesEditor } from '../TablesEditor'; export function insertMissingCells(editor: TablesEditor, path: Path) { - const table = Node.get(editor, path); + const table = NodeApi.get(editor, path); - if (!editor.isTableNode(table)) { + if (!table || !editor.isTableNode(table)) { return false; } @@ -18,7 +17,7 @@ export function insertMissingCells(editor: TablesEditor, path: Path) { ), ); - for (const [row, rowPath] of Node.children(editor, path)) { + for (const [row, rowPath] of NodeApi.children(editor, path)) { if (editor.isTableRowNode(row)) { const rowSize = calculateRowWidth(row); const absentCellsQuantity = maxWidth - rowSize; @@ -28,14 +27,14 @@ export function insertMissingCells(editor: TablesEditor, path: Path) { TablesEditor.createTableCell(editor), ); - const lastNodeInRowEntry = Array.from(Node.children(editor, rowPath)).at(-1); + const lastNodeInRowEntry = Array.from(NodeApi.children(editor, rowPath)).at(-1); if (lastNodeInRowEntry) { const [lastNode, lastNodePath] = lastNodeInRowEntry; if (editor.isTableCellNode(lastNode)) { - editor.insertNodes(newCells, { - at: Path.next(lastNodePath), + editor.tf.insertNodes(newCells, { + at: PathApi.next(lastNodePath), }); return true; } diff --git a/packages/slate-tables/src/normalization/removeEmptyRows.ts b/packages/slate-tables/src/normalization/removeEmptyRows.ts index 2bd2f18cb..ec2c356ba 100644 --- a/packages/slate-tables/src/normalization/removeEmptyRows.ts +++ b/packages/slate-tables/src/normalization/removeEmptyRows.ts @@ -1,18 +1,17 @@ -import { Node } from 'slate'; -import type { Path } from 'slate'; +import { NodeApi, type Path } from '@udecode/plate'; import type { TablesEditor } from '../TablesEditor'; export function removeEmptyRows(editor: TablesEditor, path: Path) { - const table = Node.get(editor, path); + const table = NodeApi.get(editor, path); - if (!editor.isTableNode(table)) { + if (!table || !editor.isTableNode(table)) { return false; } - for (const [row, rowPath] of Node.children(editor, path)) { + for (const [row, rowPath] of NodeApi.children(editor, path)) { if (editor.isTableRowNode(row) && row.children.length == 0) { - editor.removeNodes({ at: rowPath, match: (n) => n === row }); + editor.tf.removeNodes({ at: rowPath, match: (n) => n === row }); return true; } } diff --git a/packages/slate-tables/src/normalization/splitColSpanCells.ts b/packages/slate-tables/src/normalization/splitColSpanCells.ts index 1ae483293..329aa4201 100644 --- a/packages/slate-tables/src/normalization/splitColSpanCells.ts +++ b/packages/slate-tables/src/normalization/splitColSpanCells.ts @@ -1,23 +1,22 @@ import { times } from '@technically/lodash'; -import { Path } from 'slate'; -import { Node } from 'slate'; +import { NodeApi, type Path, PathApi } from '@udecode/plate'; import { TablesEditor } from '../TablesEditor'; export function splitColSpanCells(editor: TablesEditor, path: Path) { - const node = Node.get(editor, path); + const node = NodeApi.get(editor, path); - if (!editor.isTableRowNode(node)) { + if (!node || !editor.isTableRowNode(node)) { return false; } - for (const [cell, cellPath] of Node.children(editor, path)) { + for (const [cell, cellPath] of NodeApi.children(editor, path)) { if (editor.isTableCellNode(cell) && cell.colspan && cell.colspan > 1) { const padCells = times(cell.colspan - 1, () => TablesEditor.createTableCell(editor)); - editor.withoutNormalizing(() => { - editor.unsetNodes('colspan', { at: cellPath }); - editor.insertNodes(padCells, { at: Path.next(cellPath) }); + editor.tf.withoutNormalizing(() => { + editor.tf.unsetNodes('colspan', { at: cellPath }); + editor.tf.insertNodes(padCells, { at: PathApi.next(cellPath) }); }); return true; diff --git a/packages/slate-tables/src/normalization/splitRowSpanCells.ts b/packages/slate-tables/src/normalization/splitRowSpanCells.ts index 70c503c47..677ed7bf3 100644 --- a/packages/slate-tables/src/normalization/splitRowSpanCells.ts +++ b/packages/slate-tables/src/normalization/splitRowSpanCells.ts @@ -1,37 +1,36 @@ import { times } from '@technically/lodash'; -import { Path } from 'slate'; -import { Node } from 'slate'; +import { NodeApi, type Path, PathApi } from '@udecode/plate'; import { TablesEditor } from '../TablesEditor'; export function splitRowSpanCells(editor: TablesEditor, path: Path) { - const node = Node.get(editor, path); + const node = NodeApi.get(editor, path); - if (!editor.isTableNode(node)) { + if (!node || !editor.isTableNode(node)) { return false; } - for (const [row, rowPath] of Node.children(editor, path)) { + for (const [row, rowPath] of NodeApi.children(editor, path)) { if (!editor.isTableRowNode(row)) { continue; } - for (const [cell, cellPath] of Node.children(editor, rowPath)) { + for (const [cell, cellPath] of NodeApi.children(editor, rowPath)) { if (editor.isTableCellNode(cell) && cell.rowspan && cell.rowspan > 1) { - const currentCellRelativePath = Path.relative(cellPath, rowPath); + const currentCellRelativePath = PathApi.relative(cellPath, rowPath); const padCells = times(cell.rowspan - 1, () => TablesEditor.createTableCell(editor), ); - editor.withoutNormalizing(() => { - editor.unsetNodes('rowspan', { at: cellPath }); - let nextRow = Path.next(rowPath); + editor.tf.withoutNormalizing(() => { + editor.tf.unsetNodes('rowspan', { at: cellPath }); + let nextRow = PathApi.next(rowPath); for (const padCell of padCells) { const at = [...nextRow, ...currentCellRelativePath]; - if (editor.hasPath(at)) { - editor.insertNodes(padCell, { at }); + if (editor.api.hasPath(at)) { + editor.tf.insertNodes(padCell, { at }); } else { console.error( `Can't find path to insert pad cell when split row spans at:`, @@ -39,7 +38,7 @@ export function splitRowSpanCells(editor: TablesEditor, path: Path) { ); } - nextRow = Path.next(nextRow); + nextRow = PathApi.next(nextRow); } }); diff --git a/packages/slate-tables/src/queries/findParentCell.ts b/packages/slate-tables/src/queries/findParentCell.ts index 6a3a66b59..4191d781b 100644 --- a/packages/slate-tables/src/queries/findParentCell.ts +++ b/packages/slate-tables/src/queries/findParentCell.ts @@ -1,14 +1,14 @@ -import { type Location, type NodeEntry, type Selection } from 'slate'; +import { type EditorSelection, type Location, type NodeEntry } from '@udecode/plate'; import type { TableCellNode } from '../nodes'; import type { TablesEditor } from '../TablesEditor'; export function findParentCell( editor: TablesEditor, - location: Location | Selection = editor.selection, + location: Location | EditorSelection = editor.selection, ): NodeEntry | undefined { if (!location) return undefined; - for (const entry of editor.levels({ at: location })) { + for (const entry of editor.api.levels({ at: location })) { if (editor.isTableCellNode(entry[0])) { return entry as NodeEntry; } diff --git a/packages/slate-tables/src/queries/findParentTable.ts b/packages/slate-tables/src/queries/findParentTable.ts index 1136eeb33..6f74bdce0 100644 --- a/packages/slate-tables/src/queries/findParentTable.ts +++ b/packages/slate-tables/src/queries/findParentTable.ts @@ -1,16 +1,16 @@ -import { type Location, type NodeEntry, type Selection } from 'slate'; +import { type EditorSelection, type Location, type NodeEntry } from '@udecode/plate'; import type { TableNode } from '../nodes'; import type { TablesEditor } from '../TablesEditor'; export function findParentTable( editor: TablesEditor, - location: Location | Selection = editor.selection, + location: Location | EditorSelection = editor.selection, ): NodeEntry | undefined { if (!location) { return undefined; } - for (const entry of editor.levels({ at: location })) { + for (const entry of editor.api.levels({ at: location })) { if (editor.isTableNode(entry[0])) { return entry as NodeEntry; } diff --git a/packages/slate-tables/src/queries/isInTable.ts b/packages/slate-tables/src/queries/isInTable.ts index d1ae544ae..a9e277ec2 100644 --- a/packages/slate-tables/src/queries/isInTable.ts +++ b/packages/slate-tables/src/queries/isInTable.ts @@ -1,5 +1,4 @@ -import type { Location } from 'slate'; -import { Node } from 'slate'; +import { type Location, NodeApi } from '@udecode/plate'; import { Traverse } from '../core'; import type { TablesEditor } from '../TablesEditor'; @@ -10,5 +9,5 @@ export function isInTable(editor: TablesEditor, location: Location | null = edit } const traverse = Traverse.create(editor, location); - return Node.isNode(traverse?.matrix.node); + return NodeApi.isNode(traverse?.matrix.node); }