myrole-docx-editor 0.1.4 → 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 +29 -0
- package/dist/chunks/{sdk-DZeo_8qT.js → sdk-BVyUd7P0.js} +5643 -5486
- package/dist/chunks/sdk-BVyUd7P0.js.map +1 -0
- package/dist/chunks/{vars-blockly-EQQZFx30.js → vars-blockly-CBeNXS0X.js} +2 -2
- package/dist/chunks/{vars-blockly-EQQZFx30.js.map → vars-blockly-CBeNXS0X.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/react.js +31 -29
- package/dist/react.js.map +1 -1
- package/dist/types/packages/docx-editor/src/index.d.ts +1 -0
- package/dist/types/packages/docx-editor/src/locking.d.ts +37 -0
- package/dist/types/packages/docx-editor/src/react.d.ts +1 -0
- package/dist/types/packages/docx-editor/src/sdk.d.ts +12 -2
- package/package.json +4 -4
- package/dist/chunks/sdk-DZeo_8qT.js.map +0 -1
package/README.md
CHANGED
|
@@ -189,3 +189,32 @@ const { pages } = await renderDocx(url, hiddenDiv) // HTMLCanvasElement[]
|
|
|
189
189
|
|
|
190
190
|
`pnpm build` writes `dist/` (ESM, one chunk per entry, types) and packs the
|
|
191
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`.
|