Building your own slides shell
The slides editor is a library, not an app. SlidesApp is one composition of public pieces; you can rearrange it, replace any region of it, or build a completely different shell from the same pieces. Nothing the default UI does is private.
@nextgensoftwares/folio-slides-editor headless: state, commands, history, keys, plugins
│
@nextgensoftwares/folio-plugin-slides React: DeckProvider + hooks → primitives → controls → panels → SlidesApp
│
@nextgensoftwares/folio-react AppShell, FolioAppBar/Panel, Toolbar, inspector controls, menus1. The deck editor
Everything starts with a headless DeckEditor. It owns the deck, the current slide, the selection, the view mode and the undo history; every action is a named command.
import { createDeckEditor } from '@nextgensoftwares/folio-slides-editor';
import { openPptx } from '@nextgensoftwares/folio-pptx';
const { presentation, package: pkg } = await openPptx(bytes, { fonts: { loader } });
const deck = createDeckEditor({ presentation });
deck.exec('slide.new'); // after the current slide, same layout
deck.exec('shape.insert', { kind: 'textBox', text: 'Hi' });
deck.exec('text.size', { size: 32 });
deck.can('slide.delete'); // false on a one-slide deck
deck.on('presentation', (s) => autosave(s.presentation));It runs without React (tests, servers, workers); the full command list is on the API page.
2. Provider and hooks
Wrap your shell in a DeckProvider with the measurer and media resolver. Hooks read the deck and re-render on change:
import { DeckProvider, useCommand, useCanExecute, useDeckState } from '@nextgensoftwares/folio-plugin-slides';
function NewSlideButton() {
const add = useCommand('slide.new');
const enabled = useCanExecute('slide.new');
return <button disabled={!enabled} onClick={() => add()}>New slide</button>;
}
function Counter() {
const index = useDeckState((s) => s.index);
const count = useDeckState((s) => s.presentation.slides.length);
return <span>{index + 1} / {count}</span>;
}useDeckState(select) must return state parts or primitives (a new array on every call would re-render forever); derive with useMemo.
3. Compose the primitives
A Keynote-like shell: a slim bar, a narrow navigator, the canvas and one contextual inspector.
import {
DeckProvider, DeckPresenter, ThumbnailList, SlideEditorSurface, TextGroup,
FormatShapePanel, SlidePanel, SLIDES_CSS, SLIDES_APP_CSS, deckKeyDown, useDeck, useDeckState,
} from '@nextgensoftwares/folio-plugin-slides';
function Shell() {
const deck = useDeck();
const hasShapes = useDeckState((s) => s.selection.shapes.length > 0);
return (
<div className="my-shell" onKeyDown={(e) => deckKeyDown(deck, e)}>
<header>
<button onClick={() => deck.exec('slide.new')}>Add slide</button>
<button onClick={() => deck.exec('present.start')}>Play</button>
</header>
<nav><ThumbnailList width={112} /></nav>
<main><SlideEditorSurface padding={40} /></main>
<aside><TextGroup />{hasShapes ? <FormatShapePanel /> : <SlidePanel />}</aside>
<DeckPresenter />
</div>
);
}
<DeckProvider deck={deck} measurer={fonts} resolveSrc={media.resolve}>
<style>{SLIDES_CSS + SLIDES_APP_CSS}</style>
<Shell />
</DeckProvider>The playground's slides.html?shell=keynote is this shell, running.
4. Or adjust the default one
Every region of SlidesApp takes false (hide) or a node (replace):
<SlidesApp
deck={deck} measurer={fonts} resolveSrc={media.resolve}
toolbarGroups={[{ id: 'slide', node: <SlideGroup /> }, { id: 'text', node: <TextGroup /> }, { id: 'mine', node: <MyGroup /> }]}
rail={<MyOutline />}
statusBar={false}
panels={[...INSPECTOR_PANELS.filter((p) => p.id !== 'design'), { id: 'review', slot: 'inspector', label: 'Review', component: Review }]}
/>appBarTarget={el} renders Folio's app bar into an element of your header instead (the ribbon stays above the slides), and creditPlacement puts the "Made with Folio" credit at the end of the app bar (default) or the status bar. A portaled bar leaves the credit in Folio's status bar by default (not your header; an explicit creditPlacement="appBar" puts it at the bar's end); a hidden or replaced app bar leaves it in the status bar, or a slim bar of its own (see Embedding the app bar). title={false} leaves the deck's title out of the bar.
initialSlide (0-based, clamped to the deck) opens the app on a slide, for example the one a book's Edit slides handed you. For a ?slide= in the URL, control it instead: slide moves the deck when it changes, and onSlideChange(index) hears every move (thumbnails, keys, the presenter's return, a deleted slide) but not the echo of a slide you just set.
<SlidesApp deck={deck} measurer={fonts} slide={slide} onSlideChange={(i) => setSearch({ slide: String(i) })} />initialSelection opens the app on a text range: a reader selected text on a slide of a deck chapter and picked Comment, and you open the deck there. It goes to slide (0-based), selects the shape shapeId (the model id) and edits its text in place with paragraph para (its index in the shape's text body), UTF-16 offsets from to to in that paragraph, selected: the same offsets as the slide layout's text items (from/to) and find matches. If the deck changed and the range or the shape is gone, the shape is selected, else just the slide, without an error. It applies on mount and again whenever you pass a new object, so keep it in state or useMemo.
initialAction starts something on that selection. 'comment' opens the Comments panel with its new-comment box focused, as Insert › Comment does: the thread is the deck's, pinned beside the selected shape. Slides have no suggestion mode, so 'suggest' leaves the text in place-editing with the range selected and focused (the reader edits it directly) and opens the Comments panel with its new-comment box unfocused, to explain the change.
const at = useMemo(() => ({ slide: 2, shapeId: '70', para: 1, from: 6, to: 11 }), []);
<SlidesApp deck={deck} measurer={fonts} initialSelection={at} initialAction="comment" />fonts takes the same values as FolioApp's: a list of families (a plain select), or a FontPickerSource (fontLoaderSource from @nextgensoftwares/folio-fonts builds one over your loader) for FolioApp's picker, with search, groups (built-in, uploaded, a catalogue by category), pins and an upload action. The ribbon's font box and Design › Theme fonts use it. A pick is applied only once the source's load resolved, so the family is measurable before the slide is laid out again. The deck stores the family name in its text runs; when the deck is opened again, ensureFonts loads it through your loader, so serve uploaded families from there too (PPTX export names the family, it does not embed the font file).
<SlidesApp deck={deck} measurer={engine} ensureFonts={(f) => loader.ensure(f)}
fonts={fontLoaderSource({ loader, groups })} />The app bar's Import menu has Pictures as slides, PDF as slides and Slides from PowerPoint (.pptx)…, which is PowerPoint's Reuse Slides. That one shows the file's slides as thumbnails to pick, lets the user keep their formatting or take this deck's theme, and inserts them after the current slide in one undo step. Pictures and media go through your storeImage / storeMedia. importers adds your own entries, and pdfImport / pptxImport take options or false. See the Import menu for the details.
Moving around a slide larger than the view (zoomed in): the wheel or a trackpad scrolls it, Shift+wheel sideways, and scrollbars show. Space+drag or a middle-button drag pans, and so does a drag on the grey area around a zoomed slide. Ctrl/⌘+wheel, a pinch and Ctrl/⌘ +/− zoom around the pointer (or the view's centre for keys); the status bar's zoom keeps the view's centre in place; its Fit button and Ctrl/⌘+0 fit the slide to the window again. SlideEditorSurface in a shell of your own takes onZoom and onFit for the same. The built-in slide show has a Notes button (or Shift+N) for the speaker notes.
Styling: the CSS reads Folio's tokens (--folio-*, light and dark) through --fsd-* custom properties; override those, or pass unstyled and bring your own stylesheet (class names stay). dir="rtl" mirrors the shell.
5. Plugins
Features are plugins on the deck editor: commands, key bindings, UI item descriptors and slot components, with a reader flag for read-only decks.
const stamp: SlidesPlugin = {
name: 'stamp',
commands: { 'stamp.add': { label: 'Stamp', run: (ctx) => ({ presentation: addStamp(ctx.state.presentation) }) } },
keymap: { 'Mod-Shift-s': 'stamp.add' },
ui: {
items: [{ id: 'stamp', label: 'Stamp', group: 'plugins', command: 'stamp.add', surfaces: ['toolbar', 'contextMenu'] }],
slots: [{ id: 'stamp.panel', slot: 'inspector', label: 'Stamp', component: StampPanel }],
},
};
const deck = createDeckEditor({ presentation, plugins: [stamp] });SlidesApp shows toolbar items of group plugins, 'contextMenu' items on right-click, 'slideMenu' items on the thumbnails and 'inspector' slots as tabs. In a custom shell, render them with <DeckItems surface group />, <DeckMenu surface at onClose /> and useDeckSlots(name).
Brand, theme and the host's selection actions
SlidesApp and SlideDeck take the same brand, credit, locale and FolioHostTheme as FolioApp (SlideDeck's root has the folio-ui class, so host themes reach it), and a selectionActions list for the host's own actions:
<SlideDeck presentation={p} measurer={m} brand={<Logo />} locale="ar"
selectionActions={[{ id: 'card', label: 'Card', onSelect: ({ anchor, text }) => makeCard(anchor, text) }]} />
<SlidesApp deck={deck} measurer={m} brand={<Logo />} locale="ar"
selectionActions={[{ id: 'ask', label: 'Ask AI', icon: 'sparkle', onSelect: ({ shapeIds, text }) => ask(text, shapeIds) }]} />In SlideDeck the actions appear in a popover over selected slide text (the text becomes selectable); in SlidesApp they come first in the slide's context menu (right-click, Shift+F10 or the menu key), where a string icon names a Folio icon. The context is SlideSelectionContext: { source: 'viewer' | 'editor', slideIndex, slideId, text, anchor, shapeIds, rect, close() }. Custom shells provide SlidesSelectionActionsContext themselves and can use editorSelection and hostMenuItems.
The accessibility check
The Accessibility tab (AccessibilityPanel, Review › Check accessibility) lists what checkSlide finds, slide by slide, checked in idle slices so typing never waits for it. It covers alt text, slide titles, duplicate titles, colour contrast and table header rows. Each finding shows its whole text (nothing is cut off) and a sentence on why it matters: explainIssue(issue) returns the rule's template from A11Y_EXPLAIN (keyed by its English text, so a locale's messages translate it) and the values to fill in. Contrast findings also show the text in its colour on what's behind it, with the ratio and the one it needs (3:1 for large text, 4.5:1 otherwise). Clicking a finding goes to its slide and selects the shape; hovering outlines it.
Where Folio can fix a finding safely, it offers a fix as one undo step (deck.exec('a11y.fix', { issue, fix }), or 'a11y.fixAll' for several):
| Finding | Fix |
|---|---|
| Slide has no title | "Use as slide title" when a text box looks like the title (the largest text among boxes starting in the slide's top 40%, a heading rather than a paragraph; titleCandidate). It becomes the slide's title placeholder and keeps its look: the size, font, colour, alignment and body it shows are written onto it (makeSlideTitle), and an empty title placeholder is removed. |
| Low contrast | "Fix contrast": the nearest text colour (same hue, the smallest lightness change) that reaches the ratio, with a preview. When the text sits on its shape's own fill, "Change the fill instead" darkens or lightens the fill the same way (contrastFixes). |
| Missing alt text | Clicking the finding focuses its description field. |
A finding repeated on several slides is summed up first ("5 slides have no title"), with "Fix all that look like titles" when Folio can fix them.
Viewers stay small
A reader or a kiosk that only shows decks imports @nextgensoftwares/folio-plugin-slides/viewer (SlideDeck, SlideCanvas, Thumbnails, Presenter): no editor, ProseMirror or editing UI in the bundle, enforced by a size test (91.9 KB gzip up front; the preset shape library, WordArt's warps and the student viewer's extras are lazy chunks, see Lazy chunks).
Same slide in every mode
A slide paints the same in every mode: the slide editor, thumbnails and the sorter, the read-only SlideDeck, the show and presenter (the animation stage too), slide pictures (exportSlideImage), the reader (deckChapter with slidesReaderPlugin), the Notes Page view and PDF (exportSlidesPdf). Modes differ only in behaviour; what belongs to one mode draws over the same layout.
- One page setup. Every surface lays a slide out through
slidePageOptions(pres, …)(the deck's slide theme, the slide renderers, the measurer, equations and media sizes) and projects it withslideProjection(mode). The slide editor takes the deck's stand-in fonts (SlideEditorOptions.standIns), so a box in a missing font shrinks to fit while you edit it, as it does everywhere else. - Editing extras. An empty placeholder (its dashed outline and prompt) and the bullet of an empty paragraph show only in the editor; they never move anything else on the slide.
- One canvas paint.
paintSlidewithslideCanvasOptionsis the canvas setup of the slide view, thumbnails, pictures and the show stage, with the editor's equations (math), metrics and faces (deckPaintSetup: the deck'smetrics, the measurer'spaintFamilies). GiveSlideDeckthe samemathandmetricsasSlidesApp. - Notes Page view paints
layoutNotesPage, the page the PDF writes; the notes are typed into an overlay over it. - No mark on the slide. The "Made with Folio" credit is in the app's bars (
SlidesApp's app or status bar,SlideDeck's bar), not painted on slides (SlideCanvas'screditis ignored). - Save as PDF (
builtInPdf) uses the app's measurer and layout when it holds the font files (aFontEngine); only a measurer without them makes it lay the deck out again with the bundled OFL faces, as a fallback.
A parity test in CI (plugin-slides-motion, slide-parity.test.ts) lays one slide (shrunk text, placeholders, bullets, math, a cropped picture, a table, a shadow, right-to-left Arabic, notes) out through the editor, the reader, the PDF and the notes page, and paints it through every canvas path: they agree.
The editor paints the same pixels
The slide editor draws the slide's content with the same canvas paint as the viewer, thumbnails, the show and pictures (useSlidePaint, the shown page from layoutSlide). Everything only editing needs is an overlay above it: the caret and text selection, handles and outlines, guides, and the editing extras (empty placeholders' dashed outline and prompt, empty bullets) on a transparent canvas of their own. A shape being dragged, resized or turned moves on the content canvas live (liveSlidePage), to the pixels it shows once dropped. Screen readers read the slide's text (SlideText); typing goes through the editor's hidden input as before.
slide-pixels.dom.test.tsx (plugin-slides-motion, CI, real pixels through @napi-rs/canvas) compares the editor's content canvas, idle, with a shape selected, while text is selected and typed, and while dragging, with the viewer's canvas, a direct paint, the show stage and a slide picture: 0 differing pixels. The book editor and the reader are compared the same way (book, edit-parity.test.tsx: page DOM idle and editing, canvas pixels); node tools/fidelity/shell/run.mjs compares them in headless Chrome, locally, with no overrides: 0 differing pixels on every fixture page. Both apps draw the page frame (PAGE_FRAME: radius, shadow, and layer, each page its own compositing layer, so Chrome's raster tiles fall the same way on a page in either app) and Folio's page mark (creditMarkStyle, creditMarkMarkup) from one description. The mark grows on screen through real sizes (calc()s of --folio-mark-scale), never a scale() transform, which Chrome rasterises differently depending on what surrounds the page. Debugging aids: SHELL_PROBE, SHELL_LAYERS=1 (the compositing layers and why), SHELL_AT=x,y (every element at a page point).