{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-auto-save",
  "framework": "aspnet-mvc",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "auto-save",
  "dependencies": [
    "Syncfusion.AspNetMvc.DocumentEditor",
    "Syncfusion.AspNetMvc.Buttons"
  ],
  "description": "Document editor that automatically saves document changes through a configurable 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/aspnet-mvc/llms.txt",
    "skillPack": "syncfusion/aspnetmvc-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/aspnet-mvc/docx-editor-auto-save.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-auto-save/DocxEditor.cshtml",
      "content": "@using Syncfusion.EJ2\n@section ControlsSection{\n    <div class=\"col-lg-9 control-section\">\n        <div class=\"flex-container\">\n            <label class=\"switchLabel\" for=\"checked\">Ribbon UI</label>\n            @*<div class=\"e-message render-mode-info\">\n                    <span class=\"e-msg-icon render-mode-info-icon\" title=\"Turn OFF to switch from Ribbon to toolbar UI\"></span>\n                </div>\n                @Html.EJS().Switch(\"toolbarSwitch\").CssClass(\"buttonSwitch\").Change(\"onSwitchChange\").Checked(true).Render()*@\n        </div>\n        <div id='documenteditor_titlebar' class=\"e-de-ctn-title\"></div>\n        @Html.EJS().DocumentEditorContainer(\"container\").Height(\"590px\").EnableToolbar(true).Render()\n    </div>\n    <div class=\"col-lg-3 property-section\">\n        <table id=\"property\" title=\"Auto save log\">\n            <tr>\n                <td>\n                    <div class=\"eventarea\" style=\"height: 245px;overflow: auto\">\n                        <span class=\"AutosaveLog\" id=\"AutosaveLog\" style=\"word-break: normal;\"></span>\n                    </div>\n                </td>\n            </tr>\n            <tr>\n                <td>\n                    <div class=\"evtbtn\" style=\"padding-bottom: 10px\">\n                        @Html.EJS().Button(\"log_clear\").Content(\"Clear\").IsPrimary(false).Render()\n                    </div>\n                </td>\n            </tr>\n        </table>\n    </div>\n    <script src=\"~/Scripts/documenteditor/default-properties.js\"></script>\n}\n\n@section Scripts{\n    <script>\n    var contentChanged = false;\n    var documenteditor;\n    ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar, ej.documenteditor.Ribbon);\n\ndocument.addEventListener('DOMContentLoaded', function () {\n        var documenteditorElement = document.getElementById(\"container\");\n        documenteditorElement.style.height = \"590px\";\n        documenteditorElement.style.width = \"100%\";\n        var container = documenteditorElement.ej2_instances[0];\n            container.toolbarMode = \"Ribbon\";\n        container.showPropertiesPane = true;\n        container.documentEditorSettings.showRuler = true;\n        documenteditor = container.documentEditor;\n        documenteditorElement.ej2_instances[0].serviceUrl = window.baseurl + 'api/documenteditorservice/';\n        documenteditor.serviceUrl = window.baseurl + 'api/documenteditorservice/';\n        var ajax = new ej.base.Ajax(\"@Url.Content(\"~/scripts/documenteditor/data-default.json\")\", 'GET', true);\n        ajax.send().then();\n        ajax.onSuccess = function (data) {\n            documenteditor.open(data);\n            documenteditor.documentName = 'Auto Save';\n            updateDocumentTitle();\n        };\n        titleBarDiv = document.getElementById('documenteditor_titlebar');\n        initComponentAndWireEvent();\n        showButtons(false);\n        var exportItem = {\n            text: 'Export',\n            id: 'custom_item',\n            iconCss: 'e-icons e-export',\n            items: [\n                { id: 'sfdt', text: 'Syncfusion Document Text (*.sfdt)' },\n                { id: 'docx', text: 'Word Document (*.docx)' },\n                { id: 'dotx', text: 'Word Template (*.dotx)' },\n                { id: 'text', text: 'Plain Text (*.txt)' },\n                { id: 'pdf', text: 'PDF (*.pdf)' },\n                { id: 'html', text: 'HyperText Markup Language (*.html)' },\n                { id: 'rtf', text: 'Rich Text Format (*.rtf)' },\n                { id: 'md', text: 'Markdown (*.md)' },\n                { id: 'odt', text: 'OpenDocument Text (*.odt)' },\n                { id: 'wordml', text: 'Word XML Document (*.xml)' },\n            ],\n        };\n        container.fileMenuItems = ['New', 'Open', exportItem, 'Print'];\n        container.fileMenuItemClick = function (args) {\n            if (args.item.id) {\n                var value = args.item.id;\n                var sampleName = container.documentEditor.documentName === '' ? 'sample' : container.documentEditor.documentName;\n                switch (value) {\n                    case 'docx':\n                        container.documentEditor.save(sampleName, 'Docx');\n                        break;\n                    case 'sfdt':\n                        container.documentEditor.save(sampleName, 'Sfdt');\n                        break;\n                    case 'text':\n                        container.documentEditor.save(sampleName, 'Txt');\n                        break;\n                    case 'dotx':\n                        container.documentEditor.save(sampleName, 'Dotx');\n                        break;\n                    case 'pdf':\n                        saveFormat('Pdf');\n                        break;\n                    case 'html':\n                        saveFormat('Html');\n                        break;\n                    case 'odt':\n                        saveFormat('Odt');\n                        break;\n                    case 'md':\n                        saveFormat('Md');\n                        break;\n                    case 'rtf':\n                        saveFormat('Rtf');\n                        break;\n                    case 'wordml':\n                        saveFormat('Xml');\n                        break;\n                }\n            }\n        };\n        container.dataBind();\n\n        container.documentChange = function () {\n            updateDocumentTitle();\n            documenteditor.focusIn();\n        };\n\n        container.contentChange = function() {\n            contentChanged = true;\n        };\n\n        setInterval(() => {\n            if (contentChanged) {\n                //You can save the document as below\n                container.documentEditor.saveAsBlob('Docx').then((blob) => {\n                    var exportedDocumment = blob;\n                    //Now, save the document where ever you want.\n                    /* tslint:disable */\n                    var span = document.createElement('span');\n                    var date = new Date();\n                    var time = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();\n                    span.innerHTML = 'Auto saved at <b>' + time + '</b><hr>';\n                    var log = document.getElementById('AutosaveLog');\n                    log.insertBefore(span, log.firstChild);\n                });\n                contentChanged = false;\n            }\n        }, 15000);\n\n\n        document.getElementById(\"log_clear\").addEventListener('click', function () {\n            document.getElementById('AutosaveLog').innerHTML = '';\n        });\n    });\n\n    function saveFormat(type) {\n        var spinTarget = document.getElementById('container');\n        ej.popups.createSpinner({\n            target: spinTarget\n        });\n        ej.popups.showSpinner(spinTarget);\n        var container = document.getElementById(\"container\").ej2_instances[0];\n        var format = type;\n        var url = window.baseurl + 'api/documenteditorservice/Export';\n        var http = new XMLHttpRequest();\n        http.open('POST', url);\n        http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');\n        var sfdt = {\n            Content: container.documentEditor.serialize(),\n            Filename: container.documentEditor.documentName,\n            Format: '.' + format\n        };\n        http.onload = function () {\n            if (http.status === 200) {\n                var responseData = http.response;\n                var downloadLink = document.createElement('a');\n                downloadLink.href = responseData;\n                downloadLink.download = container.documentEditor.documentName + '.' + (format).toLowerCase();\n                document.body.appendChild(downloadLink);\n                ej.popups.hideSpinner(spinTarget);\n                downloadLink.click();\n                document.body.removeChild(downloadLink);\n            }\n            else {\n                console.error('Request failed with status:', http.status);\n                ej.popups.hideSpinner(spinTarget);\n            }\n        };\n        http.send(JSON.stringify(sfdt));\n    }\n    </script>\n}\n\n<style>\n    #container {\n        display: block;\n        height: 500px;\n    }\n\n    .flex-container {\n        display: flex;\n        justify-content: flex-end;\n        align-items: center;\n    }\n\n    .render-mode-info {\n        background: none;\n        border: none;\n        padding-left: 0px;\n    }\n\n        .render-mode-info .render-mode-info-icon {\n            height: 16px;\n            width: 16px;\n        }\n\n    .switchLabel {\n        font-family: \"Segoe UI\", \"GeezaPro\", \"DejaVu Serif\", sans-serif;\n        font-weight: 400;\n        line-height: 20px;\n        letter-spacing: 0.24px;\n        text-align: right;\n        font-size: 14px;\n        margin-bottom: 0px;\n    }\n\n    .render-mode-info .render-mode-info-icon::before {\n        line-height: normal;\n    }\n\n    .buttonSwitch {\n        Width: 40px;\n        Height: 24px;\n    }\n\n    #documenteditor_titlebar {\n        border-bottom: 1px solid #2B3481;\n        height: 36px;\n        line-height: 26px;\n        width: 100%;\n        font-size: 12px;\n        padding-left: 15px;\n        padding-right: 10px;\n        font-family: inherit;\n    }\n\n    #documenteditor_title_contentEditor {\n        height: 26px;\n        max-width: 85%;\n        width: auto;\n        overflow: hidden;\n        display: inline-block;\n        padding-left: 4px;\n        padding-right: 4px;\n        margin: 5px;\n    }\n\n\n    .single-line {\n        cursor: text !important;\n        outline: none;\n    }\n\n        .single-line:hover {\n            border-color: #e4e4e4 !important;\n        }\n\n    [contenteditable=\"true\"].single-line {\n        white-space: nowrap;\n        border-color: #e4e4e4 !important;\n    }\n\n    #AutosaveLog b {\n        color: #388e3c;\n    }\n\n\n    /** Document editor sample level font icons*/\n\n    @@font-face {\n        font-family: 'Sample brower icons';\n        font-weight: normal;\n        font-style: normal;\n    }\n\n    [class^=\"e-de-icon-\"],\n    [class*=\" e-de-icon-\"] {\n        font-family: 'Sample brower icons' !important;\n    }\n\n    .e-de-icon-Print:before {\n        content: \"\\e723\";\n    }\n\n    .e-de-icon-Download:before {\n        content: \"\\e728\";\n    }\n\n    /** sample level font icons ends*/\n</style>"
    },
    {
      "target": "src/components/docx-editor-auto-save/DocxEditorController.cs",
      "content": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Web;\nusing System.Web.Mvc;\n\nnamespace EJ2MVCSampleBrowser.Controllers.DocumentEditor\n{\n    public partial class DocumentEditorController : Controller\n    {\n        // GET: AutoSave\n        public ActionResult AutoSave()\n        {\n            this.DocumentEditorViewResultHelper();\n            return View(\"~/Views/Home/docx-editor/auto-save/DocxEditor.cshtml\");\n        }\n    }\n}"
    }
  ]
}