1+ /* This file contains reusable functions useful for managing designer functionality */
2+
13import { Guid } from '@microsoft/sp-core-library' ;
24import { CardDesigner , IChoicePickerItem , SnippetPaletteItem , ToolbarButton , ToolbarChoicePicker } from "adaptivecards-designer" ;
35
6+ // Given the instance of a "CardDesigner", it allows you to hide an element of the toolbar given its id.
47export const hideToolbarElement = ( cardDesigner : CardDesigner , elementId : string ) => {
58 cardDesigner . toolbar . getElementById ( elementId ) . isVisible = false ;
69} ;
710
11+ // Given the instance of a "CardDesigner", it allows you to add an element in the toolbar.
812export const addToolbarButton = ( cardDesigner : CardDesigner , caption : string , iconClass : string , positionElementId : string , isAfter : true , hideElementId ?: string , onClick ?: ( sender : ToolbarButton ) => void ) : string => {
913 let id = `__${ Guid . newGuid ( ) . toString ( ) } _ToolbarButton` ;
1014 let newToolbarButton = new ToolbarButton (
@@ -25,6 +29,7 @@ export const addToolbarButton = (cardDesigner: CardDesigner, caption: string, ic
2529 return id ;
2630} ;
2731
32+ // Given the instance of a "CarDesigner", it allows you to add a snippets to the toolbox.
2833export const addToolboxSnippet = ( cardDesigner : CardDesigner , category : string , name : string , payload : object ) => {
2934 let newSnippet = new SnippetPaletteItem ( category , name ) ;
3035 newSnippet . snippet = payload ;
@@ -35,6 +40,7 @@ export const addToolboxSnippet = (cardDesigner: CardDesigner, category: string,
3540 cardDesigner . customPaletteItems . push ( newSnippet ) ;
3641} ;
3742
43+ // Given the instance of a "CarDesigner", it allows to add a "Choice Picker" to the toolbar
3844export const addToolbarChoicePicker = ( cardDesigner : CardDesigner ,
3945 afterElementId : string ,
4046 separator : boolean ,
@@ -51,6 +57,7 @@ export const addToolbarChoicePicker = (cardDesigner: CardDesigner,
5157 return id ;
5258} ;
5359
60+ // Convert nulls to empty strings, used for binding with Adaptive Card Template
5461export const convertNullToEmptyString = ( object : any ) => {
5562 for ( var key in object ) {
5663 if ( null === object [ key ] || undefined === object [ key ] ) object [ key ] = '' ;
0 commit comments