# docx-editor-document-protection

> Word document editor with restrict-editing protection, current user, and editing envelope.

**Framework:** react  **Component:** DocxEditor  **Variant:** document-protection

## Get this item

**If you are an agent, fetch the JSON.** Source is inlined, so one request is enough and no tooling is required:

```
GET https://ai.syncfusion.com/r/react/ts/docx-editor-document-protection.json
```

**Install Package(s)**

```bash
npm install @syncfusion/ej2-react-documenteditor @syncfusion/ej2-react-buttons
```

**Notes**

- Syncfusion release: 2026 Volume 2 (v34.1.29)
- The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md

## Source files

### src/components/docx-editor-document-protection/DocxEditor.tsx

```tsx
import { useEffect, useRef } from 'react';
import { DocumentEditorContainerComponent, Toolbar, Ribbon } from '@syncfusion/ej2-react-documenteditor';
import { dataProtection } from './datasource';
import { SwitchComponent } from '@syncfusion/ej2-react-buttons';
DocumentEditorContainerComponent.Inject(Toolbar,Ribbon);
const SAMPLE_CSS = `
.flex-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.render-mode-info {
    background: none;
    border: none;
    padding-left: 0px;
}

.render-mode-info .render-mode-info-icon {
    height: 16px;
    width: 16px;
}

.switchLabel {
    font-family: "Segoe UI", "GeezaPro", "DejaVu Serif", sans-serif;
    font-weight: 400;
    line-height: 20px;
    letter-spacing: 0.24px;
    text-align: right;
    font-size: 14px;
    margin-bottom: 3px;
}

.render-mode-info .render-mode-info-icon::before {
    line-height: normal;
}

.buttonSwitch {
    Width: 40px;
    Height: 24px;
}

body {
    margin: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
}`;

const DocumentProtection = () => {
    useEffect(() => {
        rendereComplete();
    }, []);
    let hostUrl: string =
        "https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/";
    let container = useRef<DocumentEditorContainerComponent>(null);
    let settings={showRuler: true};
    const onLoadDefault = (): void => {
        container.current.documentEditor.open(JSON.stringify(dataProtection));
        container.current.documentEditor.documentName = "Document Protection";
        container.current.documentChange = (): void => {
            container.current.documentEditor.focusIn();
        };
    };
    const rendereComplete = (): void => {
        container.current.showPropertiesPane = false;
        container.current.documentEditor.currentUser = "engineer@mycompany.com";
        // container.documentEditor.pageOutline = '#E0E0E0';
        // container.documentEditor.acceptTab = true;
        container.current.documentEditor.resize();
        onLoadDefault();
    };
    const change = (args):void=>{
        if (args.checked) {
            container.current.toolbarMode = 'Ribbon';
        }
        else {
            container.current.toolbarMode = 'Toolbar';
        }
    }
    return (
        <div className="control-pane">
            <style>{SAMPLE_CSS}</style>
            <div className="col-lg-9 control-section">
                <div className="flex-container">
                                  <label className="switchLabel" htmlFor="toolbarSwitch">Ribbon UI</label>
                            <div className="e-message render-mode-info">
                                <span className="e-msg-icon render-mode-info-icon" title="Turn OFF to switch from Ribbon to toolbar UI"></span>
                            </div>
                                <SwitchComponent cssClass="buttonSwitch" id="toolbarSwitch" change={change} checked={true}></SwitchComponent>
                                </div>
                <div id="documenteditor_container_body">
                    <DocumentEditorContainerComponent
                        id="container"
                        ref={container}
                        style={{ display: "block" }}
                                                height={"590px"}
                        toolbarMode= {"Ribbon"}
                        serviceUrl={hostUrl}
                        enableToolbar={true}
                        locale="en-US"
                        documentEditorSettings={settings}
                    />
                </div>
            </div>
        </div>
    );
}
export default DocumentProtection;
```

### src/components/docx-editor-document-protection/datasource.ts

```typescript
export let dataProtection = { "sfdt": "UEsDBAoAAAAIAEVevla6Oz6icAcAAFUqAAAEAAAAc2ZkdO1aS2/bRhD+KwR7rJvq7dhAgPohWX4LtmM3TX1YUktxZXKXIVeWFUNAkJx6KVAgLVqgAXrroSgaoAEa9NL/UgMO2vRHdGaX1MORHDmWHceJDXjIndndmW+/nX3Qh6YIJPPZfbrpVKU5LcMGnTAjapvTdw9NkEFoTh+aQdOcLqQzE2bgmtOTU/Dg+fAAMoyljKUVy6oTmNMpkILqB7dqTmcLE6YTS4upYgt6Mtdos0Jq1IT2azyCgpmQWMyGd24LDwrSEya911TSs6StamrN3d02NKK8DRx01aqGEUoJ3R6CzpNahjUtrfjd1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