pdf task-h

This commit is contained in:
phaichayon
2026-06-19 15:09:58 +07:00
parent a85d24235c
commit fd01ebf7c7
35 changed files with 3905 additions and 133 deletions

View File

@@ -87,6 +87,12 @@ function extractSinglePlaceholder(value: string) {
return uniqueMatches.length === 1 ? uniqueMatches[0] : null;
}
function getFieldName(field: unknown) {
return field && typeof field === 'object' && typeof (field as { name?: unknown }).name === 'string'
? ((field as { name: string }).name ?? '')
: '';
}
function normalizeTopicKey(value: string | null | undefined) {
return (
value
@@ -165,13 +171,26 @@ function normalizePdfmeTemplateInput(schemaJson: unknown, templateInput: Record<
}
const tableField = field as { type?: unknown; content?: unknown };
const fieldName = getFieldName(field);
const placeholderKey =
typeof tableField.content === 'string'
? extractSinglePlaceholder(tableField.content)
: null;
if (fieldName && placeholderKey && fieldName !== placeholderKey) {
if (normalized[fieldName] !== undefined && normalized[placeholderKey] === undefined) {
normalized[placeholderKey] = normalized[fieldName];
}
if (normalized[placeholderKey] !== undefined && normalized[fieldName] === undefined) {
normalized[fieldName] = normalized[placeholderKey];
}
}
if (tableField.type !== 'table' || typeof tableField.content !== 'string') {
continue;
}
const placeholderKey = extractSinglePlaceholder(tableField.content);
if (!placeholderKey) {
continue;
}