1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 14:41:23 +02:00

Rewrite CheckListItem component. Only the area we really want to be editable (#696)

must lie inside contenteditable elements.
This commit is contained in:
AlbertHilb
2017-03-30 16:35:01 +02:00
committed by Ian Storm Taylor
parent 83a94f0737
commit f1b147860b
2 changed files with 23 additions and 5 deletions

View File

@@ -40,15 +40,21 @@ class CheckListItem extends React.Component {
const { attributes, children, node } = this.props
const checked = node.data.get('checked')
return (
<div {...attributes} className="check-list-item">
<span contentEditable={false}>
<div
className="check-list-item"
contentEditable={false}
{...attributes}
>
<span>
<input
type="checkbox"
checked={checked}
onChange={this.onChange}
/>
</span>
<span contentEditable>
{children}
</span>
</div>
)
}

View File

@@ -208,7 +208,19 @@ input:focus {
margin-top: 0;
}
.check-list-item [contenteditable="false"] {
display: inline-block;
.check-list-item {
display: flex;
flex-direction: row;
}
.check-list-item > span:first-child {
margin-right: 0.75em;
}
.check-list-item > span:last-child {
flex: 1;
}
.check-list-item > span:last-child:focus {
outline: none;
}