Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | export function collectFileRefs(preview) { const refs = []; if (!preview) { return refs; } if (Array.isArray(preview.files)) { for (const file of preview.files) { if (isFileRef(file)) { refs.push({ source: 'files', file }); } } } if (Array.isArray(preview.custom_fields)) { for (const field of preview.custom_fields) { if (field?.field_type === 'file' && isFileRef(field.value)) { refs.push({ source: 'custom_field', file: field.value }); } } } return refs; } export function isFileRef(value) { if (value === null || typeof value !== 'object') { return false; } const file = value; return file.file_id !== undefined || (typeof file.guid === 'string' && file.guid.length > 0); } export function fileRefMatchesHit(file, fileHit) { if (fileHit.file_id !== undefined && file.file_id !== undefined) { return file.file_id === fileHit.file_id; } if (fileHit.guid && file.guid) { return file.guid === fileHit.guid; } return false; } |