{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-mail-merge",
  "framework": "aspnet-core",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "mail-merge",
  "dependencies": [
    "Syncfusion.AspNetCore.DocumentEditor"
  ],
  "description": "Document editor demonstrating mail merge fields populated with recipient data.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/aspnet-core/llms.txt",
    "skillPack": "syncfusion/aspnetcore-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/aspnet-core/docx-editor-mail-merge.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-mail-merge/docx-editor.cshtml",
      "content": "@page\n@namespace aspnet_core.DocxEditor.MailMerge\n@model EJ2CoreSampleBrowser.DocxEditor.MailMerge.MailMergeModel\n@using Syncfusion.EJ2\n\n    <div class=\"control-section\">\n        <div id='documenteditor_titlebar' class=\"e-de-ctn-title\"></div>\n        <div style=\"display: flex; gap: 12px; padding-top: 8px;\">\n            <div style=\"width: 200px; padding: 8px; border: 1px solid #eee;\">\n                <h6>Insert Field</h6>\n                <div id=\"fieldList\">\n                    @foreach (var field in Model.Fields)\n                    {\n                        <div class=\"merge-field\" data-field=\"@field.Name\" title=\"@field.Category\"\n                             style=\"border: 1px solid #ddd; padding: 4px 6px; margin-bottom: 4px; cursor: pointer;\">\n                            @field.Name\n                        </div>\n                    }\n                </div>\n            </div>\n            <div style=\"flex: 1;\">\n                <ejs-documenteditorcontainer id=\"container\" height=\"590px\" enableToolbar=\"true\"></ejs-documenteditorcontainer>\n            </div>\n        </div>\n    </div>\n\n    <script>\n        // Clicking a field inserts a MERGEFIELD into the document at the\n        // current selection. The actual mail merge (substituting field values\n        // and emitting the final document) is left out of this minimal sample.\n        document.addEventListener('DOMContentLoaded', function () {\n            var container = document.getElementById('container').ej2_instances[0];\n            if (!container) return;\n            var list = document.getElementById('fieldList');\n            list.addEventListener('click', function (e) {\n                var item = e.target.closest('.merge-field');\n                if (!item) return;\n                var fieldName = item.getAttribute('data-field');\n                if (fieldName && container.documentEditor && container.documentEditor.editor) {\n                    container.documentEditor.editor.insertField('MERGEFIELD ' + fieldName + ' \\\\* MERGEFORMAT');\n                }\n            });\n        });\n    </script>\n"
    },
    {
      "target": "src/components/docx-editor-mail-merge/docx-editor.cshtml.cs",
      "content": "using System.Collections.Generic;\nusing Microsoft.AspNetCore.Mvc.RazorPages;\n\nnamespace EJ2CoreSampleBrowser.DocxEditor.MailMerge\n{\n    public class MailMergeModel : PageModel\n    {\n        public List<FieldItem> Fields { get; set; } = new List<FieldItem>();\n\n        public void OnGet()\n        {\n            Fields = new List<FieldItem>\n            {\n                new FieldItem { Name = \"FirstName\", Category = \"Recipients\" },\n                new FieldItem { Name = \"LastName\",  Category = \"Recipients\" },\n                new FieldItem { Name = \"Address\",   Category = \"Recipients\" },\n                new FieldItem { Name = \"OrderId\",   Category = \"Orders\" },\n                new FieldItem { Name = \"OrderDate\", Category = \"Orders\" },\n            };\n        }\n    }\n\n    public class FieldItem\n    {\n        public string Name { get; set; } = string.Empty;\n        public string Category { get; set; } = string.Empty;\n    }\n}\n"
    }
  ]
}