diff --git a/packages/slate-react/src/plugins/react.js b/packages/slate-react/src/plugins/react.js index a66410ecf..56440bffc 100644 --- a/packages/slate-react/src/plugins/react.js +++ b/packages/slate-react/src/plugins/react.js @@ -120,7 +120,8 @@ function ReactPlugin(options = {}) { when: (editor, node) => node.object === 'document' && node.text === '' && - node.nodes.size === 1, + node.nodes.size === 1 && + node.getTexts().size === 1, }) ) } diff --git a/packages/slate-react/test/rendering/fixtures/placeholder/multiple-blocks-with-single-empty-text.js b/packages/slate-react/test/rendering/fixtures/placeholder/multiple-blocks-with-single-empty-text.js new file mode 100644 index 000000000..ce388d001 --- /dev/null +++ b/packages/slate-react/test/rendering/fixtures/placeholder/multiple-blocks-with-single-empty-text.js @@ -0,0 +1,46 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export const props = { + placeholder: 'placeholder text', +} + +export const value = ( + + + + + + + + + + +) + +export const output = ` +
+
+ + + +
+
+
+
+
+
+ + + +
+
+
+
+
+
+` + .split('\n') + .map(l => l.trim()) + .join('') diff --git a/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-inline.js b/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-inline.js new file mode 100644 index 000000000..cbd65ed85 --- /dev/null +++ b/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-inline.js @@ -0,0 +1,49 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export const props = { + placeholder: 'placeholder text', +} + +export const value = ( + + + + + + + + + + +) + +export const output = ` +
+
+ + + + + + + + + + + + + + + +
+
+
+
+
+
+` + .split('\n') + .map(l => l.trim()) + .join('') diff --git a/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-single-empty-text.js b/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-single-empty-text.js new file mode 100644 index 000000000..5ca925227 --- /dev/null +++ b/packages/slate-react/test/rendering/fixtures/placeholder/single-block-with-single-empty-text.js @@ -0,0 +1,37 @@ +/** @jsx h */ + +import h from '../../../helpers/h' + +export const props = { + placeholder: 'placeholder text', +} + +export const value = ( + + + + + + + +) + +export const output = ` +
+
+ + + + placeholder text + + +
+
+
+
+
+
+` + .split('\n') + .map(l => l.trim()) + .join('')