### Full Setup and Development Commands
Source: https://github.com/reveal/revealjs.com/blob/master/src/installation.md
Commands to clone the repository, install dependencies, and start the development server for reveal.js.
```shell
git clone https://github.com/hakimel/reveal.js.git
cd reveal.js && npm install
npm start
```
--------------------------------
### Install Dependencies and Start Development Server
Source: https://github.com/reveal/revealjs.com/blob/master/README.md
Installs project dependencies using Yarn and starts the development server. The server provides automatic reloading for changes made during development.
```sh
yarn
yarn start
```
--------------------------------
### Install @revealjs/react
Source: https://github.com/reveal/revealjs.com/blob/master/src/react.md
Installation command for the @revealjs/react package and its peer dependencies using npm or yarn.
```bash
npm i @revealjs/react reveal.js react react-dom
# or
yarn add @revealjs/react reveal.js react react-dom
```
--------------------------------
### Install Reveal.js via npm or yarn
Source: https://context7.com/reveal/revealjs.com/llms.txt
Demonstrates how to install the reveal.js framework as an npm package for use in modern JavaScript projects. This allows for integration with build tools and ES module imports.
```bash
# Install via npm
npm install reveal.js
# Or via yarn
yarn add reveal.js
```
--------------------------------
### Math Plugin Initialization
Source: https://github.com/reveal/revealjs.com/blob/master/src/math.md
Example of initializing reveal.js with the Math plugin enabled, using KaTeX as the typesetting library.
```APIDOC
## Initialization with Math Plugin
### Description
This snippet shows how to include the Math plugin and initialize reveal.js with KaTeX support.
### Method
JavaScript Initialization
### Endpoint
N/A
### Parameters
N/A
### Request Example
```html
```
### Response
N/A
```
--------------------------------
### Install reveal.js via npm
Source: https://github.com/reveal/revealjs.com/blob/master/src/react-legacy.md
Command to install the reveal.js package as a dependency in your project.
```bash
npm install reveal.js
```
--------------------------------
### Configure Development Server Port
Source: https://github.com/reveal/revealjs.com/blob/master/src/installation.md
Command to start the reveal.js development server on a custom port.
```shell
npm start -- --port=8001
```
--------------------------------
### Install Reveal.js React Dependencies
Source: https://context7.com/reveal/revealjs.com/llms.txt
Use npm to install the necessary packages for running reveal.js within a React project.
```bash
npm i @revealjs/react reveal.js react react-dom
```
--------------------------------
### Configuring Reveal.js Deck with Options and Plugins
Source: https://github.com/reveal/revealjs.com/blob/master/src/react.md
Provides an example of setting up the `Deck` component with custom reveal.js configuration options and plugins. This includes setting presentation dimensions, hash navigation, and transition effects, along with integrating the highlight plugin.
```tsx
import { Deck, Slide } from '@revealjs/react';
import 'reveal.js/reveal.css';
import 'reveal.js/theme/black.css';
import 'reveal.js/plugin/highlight/monokai.css';
import RevealHighlight from 'reveal.js/plugin/highlight';
export function Presentation() {
return (
Oranges
$2
18
```
--------------------------------
### Implement an Asynchronous Plugin
Source: https://github.com/reveal/revealjs.com/blob/master/src/creating-plugins.md
Illustrates how to return a Promise in the init function to delay reveal.js initialization, useful for loading external resources or performing async setup tasks.
```javascript
let WaitForIt = {
id: 'wait-for-it',
init: (deck) => {
return new Promise((resolve) => setTimeout(resolve, 3000));
},
};
Reveal.initialize({ plugins: [WaitForIt] }).then(() => {
console.log('Three seconds later...');
});
```
--------------------------------
### Create React Presentation Components
Source: https://context7.com/reveal/revealjs.com/llms.txt
Implement a presentation using the Deck and Slide components. This example demonstrates custom hooks, slide nesting, fragments, code blocks, and markdown integration.
```tsx
import { Deck, Slide, Stack, Fragment, Code, Markdown, useReveal } from '@revealjs/react';
import 'reveal.js/reveal.css';
import 'reveal.js/theme/black.css';
import 'reveal.js/plugin/highlight/monokai.css';
import RevealHighlight from 'reveal.js/plugin/highlight';
function NextButton() {
const deck = useReveal();
return ;
}
export function Presentation() {
return (
{`const a = 1;\nconst b = 2;\nconst c = a + b;`}
Apples $1
Oranges $2
Apples
$1
7
Oranges
$2
18
Kiwi
$3
1
```
--------------------------------
### Configure Reveal.js Presentation Options
Source: https://context7.com/reveal/revealjs.com/llms.txt
Illustrates how to initialize a Reveal.js presentation with various configuration options. This includes settings for controls, progress bar, slide numbers, navigation behavior, appearance, size, auto-sliding, fragments, and plugins.
```javascript
Reveal.initialize({
// Display controls
controls: true,
controlsTutorial: true,
controlsLayout: 'bottom-right',
// Progress bar
progress: true,
// Slide numbers: true, false, 'h.v', 'h/v', 'c', 'c/t'
slideNumber: 'c/t',
// Navigation
hash: true,
history: true,
keyboard: true,
overview: true,
touch: true,
loop: false,
// Appearance
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
transitionSpeed: 'default', // default/fast/slow
backgroundTransition: 'fade',
// Presentation size
width: 960,
height: 700,
margin: 0.04,
minScale: 0.2,
maxScale: 2.0,
// Auto-slide (milliseconds, 0 = disabled)
autoSlide: 0,
autoSlideStoppable: true,
// Fragments
fragments: true,
fragmentInURL: true,
// Plugins
plugins: [RevealMarkdown, RevealHighlight, RevealNotes]
}).then(() => {
console.log('reveal.js is ready');
});
```
--------------------------------
### Customize Auto-Slide Navigation Method
Source: https://github.com/reveal/revealjs.com/blob/master/src/auto-slide.md
Configures the autoSlideMethod to define custom navigation behavior during auto-sliding. This example restricts navigation to horizontal slides only.
```javascript
Reveal.configure({
autoSlideMethod: () => Reveal.right(),
});
```
--------------------------------
### Configuring Highlight Plugin
Source: https://github.com/reveal/revealjs.com/blob/master/src/code.md
Shows the necessary CSS and JavaScript includes to initialize the highlight plugin in a reveal.js presentation.
```html
```
--------------------------------
### Markdown Slide Attributes
Source: https://github.com/reveal/revealjs.com/blob/master/src/markdown.md
Shows how to apply attributes to the generated slide `
Open Link
```
--------------------------------
### Receiving Events via postMessage
Source: https://github.com/reveal/revealjs.com/blob/master/src/postmessage.md
Explains how to listen for messages from a reveal.js presentation, specifically for event bubbling. This example shows how to capture slide change events.
```APIDOC
## GET /postMessage Events
### Description
Listens for events dispatched by a reveal.js presentation running in an iframe.
### Method
GET (via window.addEventListener('message'))
### Endpoint
Parent window
### Parameters
#### Query Parameters
N/A
#### Request Body
N/A
### Request Example
```javascript
window.addEventListener('message', (event) => {
var data = JSON.parse(event.data);
if (data.namespace === 'reveal' && data.eventName === 'slidechanged') {
// Slide changed, see data.state for slide number
console.log('Slide changed to:', data.state);
}
});
```
### Response
#### Success Response (200)
- **namespace** (string) - The namespace of the event (e.g., 'reveal').
- **eventName** (string) - The name of the event (e.g., 'slidechanged').
- **state** (object) - The state associated with the event (e.g., current slide information).
#### Response Example
```json
{
"namespace": "reveal",
"eventName": "slidechanged",
"state": {
"indexh": 0,
"indexv": 1,
"indexf": 0,
"slide": "You clicked {count} times
You clicked {count} times