Skip to content

Commit 411d855

Browse files
authored
Merge pull request #503 from Harbour-Enterprises/feature/har-9685-superdoc-update-docs-documentmode
docs: update docs with proper documentMode + file format
2 parents e11eabc + 06cf304 commit 411d855

2 files changed

Lines changed: 34 additions & 8 deletions

File tree

docs/src/components/index.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ const superdoc = new SuperDoc({
4949
| `selector` | `string\|Element` | CSS selector or DOM element where SuperDoc will be rendered || - |
5050
| `documents` | `array` | Array of document objects to load || - |
5151
| `superdocId` | `string` | Unique identifier for this SuperDoc instance | | Random UUID |
52-
| `documentMode` | `string` | Initial mode: 'viewing' or 'editing' | | 'viewing' |
52+
| `documentMode` | `string` | Document mode: 'viewing', 'suggesting', or 'editing' | | 'editing' |
53+
| `role` | `string` | User role: 'editor', 'suggester', or 'viewer' | | 'editor' |
5354
| `user` | `object` | Current user information | | {} |
5455
| `toolbar` | `string\|Element` | DOM element to render toolbar | | Internal toolbar |
5556
| `modules` | `object` | Additional modules configuration | | {} |
@@ -91,7 +92,7 @@ modules: {
9192
| Method | Parameters | Return | Description |
9293
| :------------------------------------ | :-------------------------------- | :-------------- | :---------------------------------------------------------- |
9394
| `export()` | - | `Promise<Void>` | Exports the SuperDocs and triggers download |
94-
| `setDocumentMode(mode)` | mode: 'viewing' or 'editing' | - | Switches between view and edit modes |
95+
| `setDocumentMode(mode)` | mode: 'viewing', 'suggesting', or 'editing' | - | Switches between view, suggest, and edit modes |
9596
| `on(event, callback)` | event: string, callback: function | - | Registers an event listener |
9697
| `off(event, callback)` | event: string, callback: function | - | Removes an event listener |
9798
| `getHTML()` | - | - | Get a list of HTML strings (one per DOCX document) |
@@ -103,7 +104,7 @@ modules: {
103104
| onEditorBeforeCreate | - | Called **before** the document editor is created. |
104105
| onEditorCreate | `{ editor }` | Called when the document editor is created. |
105106
| onEditorDestroy | - | Called when the document editor is destroyed. |
106-
| onContentError | `{ error, editor }` | Called when theres an error with document content. |
107+
| onContentError | `{ error, editor }` | Called when there's an error with document content. |
107108
| onReady | - | Called when the document is fully initialized and ready.|
108109
| onAwarenessUpdate | `{ users }` | Called when user presence information changes. |
109110
| onPdfDocumentReady | - | Called when the PDF version of the document is ready. |
@@ -151,8 +152,8 @@ const editor = new SuperEditor({
151152
| :---------------------- | :--------- | :------------------------------------- | :------------- |
152153
| `user` | `object` | Current user information | {} |
153154
| `colors` | `object` | Theme color configuration | Default colors |
154-
| `role` | `string` | User role: 'editor', 'viewer', 'admin' | 'editor' |
155-
| `documentMode` | `string` | 'viewing' or 'editing' | 'viewing' |
155+
| `role` | `string` | User role: 'editor', 'suggester', 'viewer' | 'editor' |
156+
| `documentMode` | `string` | 'editing', 'viewing', or 'suggesting' | 'viewing' |
156157
| `pagination` | `boolean` | Enable pagination | true |
157158
| `rulers` | `array` | Document ruler configuration | [] |
158159
| `ydoc` | `Y.Doc` | Yjs document for collaboration | null |

docs/src/index.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,21 @@ const config = {
8787
// Required: A DOM element ID to render superdoc into
8888
selector: '#superdoc',
8989

90-
// Optional: Initial document mode: viewing, editing. Defaults to viewing
90+
// Optional: Initial document mode: viewing, suggesting,editing. Defaults to editing
9191
documentMode: 'editing',
9292

93+
// Optional: User role: editor, suggester, viewer. Defaults to editor
94+
role: 'editor',
95+
9396
// Required: Documents list with one document
9497
documents: [
9598
{
9699
id: 'my-doc-id', // Required: This document's ID. This is also used as the room name in collaboration.
97100
type: 'docx', // Required: 'pdf', 'docx' or 'html'
98-
data: fileObject, // Optional: A JS File object of your doc, pdf or html file.
101+
102+
// Document content - provide EITHER data OR url:
103+
data: fileObject, // Option 1: A JS File/Blob object of your document
104+
url: 'https://example.com/document.docx', // Option 2: URL to fetch the document from
99105
},
100106
],
101107

@@ -144,6 +150,24 @@ const config = {
144150
};
145151
```
146152

153+
## Document Modes and Roles
154+
155+
SuperDoc supports different document modes and user roles to control editing capabilities:
156+
157+
### Document Modes
158+
159+
- **editing** - Full document editing capabilities
160+
- **viewing** - Read-only mode with no editing allowed
161+
- **suggesting** - Track changes mode where edits are shown as suggestions
162+
163+
### User Roles
164+
165+
- **editor** - Users with full editing capabilities who can access all document modes
166+
- **suggester** - Users who can only make suggestions (track changes) but cannot directly edit
167+
- **viewer** - Users with read-only access who can only view the document
168+
169+
The user's role restricts which document modes they can access. For example, a user with the "viewer" role will always be in viewing mode regardless of the requested document mode.
170+
147171
## Project Structure
148172

149173
SuperDoc consists of two main packages:
@@ -196,8 +220,9 @@ superdoc.off('ready', myReadyHandler);
196220
// Export the document as DOCX
197221
await superdoc.export();
198222

199-
// Switch between viewing and editing modes
223+
// Switch between viewing, suggesting, and editing modes
200224
superdoc.setDocumentMode('viewing');
225+
superdoc.setDocumentMode('suggesting');
201226
superdoc.setDocumentMode('editing');
202227

203228
// Get a list of HTML strings (one per DOCX editor)

0 commit comments

Comments
 (0)