You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Built-in password dialog for encrypted DOCX files. Enabled by default when omitted; set to `false` to disable, or pass an object to customize titles and button text. See [Surfaces — Built-in password prompt](/core/superdoc/surfaces#built-in-password-prompt).
Password prompt for encrypted DOCX files. Enabled by default. Set to `false` to disable, `true` for defaults, or pass an object to customize text, provide a custom component/render function, or add a per-document resolver. See [Surfaces — Password prompt](/core/superdoc/surfaces#password-prompt).
@@ -46,6 +46,9 @@ Open a `dialog` or `floating` surface above the document.
46
46
<ParamFieldpath="title"type="string">
47
47
Optional title rendered in the surface chrome
48
48
</ParamField>
49
+
<ParamFieldpath="ariaLabel"type="string">
50
+
Accessible name for the surface when no visible `title` is provided. Used as `aria-label` on the surface element (dialog or floating). Ignored when `title` or `ariaLabelledBy` is set.
There is no built-in surface registry yet. If you use `kind`, you must provide `modules.surfaces.resolver`.
344
347
</Warning>
345
348
346
-
## Built-in password prompt
347
-
348
-
SuperDoc includes a built-in password dialog for encrypted DOCX files. It is enabled by default. On wrong password, the dialog stays open and shows an error. On success, the document loads normally.
349
+
## Password prompt
349
350
350
-
You can configure it via `modules.surfaces.passwordPrompt`:
351
+
SuperDoc includes a built-in password dialog for encrypted DOCX files. Enabled by default. On wrong password, the dialog stays open and shows an error. On success, the document loads normally.
351
352
352
353
```javascript
353
354
newSuperDoc({
354
355
selector:'#editor',
355
356
document: encryptedFile,
356
357
modules: {
357
358
surfaces: {
358
-
passwordPrompt:true,
359
+
passwordPrompt:true,// default — can omit
359
360
},
360
361
},
361
362
});
362
363
```
363
364
364
-
### Custom labels
365
+
Set to `false` to disable:
365
366
366
-
Pass an object to override the default titles and button text:
367
+
```javascript
368
+
modules: {
369
+
surfaces: {
370
+
passwordPrompt:false,
371
+
},
372
+
}
373
+
```
374
+
375
+
### Text customization
376
+
377
+
Override any of the built-in copy:
367
378
368
379
```javascript
369
380
modules: {
370
381
surfaces: {
371
382
passwordPrompt: {
372
383
title:'Unlock document',
373
384
invalidTitle:'Wrong password — try again',
385
+
description:'This file requires a password.',
374
386
submitLabel:'Unlock',
375
387
cancelLabel:'Dismiss',
388
+
busyLabel:'Opening\u2026',
389
+
invalidMessage:'That password is wrong. Try again.',
Custom Vue component rendered inside the dialog shell. Receives a `passwordPrompt` prop (see handle reference below). Mutually exclusive with `render`.
Conditional resolver for per-document customization. Can coexist with `component`/`render` — the resolver runs first, and `null`/`undefined`/`{ type:'default' }` falls through to the direct component/render or built-in.
448
+
</ParamField>
397
449
</Expandable>
398
450
</ParamField>
399
451
400
-
### Custom password UI via resolver
452
+
### Custom Vue component
401
453
402
-
To replace the built-in dialog with your own component, add a resolver that handles the `'password-prompt'` kind. Keep `passwordPrompt`enabled so the password flow stays active:
454
+
Replace the built-in dialog content with your own Vue component. Your component receives a `passwordPrompt`prop with everything it needs:
Use `resolver` when you need per-document decisions. The resolver receives a read-only `PasswordPromptContext` (`documentId`, `errorCode`, `texts`) and returns a resolution:
514
+
515
+
```javascript
516
+
modules: {
517
+
surfaces: {
518
+
passwordPrompt: {
519
+
resolver: (ctx) => {
520
+
if (ctx.documentId==='public-doc') {
521
+
return { type:'none' }; // suppress prompt for this doc
423
522
}
523
+
returnnull; // fall through to built-in
424
524
},
425
525
},
426
526
},
427
-
});
527
+
}
428
528
```
429
529
430
-
Your custom component receives `resolve` and `close` as reserved props, plus whatever you pass in `props`. Call `request.payload.attemptPassword(password)` to retry — it returns `{ success:true }` or `{ success:false, errorCode }`. On success, call `resolve()` to close the dialog.
530
+
**Resolution types:**
531
+
532
+
| Type | Behavior |
533
+
|------|----------|
534
+
| `null` / `undefined` | Fall through to `component`/`render` or built-in |
535
+
| `{ type:'default' }` | Same as `null` — fall through |
536
+
| `{ type:'none' }` | Suppress the password prompt for this document |
537
+
| `{ type:'custom', component, props? }` | Mount a Vue component in the dialog shell |
538
+
| `{ type:'external', render }` | Mount framework-agnostic UI in the dialog shell |
539
+
540
+
The resolver can coexist with `component`/`render`. If the resolver returns `null` or `{ type:'default' }`, the direct `component`/`render` is used. If neither is configured, the built-in prompt renders.
2. If `{ success:true }` — call `resolve()` to close the dialog
560
+
3. If `{ success:false, errorCode }` — keep the dialog open, show your error state
561
+
562
+
`resolve()` with no arguments is sufficient. The password flow does not consume the resolved data.
563
+
564
+
**Cancel / dismiss button:**
565
+
- Call `close('user-cancelled')`
566
+
567
+
**Other actions** (forgot password, help links): app-owned. Keep the dialog open or close with a custom reason.
568
+
569
+
<Warning>
570
+
Do not set `doc.password` or increment `editorMountNonce` directly. Use `passwordPrompt.attemptPassword(password)` — it handles the document mutation and remount internally.
571
+
</Warning>
572
+
573
+
### `{ type:'none' }` semantics
574
+
575
+
`{ type:'none' }` means **suppress SuperDoc's password prompt**. The resolver context does not expose `attemptPassword`, so `none` cannot be used to build a self-hosted modal that retries passwords through SuperDoc.
576
+
577
+
Use this when your app handles passwords entirely outside SuperDoc — for example, pre-prompting before instantiation or server-side decryption. For global suppression, use `passwordPrompt:false` instead.
431
578
432
579
### Relationship with the exception event
433
580
434
-
If `passwordPrompt` is disabled, encrypted files emit a `DOCX_PASSWORD_REQUIRED` or `DOCX_PASSWORD_INVALID`code on the `exception` event. Your app can handle password entry entirely through that event if you prefer.
581
+
If `passwordPrompt` is disabled, encrypted files emit `DOCX_PASSWORD_REQUIRED` or `DOCX_PASSWORD_INVALID` on the `exception` event. Your app can handle password entry through that event instead.
435
582
436
-
When `passwordPrompt` is enabled, the built-in dialog handles retry automatically. The `exception` event still fires (with `documentId` in the payload) so your app can log or track failures.
583
+
When `passwordPrompt` is enabled, recoverable encryption errors are intercepted by the password prompt flow. If the prompt renders successfully (built-in, custom, or external), the `exception` event is suppressed. If the prompt cannot render (resolver returned `{ type:'none' }`, invalid config, or resolver threw), the original `exception` event is re-emitted so your app can handle it.
0 commit comments