mirror of
https://github.com/Doodle3D/Doodle3D-Transform.git
synced 2024-11-22 13:37:57 +01:00
Export doodles with accompanied HTML
@companje
This commit is contained in:
parent
44d0c226e7
commit
800fe411f4
@ -60,12 +60,26 @@ export const downloadAllSketches = () => {
|
|||||||
attachments: true,
|
attachments: true,
|
||||||
binary: true
|
binary: true
|
||||||
}));
|
}));
|
||||||
for (const { name, _attachments: { sketch: { data } }, updatedOn } of files) {
|
for (const { name, _attachments: { sketch: { data: sketchData }, img: { data: imgData } }, updatedOn } of files) {
|
||||||
const uniqueName = createUniqueName(name || 'Doodle', names);
|
const uniqueName = createUniqueName(name || 'Doodle', names);
|
||||||
|
const date = new Date(updatedOn);
|
||||||
zip.file(`${uniqueName}.doodle3d`, data, { binary: true, date: new Date(updatedOn) });
|
zip.file(`sketches/${uniqueName}.doodle3d`, sketchData, { binary: true, date: date });
|
||||||
|
zip.file(`images/${uniqueName}.png`, imgData, { binary: true, date: date });
|
||||||
names.push(uniqueName);
|
names.push(uniqueName);
|
||||||
}
|
}
|
||||||
|
zip.file(`index.html`, `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${names.map(name =>
|
||||||
|
`<a href="sketches/${name}.doodle3d">
|
||||||
|
<img src="images/${name}.png" title="${name}" alt="${name}" width="200" />
|
||||||
|
</a>`
|
||||||
|
).join("")}
|
||||||
|
</body>
|
||||||
|
</html>`, { binary: false });
|
||||||
const dataBlob = await zip.generateAsync({ type: 'blob' });
|
const dataBlob = await zip.generateAsync({ type: 'blob' });
|
||||||
return dispatch({
|
return dispatch({
|
||||||
type: ALL_SKETCHES_EXPORT,
|
type: ALL_SKETCHES_EXPORT,
|
||||||
|
Loading…
Reference in New Issue
Block a user