Control what happens when a user clicks a link in the editor. By default, SuperDoc shows a built-in popover with the link URL and edit controls. WithDocumentation Index
Fetch the complete documentation index at: https://docs.superdoc.dev/llms.txt
Use this file to discover all available pages before exploring further.
popoverResolver, you can replace it with your own UI in any framework.
Quick start
No configuration needed for the default behavior: click a link and the built-in popover appears. To customize, add apopoverResolver to the links module:
Configuration
Synchronous function called when a user clicks a link. Receives a context object and returns a resolution that determines which popover to show. Return
null or undefined to use the default popover.Resolver context
The resolver receives aLinkPopoverContext object with all information about the clicked link:
| Property | Type | Description |
|---|---|---|
editor | Editor | The editor instance |
href | string | The href attribute of the clicked link |
target | string | null | The target attribute |
rel | string | null | The rel attribute |
tooltip | string | null | The title attribute |
element | HTMLAnchorElement | The clicked anchor DOM element |
clientX | number | X coordinate of the click |
clientY | number | Y coordinate of the click |
isAnchorLink | boolean | true when href starts with # |
documentMode | string | Current mode: 'editing', 'viewing', or 'suggesting' |
position | { left: string, top: string } | Computed popover position relative to the editor surface |
closePopover | () => void | Close the popover programmatically |
Resolution types
The resolver returns one of four resolution types. Returnnull or undefined to use the default popover.
default
Show the built-in link popover with URL display and edit controls.
none
Suppress the popover entirely. Use this when the resolver handles the click itself (navigation, opening a modal, logging, etc.).
custom
Render a Vue component inside the built-in popover shell. editor and closePopover are automatically injected as props alongside any props you provide.
editor, closePopover, and any additional props:
external
Mount framework-agnostic UI into a raw DOM container. Use this for React, Svelte, vanilla JS, or any non-Vue framework.
SuperDoc creates a positioned <div> element and passes it to your render function. You mount your UI into that container. Return a { destroy } callback for cleanup when the popover closes.
render function receives an ExternalPopoverRenderContext:
| Property | Type | Description |
|---|---|---|
container | HTMLElement | Empty positioned DOM container to mount your UI into |
closePopover | () => void | Close the popover, call destroy, and return focus to the editor |
editor | Editor | The editor instance |
href | string | The href of the clicked link |
The popover automatically closes on click-outside and Escape key: matching the built-in popover behavior. Your
destroy callback is called in both cases.Framework examples
- React
- Vue
- Vanilla JS
Use With the React wrapper:
createRoot to mount a React component into the external container. Return destroy to unmount cleanly.Styling
External popovers use CSS custom properties with sensible defaults that match the built-in popover. Override them to match your design system.Shared popover variables
These apply to both the built-in popover and external link popovers:| Variable | Default | Description |
|---|---|---|
--sd-popover-bg | white | Background color |
--sd-popover-z-index | 1000 | Stack order |
--sd-popover-radius | 6px | Border radius |
--sd-popover-shadow | 0 0 0 1px rgba(0,0,0,0.05), 0px 10px 20px rgba(0,0,0,0.1) | Box shadow |
--sd-popover-min-width | 120px | Minimum width |
--sd-popover-min-height | 40px | Minimum height |
External link popover overrides
Override just the external link popover without affecting other popovers:| Variable | Fallback | Description |
|---|---|---|
--sd-external-link-popover-bg | --sd-popover-bg | Background color |
--sd-external-link-popover-z-index | --sd-popover-z-index | Stack order |
--sd-external-link-popover-radius | --sd-popover-radius | Border radius |
--sd-external-link-popover-shadow | --sd-popover-shadow | Box shadow |
--sd-external-link-popover-min-width | --sd-popover-min-width | Minimum width |
--sd-external-link-popover-min-height | --sd-popover-min-height | Minimum height |
sd-external-link-popover for direct CSS targeting:
Behavior
- Toggle off: Clicking a link while its popover is already open closes the popover.
- Click outside: Clicking anywhere outside the popover closes it.
- Escape key: Pressing Escape closes the popover.
- Focus: When a popover closes, focus returns to the editor.
- Error handling: If the resolver or
renderfunction throws, SuperDoc falls back to the default popover and calls theonExceptioncallback. - Cursor: The editor cursor moves to the clicked link position before the resolver runs.

