@nextgensoftwares/folio-plugin-canvas
Boards for React: <BoardApp>, a whiteboard app made of Folio's own components and tokens (light and dark), where every feature is a plugin and every piece is public. Guide: Boards.
import { FolioStyles } from '@nextgensoftwares/folio-react';
import { BoardApp, lecturePlugins } from '@nextgensoftwares/folio-plugin-canvas';
const plugins = lecturePlugins(); // keep the array stable (module scope or useMemo)
<FolioStyles />
<div className="folio-ui" style={{ height: '100vh' }}>
<BoardApp plugins={plugins} title="Lecture 7" text={textEngine} onReady={(board) => {}} />
</div>The board fills the window under Folio's app bar. Its plugins bring the rest: tools in a floating dock at the bottom with the current tool's options in a tray just above it, a selection bar over what is selected with what it can change, controls in the corners (undo and pages bottom left, zoom bottom right; on narrow screens they move to the top), app bar actions. A board without plugins is a plain board you can select on, and only the tools its plugins bring can be picked, by keys too.
Plugins
| Export | What it brings |
|---|---|
whiteboardPlugins(), lecturePlugins() | everything (frames and Present on whiteboards), as a whiteboard (infinite dotted canvas, select first, paper following the app) or a lecture board (bounded grid pages, pens first, white paper) |
navigatePlugin() | select and pan |
penPlugin({ colors, penSizes, markerSizes, marker, eraser }), PenPluginOptions | pen, marker and eraser; ink colours and thickness in the tray and on selected ink |
laserPlugin({ colors, color, width, glow, tail, core }), LaserPluginOptions, LASER_COLORS | the laser pointer, a glowing comet: its colours in the tray, its look |
stickyPlugin({ colors }) | sticky notes: colours in the tray; note colour, text size and bold on the selection |
shapesPlugin({ shapes, quick }) | native and Office shapes: quick shapes and a gallery in the tray; fill, line colour, text size and bold on the selection |
textPlugin() | text boxes; text size and bold on the selection |
connectorPlugin() | connectors that attach to shapes: route and arrowheads in the tray and on the selection; line colour |
imagePlugin() | pictures from a file, pasted or dropped onto the board, embedded |
framePlugin() | frames (F): titled areas that carry their contents; title (or double-click it on the board) and colour on the selection |
historyPlugin(), zoomPlugin(), pagesPlugin({ always }) | undo and redo; zoom; the page switcher (on bounded or multi-page boards, or always) |
minimapPlugin() | a Map button beside zoom: the board drawn small with the view outlined; click or drag on it to move the view (in whiteboardPlugins) |
exportPlugin({ exporters, builtins }) | the Export menu: the page as SVG, every page as PowerPoint (loaded on first use), your exporters |
presentPlugin(), PresentButton, setPresenting(board, on), isPresenting(board), PRESENT_EVENT | Present in the app bar: the board app goes fullscreen (Escape stops); with collabPlugin everyone else follows this view |
lecturePlugin({ pageSize, background }) | bounded pages, white paper, the pen first |
ToolPluginOptions | every tool plugin's group: dividers fall between groups in the dock |
Live collaboration comes from its own entry point, so boards that don't collaborate don't load it (it needs @nextgensoftwares/folio-canvas-collab):
@nextgensoftwares/folio-plugin-canvas/collab | |
|---|---|
collabPlugin(collab, { pointer, people, status, present }), CollabPluginOptions | the board edits collab.store (from joinCanvas or createCollabCanvas); everyone's cursors, strokes and laser trails; the people here and the save state in the app bar; this user's pointer to the others; presenting: the presenter's view is shared, everyone else sees who presents and follows them (their page and the area they show) until they pan or zoom, with Follow to catch up again |
shareBoardPointer(board, collab) | just the pointer, for your own shell; returns a cleanup |
bindPresenting(board, collab), presenterBanner(collab) | presenting and following for your own shell (returns a cleanup); the "… is presenting" banner component |
Your own plugins
A BoardPlugin is one object; every field is optional.
| Field | |
|---|---|
name | its name (and dock group by default) |
options, paper | board options it needs (the host's options win); app or page paper |
tools, dock, group | board tools it offers; dock entries: board tools, image, |, or your buttons (DockAction: { id, label, icon, run(board), active?, shortcut? }, the icon a name, SVG path data or your own element) |
trays | per tool, a component shown above the dock while it is on |
selection | SelectionItems: { id, order, when(objs), locked?, component }, or selectionAction({ id, label, icon, run(board, objs), when, active, order }) for a button |
widgets | BoardWidgets: { id, place: 'tl' | 'tr' | 'bl' | 'br' | 'over', order, component } |
config | colours and shapes its controls offer |
exporters | Export menu entries (BoardExporter) |
bar | app bar actions, and people and status as Readables (get(), subscribe(fn)) |
setup(board) | runs once the board is mounted; return a cleanup |
composeBoardPlugins(list) → ComposedBoardPlugins adds them up as BoardApp does: options merge (later wins), tools and dock entries append, selection items and widgets are unique by id and sorted by order.
App
| Export | Description |
|---|---|
BoardApp, BoardAppProps | the app: plugins, arrange, options, text, onReady, the app bar's title, status, people, actions, brand, theme, credit; slots, unstyled, children (host overlays) |
BoardArrange | arrange: the last word on what the plugins add up to: dock(items), selection(items), widgets(list) return the entries to show, in order |
BoardSlots | appBar, dock, selectionBar: leave out for the default, false hides, a node replaces |
BoardConfigProvider, useBoardConfig(), BoardUiConfig, DEFAULT_CONFIG, DockAction, DockItem, TOOL_META | what the controls read (BoardApp provides it from its plugins): colours, shapes, dock, trays, selection items, text engine; how each tool shows |
BoardProvider, useBoard(), useBoardState(select, fallback, equal?), sameList | the board for the pieces inside; a value read from it, re-read on change |
BOARD_CSS, WHITEBOARD_CSS | the app's CSS (fcv- classes on --folio-* tokens); unstyled skips it |
Whiteboard pieces
| Export | Description |
|---|---|
ToolDock | the dock (the configured entries, or items) with the tool tray |
ToolTray, InkTray, Sizes, StickyColors, LaserColors, QuickShapes, NewConnectorStyle, ConnectorStyle, PEN_SIZES, MARKER_SIZES | the current tool's tray and the built-in trays' parts |
SelectionBar, SELECTION_ITEMS, CORE_SELECTION_ITEMS, selectionAction | the bar over the selection (hidden while dragging; only unlock and duplicate on locked objects); the built-in entries plugins offer (noteColor, inkColor, inkSize, fill, lineColor, textSize, bold, route; FRAME_ITEMS.frameTitle, frameColor with FRAME_COLORS); the ones always there (align and distribute, group and ungroup as ARRANGE_ITEMS, lock, unlock, duplicate, delete, order; ink alone gets duplicate and delete) |
HistoryControl, ZoomControl, PageSwitcher | undo and redo; zoom (the level fits); previous, next, every page as thumbnails, new page |
Minimap({ width, height, text, every }), MinimapControl | the map itself (redrawn at most every every ms, 150 by default, and held still while dragged on), and the Map button that shows it |
Controls
| Export | Description |
|---|---|
ToolToggle, NavigateTools, HistoryButtons, EditButtons, ArrangeButtons, useTool(), useSelectionIds() | tools as toggles; select and pan; undo and redo; duplicate and delete; stacking order |
DrawTools, InkColors, InkSize, TouchModePicker, INK_COLORS | pens, marker, eraser, laser; one-tap ink colours and a picker; thickness; what fingers do |
ShapeGallery, ShapeGrid, ShapeButton, useShapePreviews(), useShapeChoice(), SHAPE_CHOICES, ShapeChoice | native and Office shapes previewed by the board's painters, as a dropdown, a grid or single buttons |
StickyButton, STICKY_COLORS, TextButton, ImageButton, NewPageButton | sticky colours; the text tool; pictures (embedded); pages |
SelectionColors, useSelectedObjects(), BackgroundButtons, BACKGROUNDS, FitButtons | fill, outline and note colours of the selection; paper; fit and 100% |
PagesRail, PageThumb | page thumbnails drawn by the board's renderer, redrawn when a page changes |
ExportMenu, BoardExporter, BUILTIN_EXPORTERS | SVG of the page; PowerPoint of every page (loads on first use); host exporters |
BOARD_ICONS, boardIcon(name) | board icons in folio-react's style |
An office-style shell
The ribbon, inspector and status bar a board had before the whiteboard layout are still here for hosts that want a board inside an Office-like editor: compose BoardRibbon (RibbonGroup, defaultBoardTabs, BoardRibbonTab), PagesRail, FormatPanel and BoardStatusBar (BoardStatusBarProps, BoardCredit) in a folio-react AppShell inside a <BoardProvider>.