Made widgets readOnly-compatible

This commit is contained in:
Rainer Simon 2020-05-01 14:20:13 +02:00
parent 2ca27b285d
commit 574d805008
4 changed files with 20 additions and 13 deletions

View File

@ -82,6 +82,8 @@ const Editor = props => {
}
};
console.log(props);
return (
<div ref={element} className="r6o-editor">
<div className="arrow" />
@ -89,6 +91,7 @@ const Editor = props => {
{React.Children.map(props.children, child =>
React.cloneElement(child, {
annotation : currentAnnotation,
readOnly : props.readOnly,
onAppendBody : onAppendBody,
onUpdateBody : onUpdateBody,
onRemoveBody : onRemoveBody,

View File

@ -38,23 +38,27 @@ const TagWidget = props => {
<li key={tag.value} onClick={toggle(tag.value)}>
<span className="label">{tag.value}</span>
<CSSTransition in={showDelete === tag.value} timeout={200} classNames="delete">
<span className="delete-wrapper" onClick={onDelete(tag)}>
<span className="delete">
<CloseIcon width={12} />
{!props.readOnly &&
<CSSTransition in={showDelete === tag.value} timeout={200} classNames="delete">
<span className="delete-wrapper" onClick={onDelete(tag)}>
<span className="delete">
<CloseIcon width={12} />
</span>
</span>
</span>
</CSSTransition>
</CSSTransition>
}
</li>
)}
</ul>
<input
type="text"
value={newTag}
onChange={evt => setNewTag(evt.target.value)}
onKeyDown={onKeyDown}
placeholder="Add tag..." />
{ !props.readOnly &&
<input
type="text"
value={newTag}
onChange={evt => setNewTag(evt.target.value)}
onKeyDown={onKeyDown}
placeholder="Add tag..." />
}
</div>
)

View File

@ -1,5 +1,4 @@
.r6o-editable-text {
padding:8px 10px;
max-height:120px;
overflow:auto;
outline:none;

View File

@ -3,6 +3,7 @@
min-height:3em;
background-color:#fff;
position:relative;
padding:8px 10px;
.arrow-down {
position:absolute;