How to use the adaptivecards.AdaptiveCard function in adaptivecards

To help you get started, weā€™ve selected a few adaptivecards examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotFramework-WebChat / packages / playground / src / DebugAdaptiveCardAttachment.js View on Github external
this.createAdaptiveCard = memoize(content => {
      const card = new AdaptiveCard();
      const errors = [];

      // TODO: [P3] Move from "onParseError" to "card.parse(json, errors)"
      AdaptiveCard.onParseError = error => errors.push(error);

      card.parse({
        version: '1.0',
        ...content
      });

      AdaptiveCard.onParseError = null;

      return {
        card,
        errors
      };
github DominicMaas / TimelineExtension / src / scripts / menu.ts View on Github external
data.payload.forEach((activity) => {
                // Create an AdaptiveCard instance
                const adaptiveCard = new AdaptiveCards.AdaptiveCard();

                // Host Config defines the style and behavior of a card
                adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
                    containerStyles: {
                        default: {
                            backgroundColor: "#FF37474F",
                            foregroundColors: {
                                default: {
                                    default: "#FFEEEEEE",
                                    subtle: "#FFEEEEEE"
                                }
                            }
                        }
                    },
                    fontFamily: "Segoe UI, Helvetica Neue, sans-serif"
                });
github microsoft / ConversationLearner-UI / src / components / modals / AdaptiveCardViewer / AdaptiveCardViewer.tsx View on Github external
render() {
        if (!this.props.open || !this.props.template) {
            return null;
        }
        let card: HTMLElement | null = null

        try {
            const template = getProcessedTemplate(this.props.template, this.props.actionArguments, this.props.hideUndefined)
            
            AdaptiveCards.AdaptiveCard.onProcessMarkdown = ((text, result) => {
                result.outputHtml = this.md.render(text)
                result.didProcess = true
            })

            const adaptiveCard = new AdaptiveCards.AdaptiveCard()
            adaptiveCard.hostConfig = this.getAdaptiveCardHostConfig()
            adaptiveCard.parse(template)
            card = adaptiveCard.render()
        }
        catch (e) {
            // Ignore error, show error message below
        }
        return (
            
                <div>
                    <div></div></div>
github microsoft / BotFramework-Emulator / packages / custom-botframework-webchat / src / AdaptiveCardContainer.tsx View on Github external
mountAdaptiveCards() {
        const adaptiveCard = this.props.nativeCard || new AdaptiveCard();

        adaptiveCard.hostConfig = this.props.hostConfig || defaultHostConfig;

        let errors: IValidationError[] = [];

        if (!this.props.nativeCard && this.props.jsonCard) {
            this.props.jsonCard.version = this.props.jsonCard.version || '0.5';
            adaptiveCard.parse(cardWithoutHttpActions(this.props.jsonCard));
            errors = adaptiveCard.validate();
        }

        adaptiveCard.onExecuteAction = (action) => this.onExecuteAction(action);

        if (errors.length === 0) {
            let renderedCard: HTMLElement;
github microsoft / BotFramework-Emulator / packages / custom-botframework-webchat / src / CardBuilder.tsx View on Github external
constructor() {
        this.card = new AdaptiveCard();

        this.container = new Container();
        this.card.addItem(this.container);
    }
github microsoft / BotFramework-Emulator / packages / custom-botframework-webchat / built / CardBuilder.js View on Github external
constructor() {
        this.card = new adaptivecards_1.AdaptiveCard();
        this.container = new adaptivecards_1.Container();
        this.card.addItem(this.container);
    }
    addColumnSet(sizes, container) {
github microsoft / AdaptiveCards / source / nodejs / adaptivecards-designer / src / sample-picker-dialog.ts View on Github external
]
                }
            ]
        };

        let template = new ACData.Template(templatePayload);
        
        let context = new ACData.EvaluationContext();
        context.$root = {
            title: this.title,
            catalogue: catalogue
        };

        let expandedCardPayload = template.expand(context);

        let card = new Adaptive.AdaptiveCard();
        card.hostConfig = defaultHostConfig;
        card.onExecuteAction = (action: Adaptive.Action) => {
            if (action.id == "cancel") {
                this.close();
            }
            else if (action instanceof Adaptive.SubmitAction) {
                this._selectedSample = catalogue[action.data["catalogueIndex"]];

                this.close();
            }
        }
        card.onParseElement = (element: Adaptive.CardElement, json: any, errors?: Adaptive.IValidationError[]) => {
            if (element instanceof Adaptive.CardElementContainer) {
                element.allowVerticalOverflow = Adaptive.getBoolValue(json["allowVerticalOverflow"], false);
            }
        }
github microsoft / BotFramework-WebChat / src / AdaptiveCardContainer.tsx View on Github external
mountAdaptiveCards() {
        const adaptiveCard = this.props.nativeCard || new AdaptiveCard();

        adaptiveCard.hostConfig = this.props.hostConfig || defaultHostConfig;

        let errors: IValidationError[] = [];

        if (!this.props.nativeCard && this.props.jsonCard) {
            this.props.jsonCard.version = this.props.jsonCard.version || '0.5';
            adaptiveCard.parse(cardWithoutHttpActions(this.props.jsonCard));
            errors = adaptiveCard.validate();
        }

        adaptiveCard.onExecuteAction = this.onExecuteAction.bind(this);

        if (errors.length === 0) {
            let renderedCard: HTMLElement;
github microsoft / BotFramework-Emulator / packages / custom-botframework-webchat / built / AdaptiveCardContainer.js View on Github external
mountAdaptiveCards() {
        const adaptiveCard = this.props.nativeCard || new adaptivecards_1.AdaptiveCard();
        adaptiveCard.hostConfig = this.props.hostConfig || defaultHostConfig;
        let errors = [];
        if (!this.props.nativeCard && this.props.jsonCard) {
            this.props.jsonCard.version = this.props.jsonCard.version || '0.5';
            adaptiveCard.parse(cardWithoutHttpActions(this.props.jsonCard));
            errors = adaptiveCard.validate();
        }
        adaptiveCard.onExecuteAction = (action) => this.onExecuteAction(action);
        if (errors.length === 0) {
            let renderedCard;
            try {
                renderedCard = adaptiveCard.render();
            }
            catch (e) {
                const ve = {
                    error: -1,