Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
Added ability to see thumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreysaf committed Sep 18, 2020
1 parent da14a57 commit 678eb10
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React Sample</title>
<title>WebViewer Document Merge</title>
</head>
<body>
<noscript>
Expand Down
51 changes: 37 additions & 14 deletions src/components/Dropzone/Dropzone.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import React, { useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import './styles.css';

const Dropzone = () => {
const dropRef = useRef(null);
const fileListRef = useRef(null);
const [docs, addDocument] = useState([]);
const [thumbArray, addThumbToArray] = useState([]);

useEffect(() => {
if (docs.length >= 1) {
const CoreControls = window.CoreControls;
CoreControls.setWorkerPath('/webviewer/lib/core');
const loadDocumentAndThumb = async () => {
const doc = await CoreControls.createDocument(docs[docs.length - 1]);
doc.loadThumbnailAsync(1, thumbnail => {
addThumbToArray([...thumbArray, thumbnail]);
});
}
loadDocumentAndThumb();
}
}, [docs]);

const mergeDocuments = async () => {
const CoreControls = window.CoreControls;
Expand Down Expand Up @@ -59,19 +75,26 @@ const Dropzone = () => {
};

return (
<div
className="dropDiv"
ref={dropRef}
onDrop={ev => {
onDropEvent(ev);
}}
onDragOver={ev => {
ev.preventDefault();
ev.dataTransfer.dropEffect = 'move';
}}
>
<p>Drop the thumbs from the viewers here</p>
<button onClick={mergeDocuments}>Download</button>
<div>
<div
className="dropDiv"
ref={dropRef}
onDrop={ev => {
onDropEvent(ev);
}}
onDragOver={ev => {
ev.preventDefault();
ev.dataTransfer.dropEffect = 'move';
}}
>
<p>Drop the thumbs from the viewers here</p>
<button onClick={mergeDocuments}>Download</button>
</div>
<div className="list" ref={fileListRef}>
{thumbArray.map((thumb) => {
return <img src={thumb.toDataURL()} />
})}
</div>
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/components/Dropzone/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
margin: 20px;
flex: 1;
margin: 8px;
height: 300px;
}

0 comments on commit 678eb10

Please sign in to comment.