diff --git a/.changeset/wild-penguins-shout.md b/.changeset/wild-penguins-shout.md new file mode 100644 index 00000000000..ff78829fd78 --- /dev/null +++ b/.changeset/wild-penguins-shout.md @@ -0,0 +1,5 @@ +--- +'slate': patch +--- + +Warn when normalization removes node diff --git a/packages/slate/src/create-editor.ts b/packages/slate/src/create-editor.ts index b1a903b5eb6..59ff2324d7d 100644 --- a/packages/slate/src/create-editor.ts +++ b/packages/slate/src/create-editor.ts @@ -227,6 +227,14 @@ export const createEditor = (): Editor => { // other inline nodes, or parent blocks that only contain inlines and // text. if (isInlineOrText !== shouldHaveInlines) { + // eslint-disable-next-line no-console + console.warn( + `Removing ${ + isInlineOrText ? 'inline' : 'block' + } node at path ${path.concat(n)} because parent expects ${ + shouldHaveInlines ? 'inline' : 'block' + } children` + ) Transforms.removeNodes(editor, { at: path.concat(n), voids: true }) n-- } else if (Element.isElement(child)) {