diff --git a/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineCommentEditor/TimelineCommentEditor.js b/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineCommentEditor/TimelineCommentEditor.js index 4a4b6e46..81c2f2a9 100644 --- a/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineCommentEditor/TimelineCommentEditor.js +++ b/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineCommentEditor/TimelineCommentEditor.js @@ -27,15 +27,14 @@ const TimelineCommentEditor = ({ useSelector((state) => state.timeline.commentContentMaxLength) || 25000; const handleInit = (editor) => { editor.on("input", () => { - setCommentContent(editor.getContent()); - const charCount = editor.plugins.wordcount.body.getCharacterCount(); + // Using 'wordcount' plugin didn't give the real character count as it ignores HTML tags: + // const charCount = editor.plugins.wordcount.body.getCharacterCount(); + // Instead, we use getContent to include HTML tags in the count: + // If wordcount is redundant, we can remove it, though it might still be useful for plain text analysis. + const charCount = editor.getContent().length; setCharCount(charCount); if (charCount > commentContentMaxLength) { - setLocalError( - i18next.t( - `Character count exceeds the maximum limit of ${commentContentMaxLength} characters.` - ) - ); + setLocalError(i18next.t("Character count exceeds the maximum allowed limit.")); } else { setLocalError(""); } @@ -52,8 +51,8 @@ const TimelineCommentEditor = ({ /> { + inputValue={commentContent} + onEditorChange={(event, editor) => { setCommentContent(editor.getContent()); }} minHeight={150} diff --git a/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineEvents/TimelineCommentEvent.js b/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineEvents/TimelineCommentEvent.js index fd922ce1..ef933882 100644 --- a/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineEvents/TimelineCommentEvent.js +++ b/invenio_requests/assets/semantic-ui/js/invenio_requests/timelineEvents/TimelineCommentEvent.js @@ -113,8 +113,9 @@ class TimelineCommentEvent extends Component { {isEditing ? ( { + initialValue={event?.payload?.content} + inputValue={commentContent} + onEditorChange={(event, editor) => { this.setState({ commentContent: editor.getContent() }); }} minHeight={150}