Skip to content

Commit 48aa0eb

Browse files
chore(docs): fix icon, merge provider and focus scope pages (#3356)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ab29ec4 commit 48aa0eb

File tree

5 files changed

+84
-99
lines changed

5 files changed

+84
-99
lines changed

apps/docs/docs.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@
172172
"pages": [
173173
"editor/api-reference/ui/bubble-menu",
174174
"editor/api-reference/ui/editor-focus-scope",
175-
"editor/api-reference/ui/editor-focus-scope-provider",
176175
"editor/api-reference/ui/inspector",
177176
"editor/api-reference/ui/slash-command"
178177
]

apps/docs/editor/api-reference/ui/editor-focus-scope-provider.mdx

Lines changed: 0 additions & 81 deletions
This file was deleted.

apps/docs/editor/api-reference/ui/editor-focus-scope.mdx

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,101 @@
11
---
22
title: "EditorFocusScope"
33
sidebarTitle: "EditorFocusScope"
4-
description: "Register portaled UI as part of the editor's focus scope."
5-
icon: "crosshair"
4+
description: "Track editor focus across portaled UI with EditorFocusScope and EditorFocusScopeProvider."
5+
icon: "crosshairs"
66
---
77

88
Everything is accessed through a single import:
99

1010
```tsx
11-
import { EditorFocusScope } from '@react-email/editor/ui';
11+
import {
12+
EditorFocusScope,
13+
EditorFocusScopeProvider,
14+
} from '@react-email/editor/ui';
1215
```
1316

17+
Use `EditorFocusScopeProvider` to keep the editor's focus and blur behavior in
18+
sync across registered surfaces, then wrap each portaled surface that should
19+
still count as being inside the editor UI with `EditorFocusScope`.
20+
21+
<Tip>
22+
`Inspector.Root` already renders `EditorFocusScopeProvider` and wraps itself
23+
in `EditorFocusScope` by default, so the Inspector handles the editor's focus
24+
idiomatically and reliably. Inside a custom inspector, you usually only add
25+
`EditorFocusScope` around extra portaled content.
26+
</Tip>
27+
28+
<h2 id="editor-focus-scope-provider">EditorFocusScopeProvider</h2>
29+
30+
Wrap your editor UI with `EditorFocusScopeProvider` when you need focus-aware
31+
portals outside the built-in Inspector. The provider must be rendered inside
32+
the current editor context so it can access the active editor instance.
33+
34+
### Example
35+
36+
```tsx
37+
import {
38+
EditorFocusScope,
39+
EditorFocusScopeProvider,
40+
} from '@react-email/editor/ui';
41+
import { EditorContent, EditorContext, useEditor } from '@tiptap/react';
42+
import * as Popover from '@radix-ui/react-popover';
43+
44+
export function MyEditor() {
45+
const editor = useEditor({
46+
extensions,
47+
content,
48+
});
49+
50+
return (
51+
<EditorContext.Provider value={{ editor }}>
52+
<EditorFocusScopeProvider clearSelectionOnBlur={false}>
53+
<EditorContent editor={editor} />
54+
55+
<Popover.Root>
56+
<Popover.Trigger type="button">Theme presets</Popover.Trigger>
57+
58+
<Popover.Portal>
59+
<EditorFocusScope>
60+
<Popover.Content sideOffset={8}>
61+
<button type="button">Apply preset</button>
62+
</Popover.Content>
63+
</EditorFocusScope>
64+
</Popover.Portal>
65+
</Popover.Root>
66+
</EditorFocusScopeProvider>
67+
</EditorContext.Provider>
68+
);
69+
}
70+
```
71+
72+
Use `EditorFocusScope` for each portaled surface that should still count as
73+
being inside the editor UI.
74+
75+
### Props
76+
77+
<ResponseField name="children" type="ReactNode">
78+
The editor UI subtree that should share focus tracking.
79+
</ResponseField>
80+
81+
<ResponseField name="clearSelectionOnBlur" type="boolean" default="true">
82+
When focus leaves every registered scope, clear the current selection as part
83+
of blur handling. Set this to `false` if you want to preserve the selection
84+
when the editor truly loses focus.
85+
</ResponseField>
86+
87+
## EditorFocusScope
88+
1489
Use `EditorFocusScope` around portaled UI like Radix `Select.Content`,
1590
`Popover.Content`, or dialog content so moving focus into that portal is still
1691
treated as staying inside the editor UI.
1792

1893
`EditorFocusScope` must be used inside
19-
[EditorFocusScopeProvider](/editor/api-reference/ui/editor-focus-scope-provider),
94+
[`EditorFocusScopeProvider`](/editor/api-reference/ui/editor-focus-scope#editor-focus-scope-provider),
2095
which tracks registered focus scopes and updates the editor's focus state for
2196
them.
2297

23-
<Tip>
24-
`Inspector.Root` already renders
25-
[EditorFocusScopeProvider](/editor/api-reference/ui/editor-focus-scope-provider)
26-
and wraps itself in `EditorFocusScope` by default, so the Inspector handles
27-
the editor's focus idiomatically and reliably. Inside a custom inspector, you
28-
usually only add `EditorFocusScope` around extra portaled content.
29-
</Tip>
30-
31-
## Example
98+
### Example
3299

33100
```tsx
34101
import { EditorFocusScope, Inspector } from '@react-email/editor/ui';
@@ -68,10 +135,10 @@ import * as Select from '@radix-ui/react-select';
68135

69136
If you are building a focus-aware editor shell outside `Inspector.Root`, wrap
70137
the editor with
71-
[EditorFocusScopeProvider](/editor/api-reference/ui/editor-focus-scope-provider)
138+
[`EditorFocusScopeProvider`](/editor/api-reference/ui/editor-focus-scope#editor-focus-scope-provider)
72139
and then use `EditorFocusScope` for each portaled surface.
73140

74-
## Props
141+
### Props
75142

76143
<ResponseField name="children" type="ReactNode">
77144
The element or subtree to register as an additional editor focus scope. Wrap

apps/docs/editor/api-reference/ui/inspector.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function MyEditor() {
6262

6363
<Tip>
6464
`Inspector.Root` already renders
65-
[EditorFocusScopeProvider](/editor/api-reference/ui/editor-focus-scope-provider)
65+
[EditorFocusScopeProvider](/editor/api-reference/ui/editor-focus-scope#editor-focus-scope-provider)
6666
and wraps itself in
6767
[EditorFocusScope](/editor/api-reference/ui/editor-focus-scope) by default,
6868
so the Inspector handles the editor's focus idiomatically and reliably. Add

apps/docs/editor/features/inspector.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ import * as Select from '@radix-ui/react-select';
383383
```
384384

385385
`Inspector.Root` already includes
386-
[`EditorFocusScopeProvider`](/editor/api-reference/ui/editor-focus-scope-provider),
386+
[`EditorFocusScopeProvider`](/editor/api-reference/ui/editor-focus-scope#editor-focus-scope-provider),
387387
and it uses both focus-scope components by default to handle the editor's focus
388388
idiomatically and reliably. Inside a custom inspector you usually only need to
389389
add [`EditorFocusScope`](/editor/api-reference/ui/editor-focus-scope) around

0 commit comments

Comments
 (0)