@@ -11,7 +11,9 @@ import { kIncludeInHeader } from "../../config/constants.ts";
1111
1212import {
1313 Format ,
14+ FormatDependency ,
1415 FormatExtras ,
16+ kDependencies ,
1517 kTemplatePatches ,
1618 Metadata ,
1719} from "../../config/types.ts" ;
@@ -24,6 +26,8 @@ import { revealMultiplexPlugin } from "./format-reveal-multiplex.ts";
2426
2527const kRevealjsPlugins = "revealjs-plugins" ;
2628
29+ const kRevealSlideTone = "slide-tone" ;
30+
2731interface RevealPluginBundle {
2832 plugin : string ;
2933 config ?: Metadata ;
@@ -52,14 +56,24 @@ export function revealPluginExtras(format: Format, revealDir: string) {
5256 const scripts : RevealPluginScript [ ] = [ ] ;
5357 const stylesheets : string [ ] = [ ] ;
5458 const config : Metadata = { } ;
59+ const dependencies : FormatDependency [ ] = [ ] ;
5560
56- // built-in plugins + user plugins
61+ // built-in plugins
5762 const pluginBundles : Array < RevealPluginBundle | string > = [
5863 {
5964 plugin : formatResourcePath ( "revealjs" , join ( "plugins" , "line-highlight" ) ) ,
6065 } ,
6166 { plugin : formatResourcePath ( "revealjs" , join ( "plugins" , "a11y" ) ) } ,
6267 ] ;
68+
69+ // tone plugin (optional)
70+ const tonePlugin = revealTonePlugin ( format ) ;
71+ if ( tonePlugin ) {
72+ dependencies . push ( toneDependency ( ) ) ;
73+ pluginBundles . push ( tonePlugin ) ;
74+ }
75+
76+ // multiplex plugin (optional)
6377 const multiplexPlugin = revealMultiplexPlugin ( format ) ;
6478 if ( multiplexPlugin ) {
6579 pluginBundles . push ( multiplexPlugin ) ;
@@ -127,6 +141,7 @@ export function revealPluginExtras(format: Format, revealDir: string) {
127141 const extras : FormatExtras = {
128142 [ kIncludeInHeader ] : [ ] ,
129143 html : {
144+ [ kDependencies ] : dependencies ,
130145 [ kTemplatePatches ] : [ ] ,
131146 } ,
132147 } ;
@@ -190,6 +205,25 @@ export function injectRevealConfig(
190205 return template ;
191206}
192207
208+ function revealTonePlugin ( format : Format ) {
209+ if ( format . metadata [ kRevealSlideTone ] ) {
210+ return { plugin : formatResourcePath ( "revealjs" , join ( "plugins" , "tone" ) ) } ;
211+ } else {
212+ return undefined ;
213+ }
214+ }
215+
216+ function toneDependency ( ) {
217+ const dependency : FormatDependency = {
218+ name : "tone" ,
219+ scripts : [ {
220+ name : "tone.js" ,
221+ path : formatResourcePath ( "revealjs" , join ( "tone" , "tone.js" ) ) ,
222+ } ] ,
223+ } ;
224+ return dependency ;
225+ }
226+
193227function pluginFromBundle ( bundle : RevealPluginBundle ) : RevealPlugin {
194228 // confirm it's a directory
195229 if ( ! existsSync ( bundle . plugin ) || ! Deno . statSync ( bundle . plugin ) . isDirectory ) {
0 commit comments