myrole-docx-editor 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,6 +65,7 @@ badge display also respond to prop changes. `ref.current` is the same handle
65
65
  | `zoom` | `1` | |
66
66
  | `rulers`, `statusBar` | `true` | |
67
67
  | `panel` | `null` | `'navigation'`, `'properties'`, `'variables'` or `'inspector'` |
68
+ | `ui` | all enabled | `{ open: false, export: false, sidePanel: false }` disables file opening, UI exports and right-side panels; configured at mount |
68
69
  | `values` | sample set | values for the generated-document preview |
69
70
  | `library` | – | `{ fields: [{ path, label?, desc? }], snippets: [{ id, title, code, category?, desc? }], builtinSnippets? }` — offered in the Bibliothèque panel, the ribbon's Variable button and the autocompletion, before what the document already uses |
70
71
  | `comments` | `true` | Word's comments as marks on the text; click one for its balloon; « Commentaires » on the Affichage tab toggles them |
@@ -72,6 +73,12 @@ badge display also respond to prop changes. `ref.current` is the same handle
72
73
 
73
74
  ## Handle
74
75
 
76
+ `ui.sidePanel: false` keeps left-side navigation/search available and disables
77
+ right-panel entry points in the toolbar, ribbon, context menu and badges.
78
+ `ui.export: false` requires `onSave` or `draftKey` for Ctrl/⌘S; the host's
79
+ `load`, `save` and `download` APIs remain available. These options configure
80
+ the interface and do not replace server-side permissions.
81
+
75
82
  ```ts
76
83
  editor.load(src) editor.save(): Uint8Array editor.download('contrat.docx')
77
84
  editor.editor // the low-level editor: commands, selection, format, undo…
@@ -182,3 +189,32 @@ const { pages } = await renderDocx(url, hiddenDiv) // HTMLCanvasElement[]
182
189
 
183
190
  `pnpm build` writes `dist/` (ESM, one chunk per entry, types) and packs the
184
191
  fonts. CI publishes on a `v*` tag; see `.gitlab-ci.yml` at the repository root.
192
+
193
+ ## Exclusive editing
194
+
195
+ An optional `lock` adapter supplies `acquire(sessionId)`, `renew(sessionId)`,
196
+ `release(sessionId)` and `read(sessionId)`. Acquire and renew return
197
+ `{ acquired: true, ttlMs }` or `{ acquired: false, owner?: string }`. Read returns
198
+ fresh `Uint8Array` document bytes after acquisition. Configure one adapter per
199
+ document and remount the editor when the document identity changes.
200
+
201
+ ```tsx
202
+ <DocxEditor
203
+ src={initialDocument}
204
+ lock={documentLockAdapter}
205
+ onSave={(bytes, {lockId}) => saveWithVerifiedLock(bytes, lockId)}
206
+ onLockState={state => console.log(state.status)}
207
+ />
208
+ ```
209
+
210
+ The SDK stays read-only until ownership is confirmed, renews the lease, retries
211
+ occupied sessions and suspends editing on connection loss or expiration. The
212
+ server must reject every write without a valid lease; a `409` error thrown from
213
+ `onSave` also suspends editing. The banner identifies the blocking user, offers
214
+ retry and finishes the session with save-before-release. Unsaved changes survive
215
+ a lost lease in the open editor and can be downloaded for recovery.
216
+
217
+ `editor.lock` exposes `state()`, `acquire()` and `release()` (or is `null` when
218
+ locking is disabled). `destroy()` attempts final saving and release; the server
219
+ must expire abandoned sessions because browser shutdown is not reliable.
220
+ Read-only viewers acquire nothing. React exports `DOCX_LOCKING_VERSION = 1`.