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 find/replace popover for editor-backed documents. Disabled by default; set to `true` for the built-in UI, or pass an object to customize text, disable replace actions, provide a custom component or render function, or add a runtime resolver. See [Surfaces — Built-in Find and Replace](/core/superdoc/surfaces#built-in-find-and-replace).
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).
281
+
Built-in password prompt for encrypted DOCX files. Enabled by default when omitted; set to `false` to disable, `true` for defaults, or pass an object to customize text, provide a custom component or render function, or add a per-document resolver. See [Surfaces — Built-in password prompt](/core/superdoc/surfaces#built-in-password-prompt).
279
282
</ParamField>
280
283
</Expandable>
281
284
</ParamField>
282
285
283
286
<Note>
284
-
You only need `modules.surfaces` if you want shared defaults or a central resolver. Direct `superdoc.openSurface(...)` calls do not require any special setup.
287
+
You only need `modules.surfaces` if you want shared defaults, a central resolver, or to enable/configure built-in surface behaviors like find/replace and the password prompt. Direct `superdoc.openSurface(...)` calls do not require any special setup.
285
288
</Note>
286
289
287
290
See [Surfaces](/core/superdoc/surfaces) for the full API and examples.
Copy file name to clipboardExpand all lines: apps/docs/core/superdoc/surfaces.mdx
+274-3Lines changed: 274 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ Add `modules.surfaces` only when you want:
27
27
28
28
- global defaults for dialogs or floating overlays
29
29
- a central `resolver` for intent-based requests using `kind`
30
+
- built-in surface behaviors such as opt-in find/replace or password prompt customization
30
31
31
32
## Open a surface
32
33
@@ -287,7 +288,7 @@ This is the same pattern as [external link popovers](/modules/links#external-ren
287
288
288
289
## Optional instantiation config
289
290
290
-
Add `modules.surfaces` only if you want shared defaults or a resolver.
291
+
Add `modules.surfaces` only if you want shared defaults, a resolver, or built-in surface behaviors such as find/replace.
291
292
292
293
```javascript
293
294
newSuperDoc({
@@ -346,7 +347,277 @@ superdoc.openSurface({
346
347
There is no built-in surface registry yet. If you use `kind`, you must provide `modules.surfaces.resolver`.
347
348
</Warning>
348
349
349
-
## Password prompt
350
+
## Built-in Find and Replace
351
+
352
+
SuperDoc includes a built-in find/replace popover for editor-backed documents. It is disabled by default so existing apps can keep their own `Cmd+F` / `Ctrl+F` handling. When enabled, SuperDoc intercepts those shortcuts while focus is inside SuperDoc and opens the built-in UI.
353
+
354
+
From shortcut handling, SuperDoc only steals `Cmd+F` / `Ctrl+F` when it can actually open a surface. If `findReplace.resolver` returns `{ type:'none' }`, or the config is invalid or throws, the browser's native find remains active.
355
+
356
+
Enable it via `modules.surfaces.findReplace`:
357
+
358
+
```javascript
359
+
newSuperDoc({
360
+
selector:'#editor',
361
+
document: file,
362
+
modules: {
363
+
surfaces: {
364
+
findReplace:true,
365
+
},
366
+
},
367
+
});
368
+
```
369
+
370
+
### Text customization
371
+
372
+
Override any of the built-in labels and placeholders:
373
+
374
+
```javascript
375
+
modules: {
376
+
surfaces: {
377
+
findReplace: {
378
+
findPlaceholder:'Search in document',
379
+
replacePlaceholder:'Replace with',
380
+
noResultsLabel:'Nothing found',
381
+
previousMatchLabel:'Previous result',
382
+
nextMatchLabel:'Next result',
383
+
closeAriaLabel:'Close search',
384
+
},
385
+
},
386
+
}
387
+
```
388
+
389
+
### Find-only mode
390
+
391
+
Disable replace actions and keep only the find UI:
Find/replace configuration. Disabled by default; set to `true` to enable the built-in UI, or pass an object to customize labels, disable replace actions, or replace the rendering.
Runtime resolver for choosing built-in, custom, external, or suppressed rendering. Can coexist with `component`/`render` — the resolver runs first, and `null`/`undefined`/`{ type:'default' }` falls through to the direct component/render or built-in UI.
481
+
</ParamField>
482
+
</Expandable>
483
+
</ParamField>
484
+
485
+
### Custom Vue component
486
+
487
+
Replace the built-in content with your own Vue component. Your component receives a `findReplace` prop with reactive state and actions:
`ctx` exposes `container`, `findReplace`, `resolve`, `close`, `surfaceId`, and `mode`.
555
+
556
+
`ctx.findReplace` exposes plain JavaScript getters/setters instead of Vue refs so non-Vue renderers can work with it directly.
557
+
558
+
### Conditional resolver
559
+
560
+
Use `resolver` when your app wants to decide at runtime whether to use built-in, custom, external, or suppressed rendering. The resolver receives a read-only context with `texts` and `replaceEnabled`:
| `null` / `undefined` | Fall through to `component`/`render` or built-in |
583
+
| `{ type:'default' }` | Same as `null` — fall through |
584
+
| `{ type:'none' }` | Suppress SuperDoc's find/replace surface for this open attempt |
585
+
| `{ type:'custom', component, props? }` | Mount a Vue component in the floating shell |
586
+
| `{ type:'external', render }` | Mount framework-agnostic UI in the floating shell |
587
+
588
+
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 popover renders.
Custom Vue components receive `findReplace` as a Vue handle with refs/computed refs. External `render` functions receive `ctx.findReplace` with the same API surface, but mutable fields are exposed as plain JavaScript getters/setters and derived fields are plain getters.
595
+
596
+
| Field | Vue `component` value | External `render` value | Description |
| `registerFocusFn` | `(fn) =>void` | `(fn) =>void` | Register the function SuperDoc calls when the user presses `Cmd+F` / `Ctrl+F` again while the surface is already open |
612
+
| `close` | `(reason?:unknown) =>void` | `(reason?:unknown) =>void` | Close the surface |
613
+
614
+
### `{ type:'none' }` semantics
615
+
616
+
`{ type:'none' }` means **suppress SuperDoc's find/replace surface** for that open attempt.
617
+
618
+
When find/replace is opened via `Cmd+F` / `Ctrl+F`, suppression falls back to the browser's native find dialog instead of swallowing the shortcut.
619
+
620
+
## Built-in password prompt
350
621
351
622
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.
352
623
@@ -587,4 +858,4 @@ When `passwordPrompt` is enabled, recoverable encryption errors are intercepted
587
858
When multiple encrypted documents are loaded, the password prompt queues one dialog at a time in FIFO order. After the user submits or cancels for one document, the next dialog appears.
588
859
## Styling
589
860
590
-
Background, shadow, border radius, padding, and edge offset are all customizable via `--sd-ui-surface-*` and `--sd-ui-floating-*` CSS variables. See the full token table in [Custom themes](/guides/general/custom-themes#surfaces).
861
+
Background, shadow, border radius, padding, and edge offset are all customizable via `--sd-ui-surface-*` and `--sd-ui-floating-*` CSS variables. Find/replace controls use `--sd-ui-find-replace-*`, and search highlight colors use `--sd-ui-search-match-bg` plus `--sd-ui-search-match-active-bg`. See the full token table in [Custom themes](/guides/general/custom-themes#surfaces).
0 commit comments