|
|
|
@ -3,7 +3,7 @@ import {
|
|
|
|
|
PipeTransform
|
|
|
|
|
} from '@angular/core';
|
|
|
|
|
|
|
|
|
|
import * as linkifyString from 'linkifyjs/string';
|
|
|
|
|
import * as linkify from 'linkifyjs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
@ -22,13 +22,27 @@ export class SplitMessagePipe implements PipeTransform {
|
|
|
|
|
|
|
|
|
|
let regexp = RegExp('(' + exps.join('|') + ')');
|
|
|
|
|
|
|
|
|
|
// FIXME: do not split URLs
|
|
|
|
|
let tokens = message.split(regexp);
|
|
|
|
|
let options = new linkify.options.Options();
|
|
|
|
|
|
|
|
|
|
return tokens.map((token: any) => {
|
|
|
|
|
let e = emotes.filter((emote: any) => emote.title == token);
|
|
|
|
|
let result = [];
|
|
|
|
|
|
|
|
|
|
return e.length > 0 ? e[0] : linkifyString(token);
|
|
|
|
|
});
|
|
|
|
|
for (let token of linkify.tokenize(message)) {
|
|
|
|
|
if (token.isLink) {
|
|
|
|
|
result.push(options.resolve(token));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let part of token.toString().split(regexp)) {
|
|
|
|
|
let e = emotes.filter((emote: any) => emote.title == part);
|
|
|
|
|
|
|
|
|
|
if (e.length > 0) {
|
|
|
|
|
result.push(e[0]);
|
|
|
|
|
} else {
|
|
|
|
|
result.push(part);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|