mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-13 02:55:03 +00:00
Multipage working
This commit is contained in:
parent
f6e8f07afc
commit
ebd6aac715
@ -81,20 +81,18 @@ function setupFileInput(chooser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const googleDriveFileListener = function (e) {
|
const googleDriveFileListener = function (e) {
|
||||||
const googleDriveFile = e.detail;
|
const googleDriveFiles = e.detail;
|
||||||
|
|
||||||
const fileInput = document.getElementById(elementId);
|
const fileInput = document.getElementById(elementId);
|
||||||
if (fileInput?.hasAttribute('multiple')) {
|
if (fileInput?.hasAttribute('multiple')) {
|
||||||
allFiles.push(googleDriveFile);
|
pushFileListTo(googleDriveFiles, allFiles);
|
||||||
} else if (fileInput) {
|
} else if (fileInput) {
|
||||||
allFiles = [googleDriveFile];
|
allFiles = [googleDriveFiles[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataTransfer = new DataTransfer();
|
const dataTransfer = new DataTransfer();
|
||||||
allFiles.forEach((file) => dataTransfer.items.add(file));
|
allFiles.forEach((file) => dataTransfer.items.add(file));
|
||||||
|
|
||||||
fileInput.files = dataTransfer.files;
|
fileInput.files = dataTransfer.files;
|
||||||
|
|
||||||
fileInput.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { source: 'drag-drop' } }));
|
fileInput.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { source: 'drag-drop' } }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,21 +95,23 @@
|
|||||||
*/
|
*/
|
||||||
async function pickerCallback(data) {
|
async function pickerCallback(data) {
|
||||||
if (data.action === google.picker.Action.PICKED) {
|
if (data.action === google.picker.Action.PICKED) {
|
||||||
data[google.picker.Response.DOCUMENTS].forEach(async pickedFile => {
|
const files = await Promise.all(data[google.picker.Response.DOCUMENTS].map(async pickedFile => {
|
||||||
const fileId = pickedFile[google.picker.Document.ID];
|
const fileId = pickedFile[google.picker.Document.ID];
|
||||||
console.log(fileId);
|
console.log(fileId);
|
||||||
const res = await gapi.client.drive.files.get({
|
const res = await gapi.client.drive.files.get({
|
||||||
'fileId': fileId,
|
'fileId': fileId,
|
||||||
'alt': 'media',
|
'alt': 'media',
|
||||||
});
|
});
|
||||||
|
|
||||||
var file = new File([new Uint8Array(res.body.length).map((_, i) => res.body.charCodeAt(i))],
|
var file = new File([new Uint8Array(res.body.length).map((_, i) => res.body.charCodeAt(i))],
|
||||||
pickedFile.name, {
|
pickedFile.name, {
|
||||||
type: pickedFile.mimeType,
|
type: pickedFile.mimeType,
|
||||||
lastModified: pickedFile.lastModified,
|
lastModified: pickedFile.lastModified,
|
||||||
endings: pickedFile.endings
|
endings: pickedFile.endings
|
||||||
} )
|
} );
|
||||||
document.body.dispatchEvent(new CustomEvent("googleDriveFilePicked", {detail: file}));
|
return file;
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
document.body.dispatchEvent(new CustomEvent("googleDriveFilePicked", {detail: files}));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user