@nextgensoftwares/folio-plugin-slides
React for @nextgensoftwares/folio-slides decks: bindings for the headless deck editor (provider and hooks), unstyled primitives, controls, inspector panels and the default SlidesApp shell, which is one composition of these public pieces. Peer react. Guides: Slides & PPTX, Building your own slides shell.
Two entries:
@nextgensoftwares/folio-plugin-slides/viewer:SlideCanvas,Thumbnails,Presenter,SlideDeckand helpers. No editor, ProseMirror or editing UI (a bundle test keeps it so: ~92 KB gzip up front with the layout engine; the shape library, WordArt warps and the student viewer's extras load on demand).@nextgensoftwares/folio-plugin-slides: everything (the viewer entry included).
import { createDeckEditor } from '@nextgensoftwares/folio-slides-editor';
import { SlidesApp } from '@nextgensoftwares/folio-plugin-slides';
const deck = createDeckEditor({ presentation });
<SlidesApp deck={deck} measurer={fonts} metrics={(f) => fonts.metrics(f)} resolveSrc={media.resolve} title="Deck" />Viewer components
SlideDeck
UI language: locale (e.g. 'ar', Arabic built in) and messages (keyed by the English text) put the bar, thumbnails, slide show and the slides' text alternatives in that language; dir (default: the locale's) mirrors the thumbnails, the bar's arrows and ←/→ right to left. SlidesApp and SlidesRoot take the same locale / messages (they reach folio-react's toolbars, menus and panels too). SlidesLocaleContext / useSlidesT() give your own slides pieces the translator in effect.
Thumbnails, the current slide and a slide show, from a Presentation (no deck editor). SlideDeckProps:
| Prop | Meaning |
|---|---|
presentation | the deck |
measurer | the layout's measurer (a FontEngine with the deck's fonts; register the same fonts with document.fonts) |
resolveSrc?(src) | media: srcs → URLs (createMediaResolver(...).resolve) |
index?, onIndexChange? | controlled current slide |
pending?(index) | slides still loading (streamed decks): placeholders |
thumbnails? | 'auto' (default: a strip under the slide when the viewer is narrower than stripBelow, 640 px), 'side', 'strip', 'none' |
className?, style? |
Keys: ←/→, PageUp/PageDown and Home/End move between slides. F5 or Ctrl/⌘+Enter presents. On touch, swipe the slide to page.
Thumbnails, SlideCanvas, Presenter
Thumbnails(ThumbnailsProps:presentation,layout,index,onSelect(index, PickMods),selected?,onMove?(indices, to),onContextMenu?(index, at),page?(index),images?,width?,className?,orientation?,sectionHeader?(range, SectionHeaderInfo),onMoveToSection?(indices, to, sectionId)): virtualized slide column (orientation: 'horizontal'gives a strip); Ctrl/Shift-click multi-select (PickMods:{ toggle, range }), drag to reorder whenonMoveis given. A deck with sections shows a header row above each section's slides (vertical lists): its name and slide count, a button that collapses it (SectionHeaderInfo:{ index, collapsed, toggle(), setAll(collapsed) }); dropping slides on a header or beside a section's slides moves them into that section (onMoveToSection).thumbRows(pres, collapsed, row, head)→ThumbRows({ ranges, rows: ThumbRow[], total, slideTop(i) }),rowsInView,dropTargetare the rows behind it.SlideCanvas(SlideCanvasProps:page,scale,images?,label?): one laid-out slide on a canvas at device resolution (withoutlabelthe canvas is hidden from assistive technology: putSlideTextnext to it).- Student viewer (
SlideDeckpropswatermark,protect,highlights,onSelectText,onHighlightClick,selectableText):SlideWatermark(SlideWatermarkProps: the reader'sReaderWatermarkOptions,variables,size,scale,index,total; tiled per-user text, put back when removed from devtools,onTamper); copy / print / context-menu deterrents with the reader'sProtectOptions(print: 'current-page'prints the slide on screen with its watermark);SlideTextLayer(SlideTextLayerProps:slide,page,scale,highlights?,onSelect?(anchor, rect),onHighlightClick?): transparent selectable text aligned with the canvas glyphs and highlights (SlideHighlight { id, anchor, color?, note? }) drawn from their anchors (re-anchored as the deck changes);slideSelectionAnchor(layer, slide)(selection →SlideTextAnchor);slideTextRuns(page)→SlideTextRun[](laid-out runs with paragraph offsets). SlideText(SlideTextProps:presentation,index,announce?): the slide's text alternative, visually hidden: a "Slide 3 of 10: Title" heading, then its text, pictures' alternative text and tables in reading order;announcesays the slide's name when it changes.slideText(slide)→SlideTextItem[](title,text,image,table),slideName(presentation, index). Shows, the presenter view, replays and read-only surfaces use it.Presenter(PresenterProps:presentation,layout,start,onClose(last),images?,resolveSrc?for audio/video,mediaNotice?/renderMediaNotice?for those that can't play): fullscreen show; →/Space/Enter/click/swipe left forward, ←/Backspace/swipe right back, Esc leaves, N notes; hidden slides skipped; fades for slides with transitions; auto-advance timings.EmbedLayer(slide,scale,allow?): embedded web pages (PicShape.embed) as sandboxed iframes over their posters, only whereallow(EmbedPolicy;allowHosts(['youtube-nocookie.com', '*.example.org']), https only) accepts the URL, else a link;embedUrl(url)turns YouTube/Vimeo watch links into players.SlideDeckandDeckProviderPropstakeallowEmbed.MediaLayer(MediaLayerProps:slide,scale,resolve,autoPlay?,mediaNotice?,renderMediaNotice?): the slide's audio and video as native players over their poster frames (the viewer, reading view and slide show use it). One that can't play gets a notice in its frame instead of a dead player:- when
resolvereturns''(or nothing, or throws) for its storedmediaSrc:reason: 'empty'; when the player fireserror(missing file, unsupported format):reason: 'error', kept per shape and src, so a new src plays again; - the built-in notice: an icon and "This video can't be played" / "This audio can't be played" (Arabic built in) in a badge over the poster, dimmed; only the icon in frames under 120 × 36 px;
role="status"with the text as its name; coloured by the theme tokens (--folio-bg,--folio-text,--folio-border,--folio-canvas; the system colours without them), so light, dark and sepia follow; mediaNotice(src, kind)(kind:'video' | 'audio';srcis the stored ref as saved, e.g.'__pending:x', not the resolved URL) returns the text (plain text, one line, capped at 200 characters) or undefined for the built-in one;renderMediaNotice(info)draws the notice itself:MediaNoticeInfo { src (the stored ref), kind, poster? (resolved), reason, label (the text Folio would show, after mediaNotice) }; Folio places it in the frame's box (scaled), the host fills it. null/undefined, or a throw (caught by an error boundary), falls back to the built-in notice;- both are taken from the props, else the enclosing
DeckProvider/SlideDeck(MediaNoticeContext). The editor canvas, Present (Presenter), the viewer (SlideDeck) and folio-plugin-slides-motion's slide show use them.MediaNotice(its drawing a lazy chunk),noticeLabel,playableSrc,useMediaErrors,useMediaNoticeHooksare exported (viewer entry) for hosts with their own players.
- when
SLIDES_CSS: the viewer stylesheet (--fsd-*custom properties).- Streaming:
createSlideSource(skeleton, fetchSlides, SlideSourceOptions?)→SlideSource(presentation,isLoaded(i),load(indices),around(index, radius?),subscribe): every slide known up front, shapes fetched for a window around the viewed slide,keepcaps how many stay loaded.useSlideStream(source, index, radius?)→{ presentation, pending }forSlideDeck(pendingprop) andThumbnails(pending): placeholders until slides arrive. - Touch paging:
useSwipe(ref, onSwipe(dir), { rtl?, enabled? })pages on a one-finger horizontal swipe. Swiping left goes forward, mirrored in RTL (the element's own direction by default). A pinch cancels it, the click a swipe ends with is swallowed, and the element getstouch-action: pan-y pinch-zoom.swipeDir(dx, dy, ms, { rtl?, min? })→1 | -1 | 0is the rule behind it. - Helpers:
stepSlide(index, count, key, { rtl?, presenter? })(NavKey),visibleRows(scrollTop, viewport, rowHeight, count, overscan?),scrollToRow(...),fitScale(w, h, bw, bh),pickSlides(selected, anchor, index, mods),createMediaResolver(lookup: MediaLookup, keep = 200)→{ resolve, dispose }(MediaLookupreturns bytes{ data, type }or a Blob, such asmediaBlob(pkg, src)for a deck opened withopenPptxFile; blob URLs made when first asked for; pastkeepthe least recently used are revoked and made again when needed),loadImage(url)(decoded pictures cached within a budget, 256 MB by default:setImageCacheBudget(bytes)). Thumbnails painted before come back from bitmaps (64 MB, keyed by the laid-out page: an edited slide, local or remote, is painted again).
Provider and hooks
<DeckProvider> puts a deck editor and its environment in context and keeps the current slide's editor session open in edit mode. DeckProviderProps: deck, measurer, locale? / messages? (UI language, placeholder prompts included; SlidesApp passes its own), resolveSrc?, metrics?, user? (comment author), fonts? (families for font pickers), storeImage?(file) (→ PickedImage{ src, w, h, alt? }; default dataUrlImage), layers?, plugins? (document plugins for slide text), math? (SlidesMath: { measurer, html?, canvas? }, equations through the host's math renderer, e.g. KaTeX: measurer sizes them for layout, html draws them on the slide being edited, canvas on thumbnails, the read-only view, the slide show; SlidesApp takes it too). useDeckEnv() returns the DeckEnv (deck, measurer, layout, images, resolveSrc, metrics, fonts, storeImage, session).
| Hook | Returns |
|---|---|
useDeck() | the DeckEditor |
useDeckState(select) | a value from the state, re-read on change (return state parts or primitives, never a new array or object) |
usePresentation(), useSelection(), useSelectedShapes() | the deck; { slides, shapes }; selected shapes as model objects |
useSlide(index?) | { index, slide, page } (laid-out page, memoized) |
useCommand(id), useCanExecute(id, args?), useIsActive(id, args?) | a runner; whether it would do something; its toggle state |
useActiveFormat() | ActiveFormat of the text being edited or the selected shapes |
useDeckItems(surface, group?), useDeckSlots(name) | visible plugin items / slot components. Slots the package renders: 'inspector' (tabs), 'thumbnail' (over each thumbnail; props { index }, through ThumbnailsProps.decorate), 'surface' (drawn over the editing canvas; component props SurfaceOverlayProps { scale, host() }), 'presenter' (replaces the built-in slide show in DeckPresenter) |
useThumbnails() | { count, size, page(i), images, presentation } with a per-slide layout cache |
useSlideSession() | the current SlideSession (null outside edit mode) |
useColorResolver() | resolves ColorRefs through the current slide's theme and colour map to #rrggbb |
Slide session (framework-free)
createSlideSession(deck, SlideSessionOptions) → SlideSession: the current slide on the layers editor wired to the deck: edits written back as undo steps (typing merges), object selection mirrored both ways, text edited in place becomes the deck's text target, Mod-Z/Y run the deck's history. Options:measurer,layers?,plugins?.SlideSessionaddsindexandproducedtoSlideEditor.createSlideEditor(pres, index, SlideEditorOptions) → SlideEditor:{ editor, composed, layers, apply(pres), destroy() }, the editor without a deck.slidesPlugin(): the schema plugin (paragraph/run props ride along in edited text).toObjectId(id),fromObjectId(id): model shape id ↔ layers object id (s:<id>).
Primitives
All need a <DeckProvider> and fill the box you give them.
| Component | What it is |
|---|---|
SlideEditorSurface (SlideEditorSurfaceProps: zoom?, padding?, onScale?, className?, style?) | the current slide: the layers editor in edit mode (right-click: 'contextMenu' items), a canvas otherwise; fits its box. Pan: Space + drag, middle-button drag, or dragging the grey area when zoomed past fit (data-pan / data-zoomed on .fsd-surface for the cursor; Space still types while editing text). With grid.ruler it shows rulers along its top and left edges, and the deck's guides while grid.guides is on (both loaded on demand) |
ThumbnailList (ThumbnailListProps: width?, editable?, className?) | the deck's slide column: selection, drag reorder (into a section: section.moveSlides), 'slideMenu' context menu (Add section included), Delete / Ctrl+D on slides; section headers are SectionHeaders (loaded with the first deck that has sections) |
SlideSorter (SlideSorterProps: width?, className?) | grid of every slide (only cells in view mounted; each section heads its own rows: sorterGrid → SorterGrid of SorterBlocks), multi-select, drag reorder, double-click opens |
SectionHeader (SectionHeaderProps: range, info) | a section's header: click collapses, double-click or F2 renames, right-click opens its menu (rename, remove, remove with slides, move up / down, collapse / expand all, remove all, plus 'sectionMenu' items) |
NotesPageView | View › Notes Page (DeckMode 'notes'): the current slide's notes page (the notes master's layout and page size), the slide image above notes edited in place |
OutlineView, slideOutline(slide) | titles and text of every slide, click opens; the outline of one slide |
NotesEditor (NotesEditorProps: index?, placeholder?, className?, style?) | speaker notes as plain text (slide.notes); the browser checks their spelling in the notes' language unless spelling is switched off |
SelectionOverlay (SelectionOverlayProps: scale, className?) | outlines of the selected shapes over a canvas (custom surfaces) |
DeckPresenter | the slide show while the deck is in 'present' mode |
Controls
| Export | What it is |
|---|---|
SlideToolbar (SlideToolbarProps: groups?, className?), defaultToolbarGroups() | folio-react's overflow-aware toolbar with the default groups |
HistoryGroup, SlideGroup, InsertGroup, TextGroup, ParagraphGroup, ArrangeGroup, PresentGroup, ToolGroup | the groups, each usable alone (ToolGroup wraps your own); ParagraphGroup: superscript/subscript, link, bullets and numbering, indent, line/paragraph/character spacing, capitals |
DrawButtons, DrawLayer (DrawLayerProps: host, scale) | pen tools (freehand, recognized shape) and the stroke layer the editor surface puts over the slide |
FormatPainterButton | takes the selected shape's format and paints the next shape selected (double-click keeps painting until Esc); in the history group |
ConnectorLayer (host, scale) | connectors: with a connector:<preset> tool (picked from the Shapes menu's lines) a drag draws one, nearby shapes' connection sites show and the nearest highlights to glue to; a selected connector's ends are handles (filled when glued) to glue elsewhere or drag off. Esc cancels, Enter inserts a plain line |
EditPointsLayer (host, scale), outlineOf(shape) | edit points (tool 'points'): anchors and curve handles over the selected shape, drag to move, double-click to delete, committed as shape.path; a shape's outline as editable commands |
GridControl | show the grid, snap moves to it, spacing |
RulerToggle, GuidesControl | View › Ruler (rulers in cm, or inches in US locales, counted from the slide's centre, the selection's extent shaded) and View › Guides (show them, add a horizontal or vertical guide through the centre, delete all). On the slide a guide drags (Ctrl: a copy, Alt: off the ruler's steps), leaves when dragged off the slide, and recolours or deletes from its right-click menu; a drag out of a ruler makes a new one. Shapes snap to shown guides (LayersController.snapLines). The top ruler shows the edited (or one selected) text box's indents per outline level and its tab stops: drag them, drag a tab off to remove it; while editing, a click adds a stop of the kind picked in the ruler's corner (text.ruler). Guides are Presentation.guides, saved in the PPTX and never shown in the show, thumbnails or PDF |
ShapeGallery (ShapeGalleryProps: onPick(preset), presets?), PresetIcon | preset previews by category, drawn by the slide geometry |
LayoutPicker (LayoutPickerProps: onPick(layoutId), current?, width?), layoutPreview(pres, layoutId) | layout previews (new slide / change layout) |
TablePickerGrid | rows × columns picker |
insertEmbed(deck, url) | embeds a web page (16:9 card poster, the page shown where allowed); the toolbar's Web page item |
DeckProviderProps.mediaLibrary, insertFromLibrary(deck, LibraryEnv, 'image' | 'media'), insertMediaSrc(deck, { kind, src, name?, poster?, width?, height? }) | the host's media picker (folio-editor's MediaLibrary) for Insert ▸ Pictures and Video or audio instead of the file input: stored items placed by reference (pictures sized from the item or the image), files stored through storeImage / storeMedia; an audio/video shape for stored media |
insertMedia(deck, file, store?) | adds an audio or video file (poster: the video's first frame, a speaker icon for audio); DeckProviderProps.storeMedia stores it (default: a data: URL, embedded on export) |
DeckItemButton, DeckItems, DeckMenu, toMenuItems(deck, items) | render plugin items: a button, a surface or group of buttons, a context menu |
SLIDE_ICONS, slideIcon(name) | slide icons on top of folio-react's set |
HeaderFooterButton, HeaderFooterDialog | Insert › Header & Footer. Slide tab: date and time (automatic in one of the 13 formats and a language, or fixed), slide number, footer, don't show on title slide; Apply / Apply to All (slide.headerFooter). Notes and Handouts tab: date and time, header, page number, footer on notes pages and handouts (notes.headerFooter). The dialog loads on demand |
SymbolButton, SymbolDialog, SYMBOL_BLOCKS, blockChars(block), searchSymbols(query), symbolName(ch) | Insert › Symbol: font, Unicode block, search by name (a compact table of common symbols and the Greek alphabet) or code (U+2192), recently used symbols (kept in localStorage when available); inserts at the caret of the text being edited, else in a new text box (text.insert). Loaded on demand |
SectionButton, SectionPanel | Home › Slides › Section: add a section at the selected slide, rename the current one, remove all (loaded on demand) |
Inspector panels
FormatShapePanel (size and position, fill, outline, text box, alt text), SlidePanel (layout, hide, background, transition), NotesPanel, SelectionPane (shapes front to back: select, hide, reorder), ThemePanel (slide size from SLIDE_SIZES, theme fonts, theme colours), SpellingPanel (Review › Spelling: the deck's misspelled words from the host's spellcheck, else the built-in English one, with suggestions, Change, Change All, Ignore All, and the "check spelling as you type" switch), CommentsPanel (the slide's comment threads: start as DeckProviderProps.user ({ name, initials?, id? }), reply, resolve / reopen, edit, delete, show resolved; CommentPins draws numbered pins over the slide's open threads).
Threads use folio-plugin-comments' threading (its /core entry): commentUserId(name) makes a user id folio-plugin-comments accepts from a name (PowerPoint's comment authors have names only). CommentsPanel draws threads with folio-plugin-comments' shared pieces (CommentView, Composer, cards, avatars, reactions), the same as the document comments.
slideCommentOp(deck, op, user, now?) applies a CommentOp (create, reply, edit, delete, resolve, react) to the current slide's comments with that package's validation, sanitizing, limits and rules (a reply reopens a resolved thread), storing the result through comment.add / comment.set (undoable); it throws CommentError on an invalid op. SlideCommentUser is CommentAuthor & { initials? }. toCommentThread(comment) / fromCommentThread(thread, was, at, user?) convert between SlideComment and CommentThread (a point anchor; the pin stays on the slide comment). Live, multi-user comment stores are folio-slides-collab's business. Sections for custom panels: ShapeExtrasSection (lock, opacity, corner radius), PictureSection (replace, crop per side, mask), TableSection (rows, columns, header/body colours, banding, borders), TableStyleSection (built-in and deck styles with previews, style options), TableCellsSection (pick a block of cells; fill, borders, vertical alignment), BackgroundFields (layout / solid / gradient / picture, apply to all). INSPECTOR_PANELS lists them as 'inspector' slot items; inspectorPlugin() registers them as a plugin (for custom shells reading useDeckSlots('inspector')).
Feature plugins
codeSlidesPlugin(): a "Code block" toolbar item (CodeInsert): code highlighted with folio-plugin-code's grammars, written as coloured runs in a monospace box (plain DrawingML text: editable, exported as is). Helpers:insertCode(deck, code, language, paletteId?),codeShape(code, tokens, palette, opts?),codeParagraphs(code, tokens, palette, size?),loadLanguage(id),CODE_PALETTES(GitHub, One, Solarized, Monochrome; light and dark).mathSlidesPlugin({ render, preview? }): an "Equation" toolbar item with plugin-math's symbol palette (preview: LaTeX → HTML for its buttons, e.g. KaTeXrenderToString; symbols insert at the caret, wrapping the selection): LaTeX rendered by the host (MathRenderer:latex → Promise<{ src, w, h }>, e.g. KaTeX or MathJax to PNG) and inserted as a picture whose alt text keeps the LaTeX (equationLatex(descr)), so PowerPoint shows it and selecting it here edits it again.insertEquation(deck, render, latex, replaceId?).
Host hooks (DeckHostHooks, on DeckProviderProps and SlidesAppProps):
exportPdf: the Slide panel's Save as PDF (full page slides, notes pages, or handouts with 1–9 slides per page and their order:opts.handouts). Built in by default (its own chunk):exportSlidesPdfwith the font files the app measured with (aFontEnginemeasurer keeps them:faceData; embedded deck fonts, the font loader's faces and stand-ins), else re-laid out with folio-fonts' bundled OFL faces; pictures fetched throughresolveSrc(PNG, JPEG). A function replaces it (return the bytes to download, or save the file yourself);falsehides it.mediaNotice(src, kind)/renderMediaNotice(info): the notice over a video or audio clip that can't play (seeMediaLayerabove), in the editor canvas, Present and the slide show.SlideDecktakes them too.spellcheck(words, lang)(SpellChecker): per word null (right) or suggestions. Absent: the built-in checker (folio-react'sbuiltInSpellcheck: English, see spell);false: none (the Spelling pane says checking is off). Slide text is drawn by Folio (a hidden text field takes the typing), so the browser's checker can't see it: with a checker, misspelled words of the slide being edited (text boxes, shapes, groups, table cells, rotated text) get a wavy underline (the layer loads on demand; folio-model's spelling core, shared with the document editor), right-click offers the suggestions and Ignore All, and the Spelling pane lists the whole deck. Speaker notes are a real text field: the browser checks them natively (with the notes'lang).spelling(deck)→SpellingState,setSpelling(deck, { on?, ignored? }),useSpelling(deck),subscribeSpelling(deck, fn): the switch, Ignore All words and the current slide's issues.
DeckProviderProps.ensureFonts(families) loads fonts the deck starts using (a picked font, a code block); slides re-lay out when it resolves, and a FontReport it resolves adds its substituted and missing families to standIns. DeckProviderProps.standIns (and SlideDeckProps.standIns): families drawn with a stand-in or missing (e.g. the import's font report), whose text boxes shrink to fit. DeckEnv also carries the pen tool (SlideTool: 'select' | 'draw' | 'shape' | 'points', or connector:<preset> while drawing a connector) and the grid (GridSettings: { show, snap, size }) with their setters.
Default shell
SlidesApp (SlidesAppProps): DeckProviderProps plus title?, onTitleChange?, titlePlaceholder?, status?, brand?, people?, actions?, theme?, onThemeChange?, themeToggle?; regions appBar?, toolbar?, toolbarGroups?, rail?, railWidth?, canvas?, panels? (inspector tabs; default INSPECTOR_PANELS plus the deck's 'inspector' slot items), panelWidth?, statusBar?, notes? (each region: false hides it, a node replaces it); features? (SlidesFeatures: parts left out everywhere); focus?, onFocusChange?, focusNotes? (SlidesFocusProps: focus mode, controlled, and notes focus: see Focus mode); unstyled?, dir?, className?, style?, children?. Built on folio-react's AppShell. The views are normal, slide sorter, outline, reading and slide show. The ribbon sits under the app bar across the whole window, as in PowerPoint.
The app bar's Import menu (importers?: SlidesImporter[] { label, accept, run(file) } added to it, false hides it) has Pictures as slides and PDF as slides. PDF as slides paints each page with pdf.js (pdfjs-dist, an optional peer dependency, loaded on first use through folio-import-formats' openPdf: no scripting, XFA or fetching), one page at a time, stores each picture through storeImage (default: a data: URL) and adds them with deck.importPictures in one undo step: fitted and centred, the page's text as the picture's alt text. A deck with nothing on it takes the pages' aspect (its longer side kept) and loses its empty slides. Progress and Cancel show in the import dialog. pdfImport? (PdfSlidesOptions): worker? (pdf.js's Worker factory; default: parse on the main thread), maxPages? (300), maxSide? (2560 px, the long side of a page's picture), maxPixels? (4096², hostile page sizes scale down), text?, encode?, onError? (default alert), onWarning? (pages left out; default console.warn); false leaves it out. A host importer whose accept takes .pdf (its own rasterizer) replaces it. Outside the app: importPdfAsSlides(deck, file, storeImage, options?) → slides added, and rasterizePdf(bytes, { onPage, createCanvas?, ... }) (a Node canvas works, e.g. @napi-rs/canvas), rasterSize, pageSlideSize, PDF_SLIDES_MAX_PAGES. rasterizePdf resolves { total, imported, truncated }; its RasterizePdfOptions are worker, maxSide, maxPages, maxPixels, text (default true), signal, onProgress(done, total), createCanvas(w, h) → PdfCanvas ({ width, height, getContext('2d') }; default an HTMLCanvasElement), encode(canvas) (default a JPEG blob at 0.9) and the required onPage(page), called with each PdfPagePicture ({ index, data: Blob | string, w, h, pageSize: { w, h } in pt, text }) before the next page is painted: store it then, so pictures don't pile up.
Slides from PowerPoint (.pptx)… is PowerPoint's Reuse Slides. folio-pptx loads on first use. The picked file opens in a dialog that shows its slides as thumbnails: a list of checkboxes, all ticked at first, with Select all. The user chooses "Use this deck's theme" (the default) or "Keep source formatting" (the slides' masters, layouts and theme come along, see reuseSlides in folio-slides), then Insert.
- Where they go: after the current slide, in one undo step (
deck.reuseSlides). - Pictures and media: pictures are stored through
storeImage, audio and video throughstoreMedia(else as data: URLs). One that can't be stored is left empty and reported throughonWarning. - Progress: reading and storing show progress with Cancel.
pptxImport? (PptxSlidesImportOptions) takes worker? (as PptxFileOptions.worker; default: the main thread), open? (import options), read? (reads the file instead), onError? (default alert) and onWarning? (default console.warn). false leaves the item out. With file, its read (the same worker and options) reads the file. A host importer whose accept takes .pptx replaces it. Outside the app, readPptx(file, options) reads a file and storeReused(dest, source, reuseOptions, { storeImage, storeMedia?, blob }) stores the media a reuse brings, giving { source, failed } for deck.reuseSlides.
SlidesStatusBar(SlidesStatusBarProps:zoom,onZoom,fitScale?,notes?,onNotes?,views?): slide position, view switcher (views: falsehides it), notes toggle (only withonNotes), zoom.deckKeyDown(deck, event),SURFACE_KEYS: routes key events to the deck's bindings (form fields excluded; inside the slide editor onlySURFACE_KEYS, never while text is typed).SLIDES_APP_CSS: the editor pieces' stylesheet; colours from Folio's tokens through--fsd-*properties.SlidesRoot(SlidesRootProps:features?,shell?,unstyled?,density?('compact': ribbon groups without captions),keys?(default true: the deck's key bindings on keys inside it),dir?,className?,style?): the root for pieces placed in a host's own layout withoutSlidesApp(inside aDeckProvider): thefolio-ui fsd-app fsd-embedclasses, the CSS once, the features and shell handles the controls read (buttons that open a panel, toggle notes or fit hide withoutshell).SlidesStyles,slidesCss(): that CSS as an element or a string. See Embedding.SlidesFeatures(notes,comments,accessibility,present,ai,design,transitions,animations,export(save as picture),master,views,focus;SlidesFeaturea key): parts a host leaves out withfalse(SlidesAppProps.features,SlidesRootProps.features): panels, ribbon tabs and groups, toggles, keys, slide marks. Plugins' items, slots and commands marked withfeaturefollow it too (useDeckItems,useDeckSlotsand the inspector leave them out; keys bound to their commands do nothing).featureOn(features, id),useFeature(id)(SlidesFeaturesContext),featurePanels(panels, features),featureTabs(tabs, features)(a tab left with only its plugins' slot shows when filled),keyOff(deck, key, features).
Files (pptxFile)
pptxFile(opts?: PptxFileOptions) → PptxFile ties a deck to .pptx files:
- Options (
PptxFileOptions):deck(default: a new editor),worker(a factory for thefolio-pptx/workermodule worker),open(OpenPptxOptions: font policy,convertImage, limits),keep(blob URLs kept) andonOpen(result, file). - Returns
{ deck, getState, subscribe, open(file), save(), dispose() }.getState()gives aPptxFileState:name(without the.pptx; null for a new deck),resolveSrc(the open file'smedia:sources as blob URLs; a new one per file, so the last file's pictures never show),busy('open','save'or null) anderror(the last failure);subscribe(fn)follows it andusePptxFile(file)reads it in React.open(file)imports intodeck(in the worker when given, else on the main thread), clears undo and resolves theOpenPptxResult; it rejects when the file can't be read.dispose()stops the worker and revokes the blob URLs.save()returns the deck as .pptx bytes. The opened package's parts are kept, and media left in the file are read back in (exportPptxFile).
<SlidesApp file={file}> uses the controller's deck and picture resolver, takes the file name as the default title, and adds a File menu (FileMenu: Open…, Save as PowerPoint; a lazy chunk). deck is optional when file is given. @nextgensoftwares/folio-pptx is an optional peer, loaded on the first open or save.
Master view UI
MasterList (the left column in master view: each master then its layouts as thumbnails; picking one opens it) and MasterBar (what is being edited, its name, how many slides use a layout, Close master view). SlidesApp swaps them in when DeckState.sheet is set; the slide group's Slide master button toggles the view. sheetList(pres) lists the sheets in that order. useViewPresentation() is the presentation being drawn (master view's one-slide view). The slide session edits the view and writes changes back to the sheet.
View › Handout Master ({ kind: 'handout' }, its code loaded first with loadHandoutView()) uses the same pieces: the left column shows the handout page, and MasterBar becomes the Handout Master bar (HandoutBar): Slides Per Page, their order, Handout Orientation, the Header, Date, Footer and Page Number placeholders and Close master view. The notes strip is hidden there.
DesignGallery ({ designs? }, default DESIGN_PRESETS): design cards (background, heading font, accents) at the top of ThemePanel.
Slide pictures
exportSlideImage(pres, index, SlideImageOptions) → Promise<Blob>: one slide painted with the screen's layout and painters at width px (default twice the slide width), as type (image/png default, image/jpeg, image/webp; quality; background, white for JPEG). It loads the preset shape library first when needed. exportSlideImages(pres, opts & { slides? }) does several slides in order. math draws equations (SlidesMath.canvas; lay them out with layout.math). canvas ({ create(w, h), encode(c, type, quality) }, ImageCanvas) lets Node hosts use their own canvas; the default is OffscreenCanvas or a DOM canvas. downloadBlob(blob, name) saves a file through the browser. ExportSection (in the Slide panel) saves the current slide as PNG or JPEG at 1×, 2× or 4×.
AccessibilityPanel (the Accessibility inspector tab, also in reading mode) checks the deck in idle slices (useA11yIssues(pres) → A11yProgress { bySlide, done, total }; it never blocks typing, shows results as they come, and re-checks only changed slides). Issues are grouped by slide (collapsed, with counts) in a virtualized list. Hovering an issue outlines its shape on the slide, or marks the slide in the rail for slide-level issues. Clicking one goes to the slide, selects the shape and scrolls it into view. Missing alt text can be filled in in place. setDeckHighlight(deck, DeckHighlight | null) / useDeckHighlight(deck) point at a slide or shape ({ slideId, shape?, inner?, reveal? }), and HighlightLayer (in the editor surface) draws the outline.
AI extension point
Folio ships no model, no keys and no network calls. DeckProviderProps.ai (SlidesAI) is where a host plugs in its own service. Every capability is optional:
rewrite({ text, instruction, context })→ plain text (one paragraph per line) for the selected shape, applied withtext.set.notes({ context })→ speaker notes, applied withslide.notes.altText({ src, url, context })→ a picture's alt text, applied withshape.alt.outline({ prompt, context })→SlidesAIOutline[]({ title, bullets: { text, level }[] }), appended withdeck.addOutline.actions: { id, label, run({ deck, context }) }[]: anything else, running commands itself.
label names the menu (default "AI"). SlidesAIContext is { presentation, index, slideText, selection, signal } (aiContext(deck, signal)); signal aborts when the user cancels. AiMenu (the toolbar's ai group) renders only when ai is given. Every result goes through an undoable command.
ChartDataSection (in the Format panel for charts, shown only when the deck registers chart.data, i.e. chartDataPlugin()) is a grid of categories by series. You can edit names and values, add or remove rows, and add or remove series.
SmartArtTextSection is in the Format panel for SmartArt. The SmartArt Design tab's "Text pane" button opens it, and both show only when the deck registers smartArtPlugin(). It is PowerPoint's text pane: one line per node, indented by level. Enter adds a node, Tab / Shift+Tab demote and promote, Alt+↑/↓ move, and Backspace on an empty line removes it. Typing shows at once; the diagram is laid out again when typing pauses.
With smartArtPlugin() registered, Insert has a SmartArt gallery (SmartArtLayouts). The SmartArt Design tab adds Layouts, Change colours and Styles (SmartArtLook). The gallery lists the 25 layouts by category (List, Process, Cycle, Hierarchy, Relationship, Matrix, Pyramid); its menu and styles are a lazy chunk.
Find and replace
SlidesApp has deck-wide find and replace: Ctrl/⌘+F, Ctrl+H (⌘⌥F on a Mac), F3 / Shift+F3, Enter / Shift+Enter, Ctrl+Alt+Enter replaces all, Esc closes. The bar is the documents' find bar (role="search", announced "3 of 41", options including "Search notes", full width on phones) at the top right of the slide area, with results grouped by slide ("Slide 3 of 10: Title"). Going to a match shows its slide, selects its shape and highlights the text on the slide being edited; tables, SmartArt, charts and rotated text get the shape outlined (setDeckHighlight). Matches in the speaker notes are marked in the notes strip (NotesEditor), the current one scrolled into view. The slide editor's own document find is off (find={false} on its view).
| Export | Description |
|---|---|
useDeckFind() → DeckFindUI | inside a DeckProvider: { open, replace, find: DeckFind | null, focusToken, show(replace), setReplace, close, onKeyDownCapture }; while open, the matches on the edited slide are a highlight layer of its editor |
SlidesFind ({ ui }) | the bar in its anchor, for your own shell: put it above the slide area and ui.onKeyDownCapture on your root |
DeckFindBar, DeckFindBarProps | the bar alone: find, replace, onReplaceChange, onClose, focusToken? |
slideTextRangeRects(page, measurer, shapeId, para, from, to) → SlideRect[] | page px boxes of a text range in a text box as laid out (shaped advances, justified spacing); empty for rotated or grouped text |
Ribbon
SlideRibbon (SlideRibbonProps: { tabs?, className? }) is PowerPoint's ribbon, a TabStrip over an overflow-aware Toolbar of the current tab's groups. SlidesApp uses it (prop ribbonTabs; toolbarGroups brings back the compact toolbar). defaultRibbonTabs() → RibbonTab[] ({ id, label, contextual?, when?(RibbonState), groups() }; RibbonState is { selection, editing, filled }) has Home, Insert, Design, Transitions, Animations (shown when a plugin fills it), Slide Show, Review, View, plus the contextual Shape Format, Picture Format, Table Design, Layout and Chart Design.
The groups are exported to rebuild tabs: homeGroups, insertGroups, designGroups, transitionsGroups, animationsGroups, slideShowGroups, reviewGroups, viewGroups, shapeFormatGroups, pictureFormatGroups, tableDesignGroups, tableLayoutGroups, chartDesignGroups. So are their pieces:
RibbonGroup(a captioned group).PanelButton(opens an inspector panel).ShapeColors(shape fill and outline).TextBoxButton,ShapesButton,PictureButton,TableButton,MediaButton,WebPageButton,HeaderFooterButton,SymbolButton,SectionButton.useSelectionKind().
Plugins put content on a tab with toolbar items in group ribbon.<tab> and slot components ribbon.<tab> (RibbonSlot, useRibbonSlot). SlidesShellContext / useSlidesShell() → SlidesShell ({ openPanel(id), notes, setNotes(on), fit() }): what SlidesApp lets controls drive (null elsewhere). DeckProviderProps.insertSources (InsertSource[]: { id, label, icon?, pick() → Promise<PickedImage | null> }) adds host picture sources (icons, stock photos, a screenshot) to Insert.
The Format pane (FormatShapePanel) has Shape options (fill, line, EffectsSection with opacity, ShadowFields, ReflectionFields (presets, transparency, size, distance, blur), GlowFields (accent × size presets, colour, size, transparency) and SoftEdgeFields (presets in pt, size), picture/table/chart sections, size and properties with alt text) and Text options (TextOptions: text fill, transform, text box with margins).
Shape interactions
Edit points (EditPointsLayer, tool 'points') map every point through the shape's full transform: path space to the box, rotation, flips, the groups around it and the zoom (shapeMatrix). All anchors show; the selected one shows its handles with tangent lines. Dragging an anchor carries its handles. Right-clicking an anchor offers smooth or corner point, straight or curved segment, add or delete point, and open or close path. Double-click the outline to add a point; Delete removes one. Edits are committed in the shape's frame (shape.path { frame: true }), so a rotated or flipped shape keeps every unmoved point where it was. Selected preset shapes show yellow adjust handles (AdjustHandlesLayer, from the ECMA-376 definitions) with a live preview, committed as shape.geometry. The rotation handle sits above the box. Shift keeps the aspect ratio when resizing and snaps rotation to 15°.
Slide content never takes the app theme's colours. The editor page's colours are pinned, and hidden slides get a dashed outline and a struck-out number instead of being dimmed (a dimmed white slide reads as grey on a dark rail).
Host selection actions
| Export | What |
|---|---|
SlideSelectionAction, SlideSelectionActions | a host action for selected slide text or shapes (SelectionAction from folio-a11y), and the selectionActions prop of SlideDeck (list or render function) |
SlideSelectionContext | { source: 'viewer' | 'editor', slideIndex, slideId, text, anchor, shapeIds, rect, close() } |
SlidesSelectionActionsContext | React context carrying the actions, for custom shells built from the parts |
editorSelection(...) | the editor's selection as a SlideSelectionContext |
hostMenuItems(...) | the host's actions as context-menu items (SlidesApp puts them first) |