diff --git a/src/components/editors/SortableImageGrid/index.tsx b/src/components/editors/SortableImageGrid/index.tsx
index 26fdd309..96eac82e 100644
--- a/src/components/editors/SortableImageGrid/index.tsx
+++ b/src/components/editors/SortableImageGrid/index.tsx
@@ -12,12 +12,17 @@ const SortableImageGrid = SortableContainer(
items,
locked,
onDrop,
+ size = 200,
}: {
items: IFile[];
locked: IUploadStatus[];
onDrop: (file_id: IFile['id']) => void;
+ size?: number;
}) => (
-
+
{items
.filter(file => file && file.id)
.map((file, index) => (
diff --git a/src/components/flow/FlowGrid/styles.scss b/src/components/flow/FlowGrid/styles.scss
index cf8e0b1d..15eadf3b 100644
--- a/src/components/flow/FlowGrid/styles.scss
+++ b/src/components/flow/FlowGrid/styles.scss
@@ -8,9 +8,6 @@ $stamp_color: $content_bg;
.grid_test {
display: grid;
- // grid-template-columns: repeat(auto-fit, minmax($cell, 1fr));
- // grid-template-rows: 50vh $cell;
- // grid-auto-rows: $cell;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: 50vh $cell;
diff --git a/src/components/node/CommentForm/index.tsx b/src/components/node/CommentForm/index.tsx
index c66dae7c..79c3a3e2 100644
--- a/src/components/node/CommentForm/index.tsx
+++ b/src/components/node/CommentForm/index.tsx
@@ -1,11 +1,11 @@
-import React, { FC, useCallback, KeyboardEventHandler, useEffect } from 'react';
+import React, { FC, useCallback, KeyboardEventHandler, useEffect, useMemo } from 'react';
import { Textarea } from '~/components/input/Textarea';
import { CommentWrapper } from '~/components/containers/CommentWrapper';
import * as styles from './styles.scss';
import { Filler } from '~/components/containers/Filler';
import { Button } from '~/components/input/Button';
import assocPath from 'ramda/es/assocPath';
-import { InputHandler, IFileWithUUID } from '~/redux/types';
+import { InputHandler, IFileWithUUID, IFile } from '~/redux/types';
import { connect } from 'react-redux';
import * as NODE_ACTIONS from '~/redux/node/actions';
import { selectNode } from '~/redux/node/selectors';
@@ -21,6 +21,9 @@ import { selectUser } from '~/redux/auth/selectors';
import { getURL } from '~/utils/dom';
import { ButtonGroup } from '~/components/input/ButtonGroup';
import { AudioPlayer } from '~/components/media/AudioPlayer';
+import { SortableImageGrid } from '~/components/editors/SortableImageGrid';
+import { moveArrItem } from '~/utils/fn';
+import { SortEnd } from 'react-sortable-hoc';
const mapStateToProps = (state: IState) => ({
node: selectNode(state),
@@ -121,6 +124,41 @@ const CommentFormUnconnected: FC = ({
const comment = comment_data[id];
+ const images = useMemo(() => comment.files.filter(file => file.type === UPLOAD_TYPES.IMAGE), [
+ comment.files,
+ ]);
+
+ const audios = useMemo(() => comment.files.filter(file => file.type === UPLOAD_TYPES.AUDIO), [
+ comment.files,
+ ]);
+
+ const onFileDrop = useCallback(
+ (file_id: IFile['id']) => {
+ nodeSetCommentData(
+ id,
+ assocPath(['files'], comment.files.filter(file => file.id != file_id), comment_data[id])
+ );
+ },
+ [comment_data, id, nodeSetCommentData]
+ );
+
+ const onImageMove = useCallback(
+ ({ oldIndex, newIndex }: SortEnd) => {
+ nodeSetCommentData(
+ id,
+ assocPath(
+ ['files'],
+ [
+ ...audios,
+ ...(moveArrItem(oldIndex, newIndex, images.filter(file => !!file)) as IFile[]),
+ ],
+ comment_data[id]
+ )
+ );
+ },
+ [images, audios]
+ );
+
return (
- {comment.temp_ids.map(
- temp_id =>
- statuses[temp_id] &&
- statuses[temp_id].is_uploading && (
-
{statuses[temp_id].progress}
- )
+ {(!!images.length || !!audios.length) && (
+
+
+
+ {audios.map(file => (
+
+ ))}
+
)}
- {comment.files.map(file => {
- if (file.type === UPLOAD_TYPES.AUDIO) {
- return
;
- }
-
- return
file.name
;
- })}
-