Merge pull request #113 from ahammouda/main

Added ability to change placeholder text for comment/tag, and make comment replies optional
This commit is contained in:
Rainer Simon 2022-10-02 19:23:10 +02:00 committed by GitHub
commit 9c8810eb36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 26 deletions

View File

@ -87,6 +87,12 @@ const CommentWidget = props => {
const onChangeReplyPurpose = purpose =>
props.onUpdateBody(draftReply, { ...draftReply, purpose: purpose.value });
// Pre-condition: will be true if the annotation exists, and Annotorious is not in read-only mode
const isReadable = (!props.readOnly && props.annotation);
// Extra condtion to: reply field exists if there is no comment yet, or disableReply is false.
const hasReply = comments.length === 0 || !props.disableReply;
return (
<>
{ comments.map((body, idx) =>
@ -101,18 +107,18 @@ const CommentWidget = props => {
onSaveAndClose={props.onSaveAndClose} />
)}
{ !props.readOnly && props.annotation &&
{ isReadable && hasReply &&
<div className="r6o-widget comment editable">
<TextEntryField
focus={props.focus}
content={draftReply.value}
editable={true}
placeholder={comments.length > 0 ? i18n.t('Add a reply...') : i18n.t('Add a comment...')}
placeholder={comments.length > 0 ? i18n.t('Add a reply...') : (props.textPlaceHolder || i18n.t('Add a comment...'))}
onChange={onEditReply}
onSaveAndClose={() => props.onSaveAndClose()}
/>
{ props.purposeSelector && draftReply.value.length > 0 &&
<PurposeSelect
{ props.purposeSelector && draftReply.value.length > 0 &&
<PurposeSelect
editable={true}
content={draftReply.purpose}
onChange={onChangeReplyPurpose}

View File

@ -98,7 +98,7 @@ const TagWidget = props => {
{!props.readOnly &&
<Autocomplete
focus={props.focus}
placeholder={i18n.t('Add tag...')}
placeholder={props.textPlaceHolder || i18n.t('Add tag...')}
vocabulary={props.vocabulary || []}
onChange={onDraftChange}
onSubmit={onSubmit}/>