{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-auto-save",
  "framework": "blazor",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "auto-save",
  "dependencies": [
    "Syncfusion.Blazor.WordProcessor"
  ],
  "description": "Document editor that auto-saves changes to a configured server endpoint.",
  "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-auto-save.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-auto-save/DocxEditor.razor",
      "content": "@page \"/document-editor/auto-save\"\r\n@namespace blazor.Components.Pages.AutoSave.AutoSave\r\n@using System.Text.Json\r\n@using Syncfusion.Blazor.Buttons;\r\n@using Syncfusion.Blazor.DocumentEditor;\r\n\r\n<div class=\"control-section\">\r\n    <div class=\"flex-container\">\r\n        <label class=\"switchLabel\">Ribbon UI</label>\r\n        <SfSwitch CssClass=\"buttonSwitch\" @bind-Checked=\"RibbonMode\" OnChange=\"OnSwitchChange\"></SfSwitch>\r\n    </div>\r\n    <div id='documenteditor_titlebar' class=\"e-de-ctn-title\">\r\n        <div class=\"single-line\" id=\"documenteditor_title_contentEditor\" style=\"border: 1px solid transparent;\" title=\"Document Name.\" contenteditable=\"false\">\r\n            <label id=\"documenteditor_title_name\" class=\"doc-edit-title\">@DocumentName</label>\r\n        </div>\r\n        <div style=\"float: right\">\r\n            <SfButton IconCss=\"e-de-icon-Print\" CssClass=\"title-bar-btn\" @onclick=\"Print\">Print</SfButton>\r\n        </div>\r\n    </div>\r\n    <SfDocumentEditorContainer @ref=\"_containerRef\" Height=\"590px\" DocumentEditorSettings=\"_settings\">\r\n        <DocumentEditorContainerEvents Created=\"OnCreated\" DocumentChanged=\"OnDocumentChange\"></DocumentEditorContainerEvents>\r\n    </SfDocumentEditorContainer>\r\n</div>\r\n\r\n@code {\r\n    internal string? DocumentName { get; set; } = \"Auto Save\";\r\n    internal bool RibbonMode { get; set; } = true;\r\n    private SfDocumentEditorContainer? _containerRef;\r\n    private DocumentEditorSettingsModel _settings = new DocumentEditorSettingsModel { ShowRuler = true };\r\n    private System.Timers.Timer? _timer;\r\n\r\n    protected override void OnInitialized()\r\n    {\r\n        // Poll for content changes and record a timestamp in the console\r\n        // whenever the document is considered saved.\r\n        _timer = new System.Timers.Timer(15000);\r\n        _timer.Elapsed += (s, e) => InvokeAsync(() => Console.WriteLine($\"Auto saved at {DateTime.Now:HH:mm:ss}\"));\r\n        _timer.Start();\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 = \"Start typing here. The document is saved automatically every 15 seconds.\";\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    public void OnDocumentChange()\r\n    {\r\n        var name = _containerRef?.DocumentEditor?.DocumentName;\r\n        if (!string.IsNullOrEmpty(name))\r\n        {\r\n            DocumentName = name;\r\n        }\r\n    }\r\n\r\n    public void OnSwitchChange(ChangeEventArgs<bool> args)\r\n    {\r\n        RibbonMode = args.Checked;\r\n    }\r\n\r\n    public void Print(object args)\r\n    {\r\n        _containerRef?.DocumentEditor?.PrintAsync();\r\n    }\r\n\r\n    public void Dispose()\r\n    {\r\n        _timer?.Dispose();\r\n    }\r\n}\r\n"
    }
  ]
}