mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-23 07:22:55 +02:00
Do not show placeholder when document contains multiple text nodes (#2403)
This commit is contained in:
committed by
Ian Storm Taylor
parent
65d662fea1
commit
3f0f55ff38
3
packages/slate-react/src/plugins/react.js
vendored
3
packages/slate-react/src/plugins/react.js
vendored
@@ -120,7 +120,8 @@ function ReactPlugin(options = {}) {
|
|||||||
when: (editor, node) =>
|
when: (editor, node) =>
|
||||||
node.object === 'document' &&
|
node.object === 'document' &&
|
||||||
node.text === '' &&
|
node.text === '' &&
|
||||||
node.nodes.size === 1,
|
node.nodes.size === 1 &&
|
||||||
|
node.getTexts().size === 1,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,46 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
|
import h from '../../../helpers/h'
|
||||||
|
|
||||||
|
export const props = {
|
||||||
|
placeholder: 'placeholder text',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const value = (
|
||||||
|
<value>
|
||||||
|
<document>
|
||||||
|
<paragraph>
|
||||||
|
<text />
|
||||||
|
</paragraph>
|
||||||
|
<paragraph>
|
||||||
|
<text />
|
||||||
|
</paragraph>
|
||||||
|
</document>
|
||||||
|
</value>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const output = `
|
||||||
|
<div data-slate-editor="true" contenteditable="true" role="textbox">
|
||||||
|
<div style="position:relative">
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span data-slate-zero-width="n" data-slate-length="0">
|
||||||
|
<br>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style="position:relative">
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span data-slate-zero-width="n" data-slate-length="0">
|
||||||
|
<br>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
.split('\n')
|
||||||
|
.map(l => l.trim())
|
||||||
|
.join('')
|
@@ -0,0 +1,49 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
|
import h from '../../../helpers/h'
|
||||||
|
|
||||||
|
export const props = {
|
||||||
|
placeholder: 'placeholder text',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const value = (
|
||||||
|
<value>
|
||||||
|
<document>
|
||||||
|
<paragraph>
|
||||||
|
<inline type="link">
|
||||||
|
<text />
|
||||||
|
</inline>
|
||||||
|
<text />
|
||||||
|
</paragraph>
|
||||||
|
</document>
|
||||||
|
</value>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const output = `
|
||||||
|
<div data-slate-editor="true" contenteditable="true" role="textbox">
|
||||||
|
<div style="position:relative">
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span data-slate-zero-width="z" data-slate-length="0"></span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span style="position:relative">
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span data-slate-zero-width="z" data-slate-length="0"></span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span data-slate-zero-width="n" data-slate-length="0">
|
||||||
|
<br>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
.split('\n')
|
||||||
|
.map(l => l.trim())
|
||||||
|
.join('')
|
@@ -0,0 +1,37 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
|
import h from '../../../helpers/h'
|
||||||
|
|
||||||
|
export const props = {
|
||||||
|
placeholder: 'placeholder text',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const value = (
|
||||||
|
<value>
|
||||||
|
<document>
|
||||||
|
<paragraph>
|
||||||
|
<text />
|
||||||
|
</paragraph>
|
||||||
|
</document>
|
||||||
|
</value>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const output = `
|
||||||
|
<div data-slate-editor="true" contenteditable="true" role="textbox">
|
||||||
|
<div style="position:relative">
|
||||||
|
<span>
|
||||||
|
<span data-slate-leaf="true">
|
||||||
|
<span contenteditable="false" style="pointer-events:none;display:inline-block;width:0;max-width:100%;white-space:nowrap;opacity:0.333">
|
||||||
|
placeholder text
|
||||||
|
</span>
|
||||||
|
<span data-slate-zero-width="n" data-slate-length="0">
|
||||||
|
<br>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
.split('\n')
|
||||||
|
.map(l => l.trim())
|
||||||
|
.join('')
|
Reference in New Issue
Block a user