{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-form-fields",
  "framework": "vue",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "form-fields",
  "dependencies": [
    "@syncfusion/ej2-vue-buttons",
    "@syncfusion/ej2-vue-documenteditor",
    "@syncfusion/ej2-vue-popups",
    "@syncfusion/ej2-vue-splitbuttons"
  ],
  "description": "Word editor loads a form-fields document with fillable form content and spinner loading.",
  "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": true,
    "platformIndex": "https://ai.syncfusion.com/vue/llms.txt",
    "skillPack": "syncfusion/vue-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/vue/docx-editor-form-fields.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-form-fields/DocxEditor.vue",
      "content": "<template>\n    <div class=\"control-section\">\n  \n    <div class=\"sample-container\">\n        <div class=\"default-section\">\n            <div ref=\"de_titlebar\" id=\"documenteditor_titlebar\" class=\"e-de-ctn-title\">\n                <div v-on:keydown=\"titleBarKeydownEvent\" v-on:click=\"titleBarClickEvent\" class=\"single-line\" id=\"documenteditor_title_contentEditor\" title=\"Document Name. Click or tap to rename this document.\" contenteditable=\"false\">\n                    <label v-on:blur=\"titleBarBlurEvent\" id=\"documenteditor_title_name\" :style=\"titileStyle\" >{{documentName}}</label>\n                </div>    \n                <ejs-button ref=\"de-print\" id=\"de-print\" :style=\"iconStyle\" :iconCss=\"printIconCss\" v-on:click=\"printBtnClick\" title=\"Print this document (Ctrl+P).\">Print</ejs-button>\t\n                <ejs-dropdownbutton ref=\"de-export\" :style=\"iconStyle\" :items=\"exportItems\" :iconCss=\"exportIconCss\" cssClass=\"e-caret-hide\" content=\"Download\" v-bind:select=\"onExport\" :open=\"openExportDropDown\" title=\"Download this document.\"></ejs-dropdownbutton>        \n            </div>\n            <div style=\"display:block; height: calc(100vh - 230px);\">\n            <ejs-documenteditorcontainer ref=\"doceditcontainer\" :toolbarMode=\"'Ribbon'\" :serviceUrl=\"hostUrl\" :documentEditorSettings=\"settings\" :enableToolbar='true' :fileMenuItems=\"fileMenuItems\" :fileMenuItemClick=\"fileMenuItemClick\" height='100%'></ejs-documenteditorcontainer>\n            </div>\n        </div>\n    </div>\n</div>\n</template>\n<style>\n#documenteditor_titlebar {\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[contenteditable=\"true\"].single-line {\n    white-space: nowrap;\n    border-color: #e4e4e4 !important;\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</style>\n<script>\nimport { DocumentEditorContainerComponent,Toolbar, Ribbon } from \"@syncfusion/ej2-vue-documenteditor\";\nimport { DropDownButtonComponent } from \"@syncfusion/ej2-vue-splitbuttons\";\nimport { createSpinner, showSpinner, hideSpinner } from \"@syncfusion/ej2-vue-popups\";\nimport { formfields } from \"../datasource/docx-editor-data\";\nimport { ButtonComponent } from \"@syncfusion/ej2-vue-buttons\";\nimport \"../style.css\";\n\nexport default {\n    components: {\n        'ejs-documenteditorcontainer': DocumentEditorContainerComponent,\n        'ejs-dropdownbutton': DropDownButtonComponent,\n        'ejs-button': ButtonComponent\n    },\n    data: function() {\n        return {\n          hostUrl : 'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/',\n          settings: {showRuler: true},\n          documentName : 'Form  Fields',\n          documentTitle: 'Untitled Document',\n          iconStyle: 'float:right;background: transparent;box-shadow:none;border-color: transparent;border-radius: 2px;color:inherit;font-size:12px;text-transform:capitalize;margin-top:4px;height:28px;font-weight:400;font-family:inherit;',\n            titileStyle: 'text-transform:capitalize;font-weight:400;font-family:inherit;text-overflow:ellipsis;white-space:pre;overflow:hidden;user-select:none;cursor:text',\n            openIconCss: 'e-de-icon-Open e-de-padding-right',\n            printIconCss: 'e-de-icon-Print e-de-padding-right',\n            exportIconCss: 'e-de-icon-Download e-de-padding-right',\n            exportItems: [\n                { text: 'Syncfusion Document Text (*.sfdt)', id: 'sfdt' },\n                { text: 'Word Document (*.docx)', id: 'word' },\n                { text: 'Word Template (*.dotx)', id: 'dotx' },\n                { text: 'Plain Text (*.txt)', id: 'txt' },\n            ],\n            fileMenuItems: [\n                'New',\n                'Open',\n                {\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                'Print',\n            ]\n        };\n    },  \n    provide:{\n        DocumentEditorContainer:[Toolbar,Ribbon]\n    },\n      methods: {\n        fileMenuItemClick: function (args) {\n            if (args.item.id) {\n                let value = args.item.id;\n                let documentEditor = this.$refs.doceditcontainer.ej2Instances.documentEditor;\n                switch (value) {\n                    case 'docx':\n                        documentEditor.save(documentEditor.documentName === '' ? 'sample' : documentEditor.documentName, 'Docx');\n                        break;\n                    case 'sfdt':\n                        documentEditor.save(documentEditor.documentName === '' ? 'sample' : documentEditor.documentName, 'Sfdt');\n                        break;\n                    case 'text':\n                        documentEditor.save(documentEditor.documentName === '' ? 'sample' : documentEditor.documentName, 'Txt');\n                        break;\n                    case 'dotx':\n                        documentEditor.save(documentEditor.documentName === '' ? 'sample' : documentEditor.documentName, 'Dotx');\n                        break;\n                    case 'pdf':\n                        this.formatSave('Pdf');\n                        break;\n                    case 'html':\n                        this.formatSave('Html');\n                        break;\n                    case 'odt':\n                        this.formatSave('Odt');\n                        break;\n                    case 'md':\n                        this.formatSave('Md');\n                        break;\n                    case 'rtf':\n                        this.formatSave('Rtf');\n                        break;\n                    case 'wordml':\n                        this.formatSave('Xml');\n                        break;\n                }\n            }\n        },\n        onExport: function (args) {\n            switch (args.item.id) {\n                case 'word':\n                    this.save('Docx');\n                    break;\n                case 'sfdt':\n                    this.save('Sfdt');\n                    break;\n                case 'txt':\n                    this.save('Txt');\n                    break;\n                case 'dotx':\n                    this.save('Dotx');\n                    break;\n            }\n        },\n        openExportDropDown: function () {\n            // tslint:disable-next-line:max-line-length\n            document.getElementById('word').setAttribute('title', 'Download a copy of this document to your computer as a DOCX file.');\n            // tslint:disable-next-line:max-line-length\n            document.getElementById('sfdt').setAttribute('title', 'Download a copy of this document to your computer as an SFDT file.');\n            // tslint:disable-next-line:max-line-length\n            document.getElementById('txt').setAttribute('title', 'Download a copy of this document to your computer as a TXT file.');\n            // tslint:disable-next-line:max-line-length\n            document.getElementById('dotx').setAttribute('title', 'Download a copy of this document to your computer as a DOTX file.');\n        },\n        save: function (format) {\n            // tslint:disable-next-line:max-line-length\n             this.$refs.doceditcontainer.ej2Instances.documentEditor.save( this.$refs.doceditcontainer.ej2Instances.documentEditor.documentName === '' ? 'sample' :  this.$refs.doceditcontainer.ej2Instances.documentEditor.documentName, format);\n        },\n        formatSave: function (type) {\n            let documentEditor = this.$refs.doceditcontainer.ej2Instances.documentEditor;\n            let containerElement = this.$refs.doceditcontainer.ej2Instances.element;\n            createSpinner({ target: containerElement });\n            showSpinner(containerElement);\n            let format = type;\n            let url = documentEditor.serviceUrl + 'Export';\n            let http = new XMLHttpRequest();\n            http.open('POST', url);\n            http.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');\n            http.responseType = 'blob';\n            let sfdt = {\n                Content: documentEditor.serialize(),\n                Filename: documentEditor.documentName,\n                Format: '.' + format,\n            };\n            http.onload = function () {\n                if (http.status === 200) {\n                    let responseData = http.response;\n                    let blobUrl = URL.createObjectURL(responseData);\n                    let downloadLink = document.createElement('a');\n                    downloadLink.href = blobUrl;\n                    downloadLink.download = documentEditor.documentName + '.' + format.toLowerCase();\n                    document.body.appendChild(downloadLink);\n                    hideSpinner(containerElement);\n                    downloadLink.click();\n                    document.body.removeChild(downloadLink);\n                    URL.revokeObjectURL(blobUrl);\n                } else {\n                    console.error('Request failed with status:', http.status);\n                    hideSpinner(containerElement);\n                }\n            };\n            http.send(JSON.stringify(sfdt));\n        },\n        openBtnClick: function () {\n            this.$refs.uploadDocument.click();\n        },\n        printBtnClick: function () {\n            this.$refs.doceditcontainer.ej2Instances.documentEditor.print();\n        },\n        titleBarKeydownEvent: function (e) {\n            if (e.keyCode === 13) {\n                e.preventDefault();\n                document.getElementById(\"documenteditor_title_contentEditor\").contentEditable = 'false';\n                if (document.getElementById(\"documenteditor_title_contentEditor\").textContent === '') {\n                    document.getElementById(\"documenteditor_title_contentEditor\").textContent = 'Document1';\n                }\n            }\n        },\n        titleBarBlurEvent: function (args) {\n            if (document.getElementById(\"documenteditor_title_contentEditor\").textContent === '') {\n                document.getElementById(\"documenteditor_title_contentEditor\").textContent = 'Document1';\n            }\n            document.getElementById(\"documenteditor_title_contentEditor\").contentEditable = 'false';\n            this.$refs.doceditcontainer.ej2Instances.documentEditor.documentName = document.getElementById(\"documenteditor_title_name\").textContent;\n        },\n        titleBarClickEvent: function () {\n            this.updateDocumentEditorTitle();\n        },\n        updateDocumentEditorTitle: function () {\n            document.getElementById(\"documenteditor_title_contentEditor\").contentEditable = 'true';\n            document.getElementById(\"documenteditor_title_contentEditor\").focus();\n            window.getSelection().selectAllChildren(document.getElementById(\"documenteditor_title_contentEditor\"));\n        },\n        documentChangedEvent: function () {\n            var obj = this.$refs.doceditcontainer.ej2Instances.documentEditor;\n            this.documentTitle = obj.documentName === '' ? 'Untitled Document' : obj.documentName;\n            document.getElementById(\"documenteditor_title_name\").textContent = obj.documentName ;\n            setTimeout(() => { obj.scrollToPage(1); }, 10);\n        }\n    },\n    mounted() {\n        this.$nextTick(function () {\n          var obj = this.$refs.doceditcontainer.ej2Instances.documentEditor;\n          obj.open(JSON.stringify(formfields));\n          obj.documentName='Form  Fields';\n          this.$refs.doceditcontainer.ej2Instances.documentEditorSettings.showRuler = true;\n\t\t  this.$refs.doceditcontainer.ej2Instances.showPropertiesPane = false;\n          this.$refs.doceditcontainer.ej2Instances.documentChange = () => {\n                this.documentChangedEvent();\n            };\n       });\n    }\n};\n</script>"
    }
  ]
}