1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-22 06:53:25 +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 { attributes, children, node } = this.props
const checked = node.data.get('checked') const checked = node.data.get('checked')
return ( return (
<div {...attributes} className="check-list-item"> <div
<span contentEditable={false}> className="check-list-item"
contentEditable={false}
{...attributes}
>
<span>
<input <input
type="checkbox" type="checkbox"
checked={checked} checked={checked}
onChange={this.onChange} onChange={this.onChange}
/> />
</span> </span>
<span contentEditable>
{children} {children}
</span>
</div> </div>
) )
} }

View File

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