Patch detector configuration
Array of placeholder keys found in the document
const placeholders = await patchDetector({ data: templateBuffer });
// Returns: ["name", "date", "address"] if template contains {{name}}, {{date}}, {{address}}
// Use detected placeholders to create patches
const patches = {};
placeholders.forEach(key => {
patches[key] = {
type: PatchType.PARAGRAPH,
children: [new TextRun(getUserData(key))],
};
});
Detects all placeholders present in a document template.
Scans through all XML content in a .docx file to find placeholder text enclosed in delimiters (default: {{placeholder}}). This is useful for discovering what patches a template expects before performing replacement.