|
1 | | -import {Editor, Element, Node, Path, Text, type Point} from '../slate' |
| 1 | +import {Editor, Node, Path, Text, type Point} from '../slate' |
2 | 2 | import type {PortableTextSlateEditor} from '../types/slate-editor' |
3 | 3 | import {applySelect} from './apply-selection' |
4 | 4 | import {applySplitNode} from './apply-split-node' |
@@ -40,27 +40,9 @@ export function applyInsertNodeAtPoint( |
40 | 40 | at: Point, |
41 | 41 | ): void { |
42 | 42 | 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) |
64 | 46 |
|
65 | 47 | const [entry] = Editor.nodes(editor, { |
66 | 48 | at: at.path, |
|
0 commit comments