Focus mode
Focus mode clears everything but the work. It's in the document editor, the document reader and the slides editor, with the same key everywhere: Ctrl/⌘+Shift+F turns it on and off, and Escape leaves it. Each app also has a Focus mode button.
Writing (FolioApp)
- The page alone. Panels and the status bar go away, and the page loses its shadow. The app bar and toolbar float over the top, faded out. Move the pointer, or Tab into them, to bring them back; they fade again once you start typing. The pointer hides while you type. While a menu they opened is open (its trigger has
aria-expanded="true", wherever the menu is portaled) they stay, typing included; so do they while focus or the pointer is in an element they own (named byaria-controls/aria-owns, or markeddata-folio-keep-awakeby the host). - Dimming. Everything but the paragraph you're in is veiled, headers and footers included. The veils follow the page when an embedded editor's host page scrolls, and never cover anything outside the editor. The bar switches between
'paragraph','sentence'(Intl.Segmenter's sentences, so Arabic works too) and'none'. - Typewriter scrolling. The caret's line stays in the middle of the window as you type. It also keeps above an on-screen keyboard.
- The bar. A small, faint bar at the bottom shows:
- the word count, with the words written this session;
- progress towards an optional word goal;
- the session timer;
- an outline peek (the headings, one click away);
- the dimming and typewriter toggles;
- full screen (the whole app; leaving focus mode leaves the full screen it entered, not one the host set up), and the way out.
<FolioApp app={app}
focus={focus} onFocusChange={setFocus}
focusMode={{ dim: 'sentence', goal: 500, timer: true }}
onFocusOptionsChange={saveFocusPrefs} />focusMode={false} leaves it out entirely: no button and no key.
focusButton moves the button: 'appbar' (default), 'statusbar' (a cell after zoom, same icon, tooltip, pressed state and key; in the app bar where no status bar shows: phones, statusbar={false}), or false (no button; Ctrl/⌘+Shift+F still turns focus mode on and off, since a hidden button shouldn't take a standard key away). FolioBookApp passes it through. A host that shows its app full screen in focus mode (onFocusChange calling requestFullscreen) gets its full-screen button there too.
Reading (read-only FolioApp)
In a read-only view, focus mode is a reading view:
- One column. The document reflows into a single column at the chosen text size (16–32 px) and line length (narrow, medium or wide). The print layout comes back when you leave.
- Progress. A thin progress line runs across the top.
- The bar. It has the text size, the line length, how far you are, and the way out.
When the view can't reflow (a FolioBookApp, or a FolioApp whose canvas is the host's own), the pages stay as they are: the normal centred page column with its zoom and gaps, only the chrome goes. The bar then has the page (Page N of M, a book's own numbering) and zoom instead of the text size and line length, and the exit; Escape leaves too.
The standalone reader (FolioReaderShell in @nextgensoftwares/folio-reader) has the same mode for its laid-out pages:
- one page at a time in a centred column, in the reading view you had: one page per row when scrolling, one page per screen when paged (two-page spreads become single pages; your display and view come back exactly when you leave);
- the progress line;
- a fading bar with text size, page colour (light, sepia, dark), page n of N and exit.
- the space around the pages in the chrome's colours (a dark canvas under dark chrome, whatever the page colour).
A host that switches light and dark itself passes hide={['theme']}: that removes the page colours from the toolbar and from the focus bar. hide={['focus']} turns focus mode off (its button and shortcut).
Slides (SlidesApp)
- Slide focus. The current slide is fitted to the window, above room for the bar. The thumbnails, inspector, notes strip and status bar are gone. The app bar and ribbon stay hidden until the pointer reaches the top edge (or keyboard focus moves into them), so they never cover the slide while you work.
- Notes focus. The slide sits over a large notes page for writing what you'll say. The slide takes 62% of the height by default; drag the bar between them, or focus it and use the arrow keys (Home and End for the limits). The split is kept for the session.
- The bar. It has the previous and next slides, slide n of N, the notes focus toggle, and exit.
- Escape. The first Escape still clears a selection; with nothing selected, Escape leaves.
- The app bar's button turns focus mode on and off (it shows pressed while it's on).
<SlidesApp deck={deck} measurer={fonts} focus={focus} onFocusChange={setFocus} focusNotes />Focus mode is a feature (features={{ focus: false }} removes it). The View tab has Focus and Notes focus buttons. Presenting works the same from focus mode.
With browser fullscreen
A host can put its app's container into browser fullscreen when focus mode turns on (container.requestFullscreen() in onFocusChange). Only the fullscreen element's subtree shows then, so Folio's popovers, menus, the selection bubble and the file viewer open inside the fullscreen element instead of <body> while there is one, and move back afterwards. Hosts with overlays of their own can use the same rule: overlayRoot() (or the useOverlayRoot() hook) from folio-react returns the element to portal into.
A host that ties focus mode to browser fullscreen itself can hide the bar's full-screen button so only the way out of focus mode shows: hide={['fullscreen']} on FolioApp or FolioBookApp (the same names as FolioReader's: also 'focusZoom', 'focusPosition', 'focusProgress').
Building your own
useFocusMode(props, editor, ui, { readOnly, layouts }) returns the pieces FolioApp uses:
- the view's slots with the dimming layer added;
- the root attributes the styles read (
data-focus,data-typewriter,data-focus-read); - the bar, and the session's context provider (
wrap).
FocusBar, FocusDimLayer, useFocusWake and the text helpers (focusRange, countWords, outlineOf) are exported for shells of your own. For an API summary, see folio-react: Focus mode.