@kivacore/ui-pro-slidedeck
v0.8.0
Published
Kiva slide deck editor with a standalone document model and editable PowerPoint import and export.
Readme
@kivacore/ui-pro-slidedeck
A React slide editor backed by a standalone TypeScript document model. Use a bounded parent to fit the filmstrip, stage and inspector into a page or a canvas tab.
import { useState } from 'react';
import { DeckModel, SlideDeck } from '@kivacore/ui-pro-slidedeck';
import '@kivacore/ui-pro-slidedeck/styles.css';
export function Review() {
const [model] = useState(() => new DeckModel());
return (
<div style={{ height: '75vh' }}>
<SlideDeck model={model} title="Design review" locale="tr" />
</div>
);
}| Prop | Purpose |
| --- | --- |
| model | Share a DeckModel with other views or commands. Omit it for an editor-owned deck. |
| title | Editor heading and download filename. |
| locale | English (en, default) or Turkish (tr). |
| readOnly | Browse, present and export a deck with editing disabled. |
| onChange | Receive the new document after a change, undo or redo. |
| onSelectionChange | Receive the active slide ID, primary object ID and all selected object IDs. |
| className | Style the editor's root. |
The filmstrip adds, duplicates, reorders and removes slides. Double-click a text box to type. Drag an object to move it, or use its corner handle to resize it. The properties panel provides numeric position and size fields, text and fill formatting, layer order, slide background and speaker notes. Use the arrow keys to nudge a selected object, hold Shift for ten-unit steps, and use Ctrl/Cmd+Z to undo. Presentation mode supports arrow keys and Escape.
Format part of a text box
Double-click a text box, select a word or phrase, and use the text formatting toolbar for bold, italic, underline, color or font size. With just a caret, the selected style applies as you type. Ctrl/Cmd+B, I and U toggle emphasis. Clear inline formatting restores the box defaults for the selection. Escape returns to object selection. Alt+F10 focuses the toolbar.
Formatted text can be copied between text boxes, viewed in thumbnails and the presenter, and exported as editable PowerPoint text. Deck JSON keeps the full plain text string. Optional spans contain ordered, non-overlapping UTF-16 offsets (from inclusive, to exclusive) and any overrides for bold, italic, underline, color or fontSize. Omitted properties inherit the box style.
Paragraph lists
Choose Bulleted list or Numbered list while editing a text box. The control applies to the current paragraph or the selected paragraphs. Choosing the active list type again returns them to ordinary text. Tab and Shift+Tab change list depth, as do the two indentation buttons. Enter continues the list at the same level. Enter on an empty item ends the list.
Optional lists metadata has one entry per newline-delimited paragraph. Use null for plain text or { kind: "bullet" | "number", level: 0..8 } for a list item. Markers are generated separately from the text and its character formatting. PowerPoint export writes native bullet and automatic numbering properties with editable levels.
Embedded audio and video
Choose Audio for an MP3 or M4A (AAC) file, or Video for an MP4 file. The editor checks the codecs when you choose a file. An MP4 with H.264 video and either AAC audio or no audio is the recommended combination for PowerPoint. A warning identifies other codecs or reports unreadable metadata. Files the browser can play can still be added. The editor preserves the original file bytes and captures the first video frame for the slide preview. You can move, resize and copy these objects like images.
In Present, use the player on the slide to play, pause or seek. Leaving the slide stops playback. Deck JSON carries the file in the object's src data URL. Exported PPTX files include the media and its click-to-play action, so you can play them in PowerPoint offline.
Entrance and exit animations
Select an object and open Properties → Animations. Choose Appear or Fade for its entrance and Disappear or Fade for its exit. Set the click step and, for fades, the duration in milliseconds. Give effects the same step number to play them together. An object's exit follows its entrance.
In Present, click the slide or press Space or → to play the next step. ← restores the previous step. The editor and filmstrip show the full composition. PowerPoint export writes editable effects on the original objects, with the same click groups and fade durations.
Version 1 deck objects accept optional entrance and exit fields. Each is either { effect: "instant", step: 1 } or { effect: "fade", step: 1, durationMs: 500 }. Steps are positive integers, and gaps are skipped. A fade lasts 1–60,000 ms. The usual revision-checked object patches accept both fields, with null to remove an effect.
Business presentation templates
Open Presentation templates to browse 16 five-slide decks by business use. Preview the sequence, then insert it after the selected slide. A new blank deck adopts the template’s theme. An existing deck keeps its theme, and Undo removes the entire insertion. Text, charts and tables stay editable in the editor and in PowerPoint. Each deck has its own visual design across the cover and interior slides. All slide content, titles, chart labels, image descriptions and speaker notes are in English. Gallery controls and category filters follow the editor locale.
import { createBusinessTemplate, listBusinessTemplates } from '@kivacore/ui-pro-slidedeck/templates';
const catalog = listBusinessTemplates('tr');
const presentation = createBusinessTemplate(catalog[0].id);
model.insertTemplate(presentation);Slide layouts and theme
Open Slide layouts to preview a single slide in the current presentation theme. Choose a layout to fill an untouched blank slide or insert it after the current one. Undo removes the insertion in one step. Layout names and sample content follow the English or Turkish editor locale.
| Layout | Editable content | | --- | --- | | Title + image | A headline, supporting text and an image frame | | Two columns / Three columns | Two or three ideas with aligned headings and space for examples | | Comparison | A pair of options in contrasting panels | | Section cover | A section title and introduction on the accent background | | Agenda | Three timed discussion topics and a meeting objective | | Milestone timeline | Three dated milestones with descriptions | | Key metric | A headline number, its definition and a comparison | | Chart + takeaway | A column chart with editable source data and a separate interpretation | | Action plan | A table of actions, owners and due dates |
Double-click a text box, chart or table to edit its contents. Double-click the image frame to choose a PNG or JPEG. The chart and table export as native PowerPoint objects.
Open Presentation theme to change the accent color and heading font across the deck. Layouts, thumbnails, the presenter and PowerPoint export share the same styling. In Properties, choose Heading for a text box or select a theme color source for a fill, text or slide background. Existing version 1 documents keep their explicit colors and body typography until you assign a theme style.
const deck = new DeckModel();
const slideId = deck.addLayout('twoColumns', deck.getSnapshot().slides[0].id, 'tr');
deck.addLayout('comparison', slideId, 'tr');
deck.setTheme({ accent: '#2956a3', headingFont: 'Georgia' });Deck JSON carries an optional theme object. Color fields accept hex values or theme:accent, theme:tint, theme:ink and theme:onAccent. A text box with role: "heading" inherits the heading font. Pass theme={document.theme} when embedding the standalone SlideSurface.
Arrange three columns
- Create a text box or shape and size it using its corner handle. Copy it and paste twice with Ctrl/Cmd+C and Ctrl/Cmd+V or the toolbar buttons.
- Shift-click the three objects, or drag a selection rectangle around them from empty space on the slide. Ctrl/Cmd+A selects every object on the current slide. A further Shift-click toggles membership.
- Choose Arrange → Align top, then Arrange → Distribute horizontally. Distribution equalizes the gaps between object edges. It uses the outer bounds of the selection when there is room. Overlapping copies spread across the slide with an inset when space permits.
Drag a selection together. Pink guides show where its edges or center snap to the slide or another object. Hold Alt while dragging to move freely. Arrow keys nudge the whole selection. Each move, alignment, distribution, paste or deletion takes one undo step. A single selected object aligns to the slide. Multiple objects align within the selection bounds.
Copying a selection preserves relative positions, styling, images and stacking order across slides. Pasted objects receive new IDs. Text fields keep their normal text-editing shortcuts.
Document model
Import from @kivacore/ui-pro-slidedeck/engine in a browser or Node process. Each model owns its undo history. getSnapshot() returns an immutable, JSON-serializable document. subscribe(listener) observes commits and returns an unsubscribe function.
A version 1 document holds an ordered, nonempty array of slides. Each slide has a stable ID, name, background color, notes and an ordered list of text boxes, shapes, PNG/JPEG images, audio, video, tables and charts. Geometry uses a 960 × 540 coordinate system. The list order also determines stacking order.
import { createText, DeckModel, parseDeck } from '@kivacore/ui-pro-slidedeck/engine';
const deck = new DeckModel();
const first = deck.getSnapshot().slides[0];
deck.updateSlide(first.id, { name: 'Launch', notes: 'Introduce the team.' });
deck.insertElement(first.id, { ...createText('Launch review'), bold: true });
const json = JSON.stringify(deck.getSnapshot());
const restored = new DeckModel(parseDeck(JSON.parse(json)));File → Open PowerPoint or deck JSON opens a local .pptx as editable slides. Undo restores the previous deck in one step. The importer reads slide order, speaker notes, formatted text, nested lists, rectangles, ellipses, embedded PNG/JPEG images, MP3/M4A/MP4 media, and supported click-triggered entrance and exit effects. It fits the source proportions into the editor’s 960 × 540 frame. Text placeholders can inherit their position from the layout or master.
Use Add table or Add chart in the toolbar to create an object on the current slide. Start with a blank 3 × 3 table or a column chart with one sample series and three categories. Choose a chart type and edit the values before pressing Insert. Cancel discards the draft.
Use the add buttons to append rows, columns, categories or series. The delete buttons on row and column headers remove the corresponding entry. Removing a category removes its value from each series. A merged table cell that crosses a deleted row or column retains its content in the remaining span. Each table keeps at least one row and column, and each chart keeps at least one category and series. Pie and doughnut charts support one series.
Double-click a table or chart, press Enter on the object, or select it and use Edit table cells or Edit chart data. You can edit multiline cell text, the chart title, category labels, series names and numeric values. A blank chart value stays blank. Apply updates the preview and creates one undo step. Merged table cells retain their spans. Export writes native PowerPoint tables and charts with an embedded Excel workbook containing the edited values.
Supported charts include 2D column, bar, line and area charts (including stacked and percentage-stacked series), plus single-series pie and doughnut charts. SlideDeck reads cached or literal chart values and can resolve simple row or column references in an embedded workbook when the cache is missing. It imports values independently of source formulas. Complex axis styles, number formats, table styles and point-specific colors may differ.
The import report identifies slides with skipped drawings such as SmartArt, combination charts and scatter plots, external media, or simplified appearance and animations. Layout and master decorations, typography outside the editor’s font set, and advanced drawing styles can differ from PowerPoint. Linked files stay offline. Import accepts up to 256 MiB of file data and 256 MiB of expanded parts, with 16 MiB per XML part.
Hosts can call const { document, warnings } = await importPowerPoint(file) from @kivacore/ui-pro-slidedeck/engine. It accepts a Blob, Uint8Array or ArrayBuffer. Each warning contains a one-based slide number and a feature category. Invalid presentations reject before the editor replaces its document.
The File menu opens and downloads deck JSON for lossless editing. It also exports a PowerPoint file with native text, shapes, tables, charts, images, embedded media and speaker notes. The PowerPoint writer loads on demand. Hosts can call exportPowerPoint(snapshot, title) to obtain a Blob.
For collaborative field edits, call listSlides(), inspectSlide(slideId) and inspectObject(slideId, objectId). Pass the returned revision to applyEdits([{ op: 'updateObject', slideId, objectId, ifRevision: revision, patch: { text } }]). Use updateSlide with the slide's revision to edit its name, notes or background. Revisions are scoped to one model instance. Changes to a sibling object leave a target's revision valid. A batch commits once or throws before changing anything. Its undoToken can be passed to undoEdits(token) while the affected targets retain their revisions.
In the playground open /components/slidedeck for the editable Orbit studies example. Agent Canvas exposes the same editor through its New → Slide deck menu and its deck commands.
