@@ -74,6 +74,7 @@ export class Properties extends VirtualDOMView {
7474 render ( ) {
7575 switch ( this . mode ) {
7676 case "preferences" : return this . renderPreferences ( ) ;
77+ case "narration" : return this . renderNarrationProperties ( ) ;
7778 case "export" : return this . renderExportTool ( ) ;
7879 default : return this . renderPresentationProperties ( ) ;
7980 }
@@ -351,6 +352,86 @@ export class Properties extends VirtualDOMView {
351352 ] ) ;
352353 }
353354
355+ /** Render the properties view for a presentation-wide narrative.
356+ *
357+ * Three properties will be configured:
358+ * 1. narrativeType: the audio tag type; this field is a hint to
359+ * guide user in selection of an appropriate format, although
360+ * the browser can automatically detect the correct type by
361+ * itself. If this value is set to "none", narration will be
362+ * disabled. If it is set to flac or ogg, the corresponding
363+ * mimetype will be set for the <audio> type:
364+ * audio/flac or audio/ogg
365+ * 2. narrativeFile: the name (or relative path) of the narrative
366+ * file which must be available in side of the HTML file.
367+ * 3. narrativeTimeToSlide: the time-to-slide data value
368+ * Check the {narrativeTimeToSlideHelp} for details.
369+ *
370+ * @returns {VNode } - A virtual DOM tree.
371+ */
372+ renderNarrationProperties ( ) {
373+ const controller = this . controller ;
374+ const _ = controller . gettext ;
375+ const disabled = controller . presentation . narrativeType === "none" ;
376+ const toDefaultMode = ( ) => this . toggleMode ( "default" ) ;
377+
378+ return h ( "div.properties" , [
379+ h ( "div.back" , {
380+ title : _ ( "Back to presentation properties" ) ,
381+ onClick ( ) { toDefaultMode ( ) ; }
382+ } , h ( "i.fas.fa-arrow-left" , ) ) ,
383+
384+ h ( "h1" , _ ( "Narration" ) ) ,
385+
386+ h ( "label" , { for : "field-narrativeType" } , _ ( "Narrative file type" ) ) ,
387+ this . renderSelectField ( "narrativeType" , controller . getPresentationProperty , controller . setPresentationProperty , {
388+ none : _ ( "None (disable narration)" ) ,
389+ flac : _ ( "Free Lossless Audio Codec (FLAC)" ) ,
390+ ogg : _ ( "Ogg (a container for Vorbis or Opus)" ) ,
391+ } ) ,
392+
393+ h ( "label.side-by-side" , { for : "field-narrativeFile" } , [
394+ _ ( "Narrative file name" ) ,
395+ this . renderHelp ( _ ( "Name or path of the narrative file" ) ,
396+ ( ) => controller . info (
397+ _ ( "Name or path of the narrative file (relative to the HTML file location)" ) ,
398+ true
399+ )
400+ )
401+ ] ) ,
402+ this . renderTextField ( "narrativeFile" , disabled , controller . getPresentationProperty , controller . setPresentationProperty , false ) ,
403+
404+ h ( "label.side-by-side" , { for : "field-narrativeTimeToSlide" } , [
405+ _ ( "Time to frame number mapping" ) ,
406+ this . renderHelp ( _ ( "Click here to see the syntax for this field" ) , ( ) => controller . info ( this . narrativeTimeToSlideHelp , true ) )
407+ ] ) ,
408+ this . renderTextField ( "narrativeTimeToSlide" , disabled , controller . getPresentationProperty , controller . setPresentationProperty , false )
409+ ] ) ;
410+ }
411+
412+ /** The HTML of the help message for time-to-slide data.
413+ *
414+ * @readonly
415+ * @type {string }
416+ */
417+ get narrativeTimeToSlideHelp ( ) {
418+ const _ = this . controller . gettext ;
419+ return [
420+ _ ( "Format of the narrative time-to-slide data:" ) ,
421+ "<ul><li>" + [
422+ _ ( "A string of comma-separated descriptors" ) ,
423+ _ ( "Each descriptor specifies the time instant (in seconds) which should trigger a slide transition" ) ,
424+ _ ( "Descriptor can specify the target slide number (counting from one); for this purpose the time and slide index must be separated by a colon" ) ,
425+ ] . join ( "<li>" ) + "</ul>" ,
426+ _ ( "Examples:" ) ,
427+ "<ul><li>" + [
428+ _ ( "\"0\": Switch to the first slide when narrative is at zero second without any other slide transition" ) ,
429+ _ ( "\"0,5,7\": Switch to the 1st, 2nd, and 3rd slides at 0, 5, and 7 seconds of narrative" ) ,
430+ _ ( "\"0,5,7:1,10:4\": At time 7s, return to the 1st slide and at 10s resume to the 4th slide" ) ,
431+ ] . join ( "<li>" ) + "</ul>" ,
432+ ] . join ( "<br>" ) ;
433+ }
434+
354435 /** The HTML of the help message for include/exclude lists in export.
355436 *
356437 * @readonly
0 commit comments