Skip to content

Commit 54261f6

Browse files
committed
refactor: remove dead branches from applyInsertNodeAtPoint
1 parent 36c0619 commit 54261f6

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

packages/editor/src/internal-utils/apply-insert-node.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Editor, Element, Node, Path, Text, type Point} from '../slate'
1+
import {Editor, Node, Path, Text, type Point} from '../slate'
22
import type {PortableTextSlateEditor} from '../types/slate-editor'
33
import {applySelect} from './apply-selection'
44
import {applySplitNode} from './apply-split-node'
@@ -40,27 +40,9 @@ export function applyInsertNodeAtPoint(
4040
at: Point,
4141
): void {
4242
Editor.withoutNormalizing(editor, () => {
43-
let match: (n: Node) => boolean
44-
45-
if (Text.isText(node, editor.schema)) {
46-
match = (n) => Text.isText(n, editor.schema)
47-
} else if (
48-
Element.isElement(node, editor.schema) &&
49-
editor.isInline(node)
50-
) {
51-
match = (n) =>
52-
Text.isText(n, editor.schema) ||
53-
(Element.isElement(n, editor.schema) && Editor.isInline(editor, n))
54-
} else if (editor.isObjectNode(node)) {
55-
match = (n) =>
56-
Text.isText(n, editor.schema) ||
57-
editor.isObjectNode(n) ||
58-
(Element.isElement(n, editor.schema) && Editor.isInline(editor, n))
59-
} else {
60-
match = (n) =>
61-
(Element.isElement(n, editor.schema) && Editor.isBlock(editor, n)) ||
62-
editor.isObjectNode(n)
63-
}
43+
const match = Text.isText(node, editor.schema)
44+
? (n: Node) => Text.isText(n, editor.schema)
45+
: (n: Node) => Text.isText(n, editor.schema) || editor.isObjectNode(n)
6446

6547
const [entry] = Editor.nodes(editor, {
6648
at: at.path,

0 commit comments

Comments
 (0)