I'd like to add css class names depending on the card type to the corresponding html element.
I already did this by setting the [AdaptiveCard.customCssSelector] 1 attribute.
E.g. you just need to add builder.card.customCssSelector = "ac-thumbnail"; in this line and the resulting html-block will contain class="ac-container ac-thumbnail".
However, I'd like to be independent of Botframework-Webchat updates and put this logic into a middleware. According to the BotFramework-Webchat docs it's possible to add attachmentMiddleware to the renderWebChat function and manipulate the html elements.
In fact I get activities and attachments, but I'm not able to manipulate html-blocks or add a css selector.
Here's my middleware code:
export const cardCssSelector = ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/INCOMING_ACTIVITY') {
const { activity } = action.payload;
for (var index in activity.attachments) {
const card = activity.attachments[index].content;
if(card.tap && card.tap.value){
card.customCssSelector = 'tap';
}
}
}
console.log(action);
return next(action);
};
Of course this doesn't work, since the attachments don't have the customCssSelector attribute.
