@@ -53,15 +59,13 @@ const Comment = props => {
onChange={onUpdateComment}
onSaveAndClose={props.onSaveAndClose}
/>
-
-
setIsMenuVisible(!isMenuVisible)}>
diff --git a/src/editor/widgets/comment/CommentWidget.jsx b/src/editor/widgets/comment/CommentWidget.jsx
index 6f34878..60e7569 100644
--- a/src/editor/widgets/comment/CommentWidget.jsx
+++ b/src/editor/widgets/comment/CommentWidget.jsx
@@ -2,8 +2,9 @@ import React from 'preact/compat';
import Comment from './Comment';
import TextEntryField from './TextEntryField';
import i18n from '../../../i18n';
+import TypeDropdown from './TypeDropdown';
+
const purposes = ['assessing', 'bookmarking', 'classifying', 'commenting', 'describing', 'editing', 'highlighting', 'identifying', 'linking', 'moderating', 'questioning']
-console.log(purposes)
/**
* Comments are TextualBodies where the purpose field is either
* blank or 'commenting' or 'replying'
@@ -28,10 +29,12 @@ const getDraftReply = (existingDraft, isReply) => {
*/
const CommentWidget = props => {
// All comments (draft + non-draft)
+ console.log(props.annotation)
const all = props.annotation ?
props.annotation.bodies.filter(isComment) : [];
// Last draft comment without a creator field goes into the reply field
+ console.log(all)
const draftReply = getDraftReply(all.slice().reverse().find(b => b.draft && !b.creator), all.length > 1);
// All except draft reply
@@ -80,6 +83,7 @@ const CommentWidget = props => {
{
0 ? i18n.t('Add a reply...') : i18n.t('Add a comment...')}
onChange={onEditReply}
onSaveAndClose={() => props.onSaveAndClose()}
diff --git a/src/editor/widgets/comment/TypeDropdown.jsx b/src/editor/widgets/comment/TypeDropdown.jsx
index bf030b0..551b05a 100644
--- a/src/editor/widgets/comment/TypeDropdown.jsx
+++ b/src/editor/widgets/comment/TypeDropdown.jsx
@@ -1,23 +1,29 @@
-import React from 'preact/compat';
-import { useRef } from 'preact/hooks';
-import useClickOutside from '../../useClickOutside';
+import React, { Component } from 'preact/compat';
+import ContentEditable from 'react-contenteditable';
import i18n from '../../../i18n';
+
const purposes = ['assessing', 'bookmarking', 'classifying', 'commenting', 'describing', 'editing', 'highlighting', 'identifying', 'linking', 'moderating', 'questioning']
-const DropdownMenu = props => {
- const ref = useRef();
- // Custom hook that notifies when clicked outside this component
- useClickOutside(ref, () => props.onClickOutside());
- return (
-
- )
+export default class TypeDropdown extends Component {
-}
+ // CTRL+Enter functions as Ok
+ onKeyDown = evt => {
+ if (evt.which === 13 && evt.ctrlKey)
+ this.props.onSaveAndClose();
+ }
-export default DropdownMenu;
\ No newline at end of file
+ render() {
+ return (
+
+
{this.props.content}
+
+
+ )
+ }
+}
\ No newline at end of file