{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "docx-editor-form-fields",
  "framework": "react",
  "type": "registry:component",
  "component": "DocxEditor",
  "variant": "form-fields",
  "dependencies": [
    "@syncfusion/ej2-react-documenteditor",
    "@syncfusion/ej2-popups"
  ],
  "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/react/llms.txt",
    "skillPack": "syncfusion/react-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/react/ts/docx-editor-form-fields.md"
  },
  "files": [
    {
      "target": "src/components/docx-editor-form-fields/DocxEditor.tsx",
      "content": "import { useEffect, useRef } from 'react';\nimport { DocumentEditorContainerComponent, Ribbon, Toolbar } from '@syncfusion/ej2-react-documenteditor';\nimport { formfields } from '../datasource/docx-editor-data';\nimport { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';\nimport { TitleBar } from '../title-bar';\nimport '../default.component.css';\n\nDocumentEditorContainerComponent.Inject(Toolbar, Ribbon);\n\nconst FormFields = () => {\n    useEffect(() => {\n        rendereComplete();\n    }, [])\n    const hostUrl: string =\n        \"https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/\";\n    let container = useRef<DocumentEditorContainerComponent>(null);\n    let titleBar: TitleBar;\n    let settings = { showRuler: true };\n    const onLoadDefault = (): void => {\n        if (!container.current) return;\n        container.current.documentEditor.open(JSON.stringify(formfields));\n        container.current.documentEditor.documentName = \"Form Fields\";\n        titleBar.updateDocumentTitle();\n        container.current.documentChange = (): void => {\n            if (!container.current) return;\n            titleBar.updateDocumentTitle();\n            container.current.documentEditor.focusIn();\n        };\n    };\n    const rendereComplete = (): void => {\n        if (!container.current) return;\n        container.current.documentEditor.pageOutline = \"#E0E0E0\";\n        container.current.documentEditor.acceptTab = true;\n        container.current.documentEditor.resize();\n        const titleBarElement = document.getElementById(\"documenteditor_titlebar\");\n        if (titleBarElement) {\n            titleBar = new TitleBar(\n                titleBarElement,\n                container.current.documentEditor,\n                true\n            );\n        }\n        onLoadDefault();\n        titleBar.showButtons(false);\n    };\n    \n        const fileMenuItemClick = (args:any): void => {\n            if (!container.current) return;\n            if (args.item.id) {\n                let value: string = args.item.id;\n                let sampleName: string = container.current.documentEditor.documentName === '' ? 'sample' : container.current.documentEditor.documentName;\n                switch (value) {\n                    case 'docx':\n                        container.current.documentEditor.save(sampleName, 'Docx');\n                        break;\n                    case 'sfdt':\n                        container.current.documentEditor.save(sampleName, 'Sfdt');\n                        break;\n                    case 'text':\n                        container.current.documentEditor.save(sampleName, 'Txt');\n                        break;\n                    case 'dotx':\n                        container.current.documentEditor.save(sampleName, 'Dotx');\n                        break;\n                    case 'pdf':\n                        formatSaveLocal('Pdf');\n                        break;\n                    case 'html':\n                        formatSaveLocal('Html');\n                        break;\n                    case 'odt':\n                        formatSaveLocal('Odt');\n                        break;\n                    case 'md':\n                        formatSaveLocal('Md');\n                        break;\n                    case 'rtf':\n                        formatSaveLocal('Rtf');\n                        break;\n                    case 'wordml':\n                        formatSaveLocal('Xml');\n                        break;\n                }\n            }\n        }\n    \n        const formatSaveLocal = (type: string): void => {\n            if (!container.current) return;\n            createSpinner({\n                target: document.getElementById('container')!\n            });\n            showSpinner(document.getElementById('container')!);\n            let format: string = type;\n            let url = container.current.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\n            let sfdt = {\n                Content: container.current.documentEditor.serialize(),\n                Filename: container.current.documentEditor.documentName,\n                Format: '.' + format,\n            };\n\n            http.onload = (): void => {\n                if (http.status === 200) {\n                    if (!container.current) return;\n                    let responseData = http.response;\n                    let blobUrl = URL.createObjectURL(responseData);\n                    let downloadLink = document.createElement('a');\n                    downloadLink.href = blobUrl;\n                    downloadLink.download = container.current.documentEditor.documentName + '.' + format.toLowerCase();\n                    document.body.appendChild(downloadLink);\n                    hideSpinner(document.getElementById('container')!);\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(document.getElementById('container')!);\n                }\n            };\n\n            http.send(JSON.stringify(sfdt));\n        }\n    return (\n        <div className=\"control-pane\">\n            <div className=\"control-section\">\n                <div id=\"documenteditor_titlebar\" className=\"e-de-ctn-title\"></div>\n                <div id=\"documenteditor_container_body\" style={{\"display\":\"block\", \"height\": \"calc(100vh - 230px)\"}}>\n                    <DocumentEditorContainerComponent\n                        id=\"container\"\n                        ref={container}\n                        style={{ display: \"block\" }}\n                        height={\"100%\"}\n                        toolbarMode= {\"Ribbon\"}\n                        serviceUrl={hostUrl}\n                        enableToolbar={true}\n                        showPropertiesPane={false}\n                        locale=\"en-US\"\n                        documentEditorSettings={settings}\n                        fileMenuItems={['New', 'Open', {\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                        }, 'Print']}\n                        fileMenuItemClick={fileMenuItemClick}\n                    />\n                </div>\n            </div>\n        </div>\n    );\n}\nexport default FormFields;\n"
    }
  ]
}