Configurable editor widgets

This commit is contained in:
Rainer Simon 2020-04-04 21:06:53 +02:00
parent 0e70226aaa
commit 05fcda369b
2 changed files with 11 additions and 13 deletions

View File

@ -70,17 +70,15 @@ const Editor = props => {
<div ref={element} className="r6o-editor">
<div className="arrow" />
<div className="inner">
<CommentWidget
annotation={currentAnnotation}
onAppendBody={onAppendBody}
onUpdateBody={onUpdateBody}
onRemoveBody={onRemoveBody}
onSaveAndClose={onOk} />
<TagWidget
annotation={currentAnnotation}
onAppendBody={onAppendBody}
onRemoveBody={onRemoveBody} />
{React.Children.map(props.children, child =>
React.cloneElement(child, {
annotation : currentAnnotation,
onAppendBody : onAppendBody,
onUpdateBody : onUpdateBody,
onRemoveBody : onRemoveBody,
onSaveAndClose : onOk
}))
}
{ props.readOnly ? (
<div className="footer">

View File

@ -20,12 +20,12 @@ const TagWidget = props => {
const onDelete = tag => evt => {
evt.stopPropagation();
props.onRemoveTag(tag);
props.onRemoveBody(tag);
}
const onKeyDown = evt => {
if (evt.which === 13) { // Enter
props.onAddTag({ type: 'TextualBody', purpose: 'tagging', value: newTag.trim() });
props.onAppendBody({ type: 'TextualBody', purpose: 'tagging', value: newTag.trim() });
setNewTag(''); // Clear the input
}
}