diff --git a/.changeset/shy-planets-eat.md b/.changeset/shy-planets-eat.md
new file mode 100644
index 0000000000..c97c44458c
--- /dev/null
+++ b/.changeset/shy-planets-eat.md
@@ -0,0 +1,5 @@
+---
+'slate': minor
+---
+
+unwrapNode call liftNode in reverse order to keep nested block
diff --git a/packages/slate/src/transforms/node.ts b/packages/slate/src/transforms/node.ts
index caa863170e..4bd4ddc3dd 100644
--- a/packages/slate/src/transforms/node.ts
+++ b/packages/slate/src/transforms/node.ts
@@ -848,7 +848,13 @@ export const NodeTransforms: NodeTransforms = {
const rangeRef = Range.isRange(at) ? Editor.rangeRef(editor, at) : null
const matches = Editor.nodes(editor, { at, match, mode, voids })
- const pathRefs = Array.from(matches, ([, p]) => Editor.pathRef(editor, p))
+ const pathRefs = Array.from(
+ matches,
+ ([, p]) => Editor.pathRef(editor, p)
+ // unwrapNode will call liftNode which does not support splitting the node when nested.
+ // If we do not reverse the order and call it from top to the bottom, it will remove all blocks
+ // that wrap target node. So we reverse the order.
+ ).reverse()
for (const pathRef of pathRefs) {
const path = pathRef.unref()!
diff --git a/packages/slate/test/transforms/unwrapNodes/split-block/block-all-nested.tsx b/packages/slate/test/transforms/unwrapNodes/split-block/block-all-nested.tsx
new file mode 100644
index 0000000000..905fbd7d0c
--- /dev/null
+++ b/packages/slate/test/transforms/unwrapNodes/split-block/block-all-nested.tsx
@@ -0,0 +1,43 @@
+/** @jsx jsx */
+import { jsx } from '../../..'
+import { Transforms } from 'slate'
+
+export const run = editor => {
+ Transforms.unwrapNodes(editor, {
+ match: n => !!n.a,
+ mode: 'all',
+ split: true,
+ })
+}
+export const input = (
+
+
+
+ one
+
+
+ word
+
+ now
+
+
+
+)
+export const output = (
+
+
+
+ one
+
+
+
+
+ word
+
+
+
+ now
+
+
+
+)