1
+ /* This file contains reusable functions useful for managing designer functionality */
2
+
1
3
import { Guid } from '@microsoft/sp-core-library' ;
2
4
import { CardDesigner , IChoicePickerItem , SnippetPaletteItem , ToolbarButton , ToolbarChoicePicker } from "adaptivecards-designer" ;
3
5
6
+ // Given the instance of a "CardDesigner", it allows you to hide an element of the toolbar given its id.
4
7
export const hideToolbarElement = ( cardDesigner : CardDesigner , elementId : string ) => {
5
8
cardDesigner . toolbar . getElementById ( elementId ) . isVisible = false ;
6
9
} ;
7
10
11
+ // Given the instance of a "CardDesigner", it allows you to add an element in the toolbar.
8
12
export const addToolbarButton = ( cardDesigner : CardDesigner , caption : string , iconClass : string , positionElementId : string , isAfter : true , hideElementId ?: string , onClick ?: ( sender : ToolbarButton ) => void ) : string => {
9
13
let id = `__${ Guid . newGuid ( ) . toString ( ) } _ToolbarButton` ;
10
14
let newToolbarButton = new ToolbarButton (
@@ -25,6 +29,7 @@ export const addToolbarButton = (cardDesigner: CardDesigner, caption: string, ic
25
29
return id ;
26
30
} ;
27
31
32
+ // Given the instance of a "CarDesigner", it allows you to add a snippets to the toolbox.
28
33
export const addToolboxSnippet = ( cardDesigner : CardDesigner , category : string , name : string , payload : object ) => {
29
34
let newSnippet = new SnippetPaletteItem ( category , name ) ;
30
35
newSnippet . snippet = payload ;
@@ -35,6 +40,7 @@ export const addToolboxSnippet = (cardDesigner: CardDesigner, category: string,
35
40
cardDesigner . customPaletteItems . push ( newSnippet ) ;
36
41
} ;
37
42
43
+ // Given the instance of a "CarDesigner", it allows to add a "Choice Picker" to the toolbar
38
44
export const addToolbarChoicePicker = ( cardDesigner : CardDesigner ,
39
45
afterElementId : string ,
40
46
separator : boolean ,
@@ -51,6 +57,7 @@ export const addToolbarChoicePicker = (cardDesigner: CardDesigner,
51
57
return id ;
52
58
} ;
53
59
60
+ // Convert nulls to empty strings, used for binding with Adaptive Card Template
54
61
export const convertNullToEmptyString = ( object : any ) => {
55
62
for ( var key in object ) {
56
63
if ( null === object [ key ] || undefined === object [ key ] ) object [ key ] = '' ;
0 commit comments