diff --git a/packages/slate/src/interfaces/editor/transforms/node.ts b/packages/slate/src/interfaces/editor/transforms/node.ts
index 79487ca33..c18c84d37 100644
--- a/packages/slate/src/interfaces/editor/transforms/node.ts
+++ b/packages/slate/src/interfaces/editor/transforms/node.ts
@@ -184,12 +184,13 @@ export const NodeTransforms = {
options: {
at?: Location
match?: NodeMatch
+ withMatch?: NodeMatch
hanging?: boolean
voids?: boolean
} = {}
) {
Editor.withoutNormalizing(editor, () => {
- let { match, at = editor.selection } = options
+ let { match, withMatch, at = editor.selection } = options
const { hanging = false, voids = false } = options
if (!at) {
@@ -225,18 +226,23 @@ export const NodeTransforms = {
return
}
- let prevMatch: NodeMatch = 'block'
const [node, path] = current
if (Editor.isEditor(node)) {
return
- } else if (Text.isText(node)) {
- prevMatch = 'text'
- } else if (editor.isInline(node)) {
- prevMatch = 'inline'
}
- const prev = Editor.previous(editor, at, prevMatch, { voids })
+ if (withMatch == null) {
+ if (Text.isText(node)) {
+ withMatch = 'text'
+ } else if (editor.isInline(node)) {
+ withMatch = 'inline'
+ } else {
+ withMatch = 'block'
+ }
+ }
+
+ const prev = Editor.previous(editor, at, withMatch, { voids })
if (!prev) {
return
diff --git a/packages/slate/test/transforms/mergeNodes/path/block-nested.js b/packages/slate/test/transforms/mergeNodes/path/block-nested.js
new file mode 100644
index 000000000..857795bc1
--- /dev/null
+++ b/packages/slate/test/transforms/mergeNodes/path/block-nested.js
@@ -0,0 +1,31 @@
+/** @jsx jsx */
+
+import { Editor } from 'slate'
+import { jsx } from '../../..'
+
+export const input = (
+
+
+ one
+
+
+ two
+
+
+)
+
+export const run = editor => {
+ Editor.mergeNodes(editor, {
+ at: [1],
+ withMatch: ([, p]) => p.length === 1,
+ })
+}
+
+export const output = (
+
+
+ one
+ two
+
+
+)