adding document when creating process takes a fileBlob type
This commit is contained in:
parent
6167d59501
commit
23a3b2a9e8
@ -32,11 +32,15 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
||||
storagesInput: HTMLInputElement;
|
||||
validationRules: ValidationRule[];
|
||||
}[] = [];
|
||||
type fileBlob = {
|
||||
type: string,
|
||||
data: Uint8Array
|
||||
};
|
||||
const nonRoleRowStates: {
|
||||
keyInput: HTMLInputElement,
|
||||
valueInput: HTMLInputElement,
|
||||
fileInput: HTMLInputElement,
|
||||
fileBlob: number[] | null
|
||||
fileBlob: fileBlob | null
|
||||
}[] = [];
|
||||
|
||||
const inputStyle = 'flex: 1; height: 2.5rem; padding: 0.5rem; border: 1px solid #ccc; border-radius: 0.375rem;';
|
||||
@ -92,8 +96,14 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
||||
fileInput.onchange = async () => {
|
||||
const file = fileInput.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
const buffer = await file.arrayBuffer();
|
||||
rowState.fileBlob = Array.from(new Uint8Array(buffer));
|
||||
const uint8 = new Uint8Array(buffer);
|
||||
|
||||
rowState.fileBlob = {
|
||||
type: file.type,
|
||||
data: uint8,
|
||||
};
|
||||
|
||||
valueInput.value = `📄 ${file.name}`;
|
||||
valueInput.disabled = true;
|
||||
@ -105,7 +115,6 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
||||
attachBtn.style.cssText = 'padding: 0.3rem 0.75rem; border: 1px solid #ccc; border-radius: 0.375rem; background: #f0f0f0; cursor: pointer;';
|
||||
attachBtn.onclick = () => fileInput.click();
|
||||
|
||||
|
||||
const keyInput = document.createElement('input');
|
||||
const valueInput = document.createElement('input');
|
||||
|
||||
@ -113,7 +122,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
||||
keyInput,
|
||||
valueInput,
|
||||
fileInput,
|
||||
fileBlob: null as File | null
|
||||
fileBlob: null as fileBlob | null
|
||||
};
|
||||
nonRoleRowStates.push(rowState);
|
||||
|
||||
@ -170,7 +179,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
|
||||
}
|
||||
return data;
|
||||
} else {
|
||||
const data: Record<string, string | Blob> = {};
|
||||
const data: Record<string, string | fileBlob> = {};
|
||||
for (const row of nonRoleRowStates) {
|
||||
const key = row.keyInput.value.trim();
|
||||
if (!key) continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user