@@ -422,6 +422,9 @@ class SnapProcessor extends BaseProcessor {
422422 buttonColumns . has ( 'BackgroundColor' ) ? 'b.BackgroundColor' : 'NULL AS BackgroundColor' ,
423423 buttonColumns . has ( 'NavigatePageId' ) ? 'b.NavigatePageId' : 'NULL AS NavigatePageId' ,
424424 buttonColumns . has ( 'ContentType' ) ? 'b.ContentType' : 'NULL AS ContentType' ,
425+ buttonColumns . has ( 'SerializedContentTypeHandler' )
426+ ? 'b.SerializedContentTypeHandler'
427+ : 'NULL AS SerializedContentTypeHandler' ,
425428 ] ;
426429
427430 if ( this . loadAudio ) {
@@ -672,23 +675,61 @@ class SnapProcessor extends BaseProcessor {
672675 } ;
673676 }
674677
678+ let snapContentType : string | undefined ;
679+ let snapContentSubType : string | undefined ;
680+ let snapGrammarPos : string | undefined ;
681+ let snapGrammarHandler : string | undefined ;
682+
683+ if ( btnRow . ContentType === 1 ) {
684+ snapContentType = 'AutoContent' ;
685+ snapContentSubType = 'Prediction' ;
686+ } else if ( btnRow . ContentType === 3 && btnRow . SerializedContentTypeHandler ) {
687+ snapContentType = 'Inflector' ;
688+ snapGrammarHandler = String ( btnRow . SerializedContentTypeHandler ) ;
689+ const colonIdx = snapGrammarHandler . indexOf ( ':' ) ;
690+ if ( colonIdx !== - 1 ) {
691+ const subtype = snapGrammarHandler . substring ( colonIdx + 1 ) . split ( ',' ) [ 0 ] ;
692+ snapContentSubType = subtype ;
693+ const {
694+ TDSnapLexiconParser,
695+ } = require ( '../utilities/analytics/morphology/tdsnapLexiconParser' ) ;
696+ snapGrammarPos = TDSnapLexiconParser . tagToPos ( subtype ) ;
697+ }
698+ }
699+
675700 const button = new AACButton ( {
676701 id : String ( btnRow . Id ) ,
677702 label : btnRow . Label || ( btnRow . ContentType === 1 ? '[Prediction]' : '' ) ,
678703 message :
679704 btnRow . Message || ( btnRow . ContentType === 1 ? '[Prediction]' : btnRow . Label || '' ) ,
680705 targetPageId : targetPageUniqueId ,
681706 semanticAction : semanticAction ,
682- contentType : btnRow . ContentType === 1 ? 'AutoContent' : undefined ,
683- contentSubType : btnRow . ContentType === 1 ? 'Prediction' : undefined ,
707+ contentType : snapContentType as AACButton [ 'contentType' ] ,
708+ contentSubType : snapContentSubType ,
684709 audioRecording : audioRecording ,
685710 visibility : mapSnapVisibility ( btnRow . Visible as number ) ,
686711 semantic_id : btnRow . LibrarySymbolId
687712 ? `snap_symbol_${ btnRow . LibrarySymbolId } `
688- : undefined , // Extract semantic_id from LibrarySymbolId
713+ : undefined ,
689714 image : buttonImage ,
690715 resolvedImageEntry : buttonImage ,
691- parameters : Object . keys ( buttonParameters ) . length > 0 ? buttonParameters : undefined ,
716+ parameters : {
717+ ...( Object . keys ( buttonParameters ) . length > 0 ? buttonParameters : { } ) ,
718+ ...( snapGrammarHandler
719+ ? {
720+ grammar : {
721+ handler : snapGrammarHandler ,
722+ category : snapGrammarHandler . substring (
723+ 0 ,
724+ snapGrammarHandler . indexOf ( ':' ) !== - 1
725+ ? snapGrammarHandler . indexOf ( ':' )
726+ : snapGrammarHandler . length
727+ ) ,
728+ subtype : snapContentSubType ,
729+ } ,
730+ }
731+ : { } ) ,
732+ } ,
692733 style : {
693734 backgroundColor : btnRow . BackgroundColor
694735 ? `#${ btnRow . BackgroundColor . toString ( 16 ) } `
@@ -702,6 +743,10 @@ class SnapProcessor extends BaseProcessor {
702743 } ,
703744 } ) ;
704745
746+ if ( snapGrammarPos ) {
747+ button . pos = snapGrammarPos ;
748+ }
749+
705750 // Add to the intended parent page
706751 const parentPage = tree . getPage ( parentUniqueId ) ;
707752 if ( parentPage ) {
0 commit comments