pdf task-h
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user