fix(kb.gbapp): MD now can play videos.

This commit is contained in:
Rodrigo Rodriguez 2021-05-09 15:32:22 -03:00
parent 660d1309ef
commit a427566196
2 changed files with 19 additions and 3 deletions

View file

@ -238,11 +238,11 @@ export class AzureDeployerService implements IGBInstallationDeployer {
}
public async botExists(botId) {
const group = GBConfigService.get('CLOUD_GROUP');
const baseUrl = `https://management.azure.com/`;
const username = GBConfigService.get('CLOUD_USERNAME');
const password = GBConfigService.get('CLOUD_PASSWORD');
const subscriptionId = GBConfigService.get('CLOUD_SUBSCRIPTIONID');
const accessToken = await GBAdminService.getADALTokenFromUsername(username, password);
const httpClient = new ServiceClient();

View file

@ -690,10 +690,26 @@ export class KBService implements IGBKBService {
);
GBLog.info(`Translated text(playMarkdown): ${text}.`);
var renderer = new marked.Renderer();
renderer.oldImage = renderer.image;
renderer.image = function (href, title, text) {
var videos = ['webm', 'mp4', 'mov'];
var filetype = href.split('.')[1];
if (videos.indexOf(filetype) > -1) {
var out = '<video autoplay loop alt="' + text + '">'
+ ' <source src="' + href + '" type="video/' + filetype + '">'
+ '</video>'
return out;
} else {
return renderer.oldImage(href, title, text);
}
};
// Converts from Markdown to HTML.
marked.setOptions({
renderer: new marked.Renderer(),
renderer: renderer,
gfm: true,
tables: true,
breaks: false,