1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 13:11:17 +02:00

Do not show placeholder when document contains multiple text nodes (#2403)

This commit is contained in:
Dundercover
2018-11-09 17:29:22 +01:00
committed by Ian Storm Taylor
parent 65d662fea1
commit 3f0f55ff38
4 changed files with 134 additions and 1 deletions

View File

@@ -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,
})
)
}

View File

@@ -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('')

View File

@@ -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('')

View File

@@ -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('')