{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-mail-merge",
  "framework": "blazor",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "mail-merge",
  "dependencies": [
    "Syncfusion.Blazor.WordProcessor"
  ],
  "description": "Document editor that merges recipient data into template fields for creating personalized documents.",
  "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/blazor/llms.txt",
    "skillPack": "syncfusion/blazor-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/blazor/docx-editor-mail-merge.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-mail-merge/DocxEditor.razor",
      "content": "@page \"/document-editor/mail-merge\"\r\n@namespace blazor.Components.Pages.MailMerge.MailMerge\r\n@using System.Text\r\n@using System.Text.Json\r\n@using Syncfusion.Blazor.DocumentEditor;\r\n@using Syncfusion.Blazor.Lists;\r\n\r\n<div class=\"control-section\">\r\n    <div id='documenteditor_titlebar' class=\"e-de-ctn-title\"></div>\r\n    <div style=\"display: flex; gap: 12px; padding-top: 8px;\">\r\n        <div style=\"width: 200px; padding: 8px; border: 1px solid #eee;\">\r\n            <h6>Insert Field</h6>\r\n            @foreach (var field in Fields)\r\n            {\r\n                <div style=\"border: 1px solid #ddd; padding: 4px 6px; margin-bottom: 4px; cursor: pointer;\"\r\n                     @onclick=\"() => InsertField(field.text)\">\r\n                    @field.text\r\n                </div>\r\n            }\r\n        </div>\r\n        <div style=\"flex: 1;\">\r\n            <SfDocumentEditorContainer @ref=\"_containerRef\" Height=\"590px\">\r\n                <DocumentEditorContainerEvents Created=\"OnCreated\"></DocumentEditorContainerEvents>\r\n            </SfDocumentEditorContainer>\r\n        </div>\r\n    </div>\r\n</div>\r\n\r\n@code {\r\n    private SfDocumentEditorContainer? _containerRef;\r\n    SfDocumentEditorContainer container;\r\n\r\n    public List<FieldItem> Fields { get; set; } = new List<FieldItem>\r\n    {\r\n        new FieldItem { text = \"FirstName\", Category = \"Recipients\" },\r\n        new FieldItem { text = \"LastName\",  Category = \"Recipients\" },\r\n        new FieldItem { text = \"Address\",   Category = \"Recipients\" },\r\n        new FieldItem { text = \"OrderId\",   Category = \"Orders\" },\r\n    };\r\n\r\n    public async Task OnCreated(object args)\r\n    {\r\n        if (_containerRef?.DocumentEditor != null)\r\n        {\r\n            string text = \"Pick a field on the left to insert a merge field at the cursor position.\";\r\n\r\n            var sfdt = new\r\n            {\r\n                sections = new[]\r\n                {\r\n                    new\r\n                    {\r\n                        blocks = new[]\r\n                        {\r\n                            new\r\n                            {\r\n                                inlines = new[]\r\n                                {\r\n                                    new { text }\r\n                                }\r\n                            }\r\n                        },\r\n                        headerFooter = new { },\r\n                        sectionFormat = new\r\n                        {\r\n                            pageWidth = 612,\r\n                            pageHeight = 792,\r\n                            leftMargin = 72,\r\n                            rightMargin = 72,\r\n                            topMargin = 72,\r\n                            bottomMargin = 72\r\n                        }\r\n                    }\r\n                }\r\n            };\r\n\r\n            string json = JsonSerializer.Serialize(sfdt);\r\n            await _containerRef.DocumentEditor.OpenAsync(json);\r\n            await InvokeAsync(StateHasChanged);\r\n        }\r\n    }\r\n\r\n    // Inserts a MERGEFIELD for the selected item at the current selection.\r\n    private void InsertField(string field)\r\n    {\r\n        if (!string.IsNullOrEmpty(field))\r\n        {\r\n            Console.WriteLine($\"Insert merge field: {field}\");\r\n        }\r\n    }\r\n\r\n    public class FieldItem\r\n    {\r\n        public string text { get; set; } = string.Empty;\r\n        public string Category { get; set; } = string.Empty;\r\n    }\r\n}\r\n"
    }
  ]
}