> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Permission Ranges extension

export const SourceCodeLink = ({extension, path}) => {
  const githubPath = path || `packages/super-editor/src/editors/v1/extensions/${extension.toLowerCase()}`;
  const githubUrl = `https://github.com/superdoc-dev/superdoc/tree/main/${githubPath}`;
  return <div>
      <p>
        <a href={githubUrl} target="_blank" rel="noopener noreferrer">
          View on GitHub →
        </a>
      </p>
    </div>;
};

Control which document regions are editable based on user permissions from Word permission ranges.

When a Word document contains permission ranges (`w:permStart`/`w:permEnd`), SuperDoc automatically restricts editing to the allowed regions for the current user.

## How it works

Permission ranges define editable regions within a protected Word document. The extension:

1. Parses `permStart` and `permEnd` markers from the document
2. Matches the current user's email against the `ed` (specific editor) or `edGrp` (editor group) attributes
3. Allows edits only within matched permission ranges
4. Blocks edits outside permitted regions

When a document is in viewing mode and has permission ranges matching the current user, the extension automatically enables editing within those ranges.

## Permission matching

Ranges can target specific users or groups:

```xml theme={null}
<!-- Allow everyone to edit -->
<w:permStart w:id="0" w:edGrp="everyone"/>
<w:permEnd w:id="0"/>

<!-- Allow a specific user -->
<w:permStart w:id="1" w:ed="domain\username"/>
<w:permEnd w:id="1"/>
```

The `ed` attribute uses the format `domain\username`, matched against the user email configured in SuperDoc.

## Word export

Permission ranges export as native Word permission markers:

```xml theme={null}
<w:permStart w:id="0" w:edGrp="everyone"/>
<w:r>
  <w:t>Editable content here</w:t>
</w:r>
<w:permEnd w:id="0"/>
```

## Source code

<SourceCodeLink path="packages/super-editor/src/editors/v1/extensions/permission-ranges/permission-ranges.js" />
