|
|
@ -3,7 +3,7 @@ import {
|
|
|
|
PipeTransform
|
|
|
|
PipeTransform
|
|
|
|
} from '@angular/core';
|
|
|
|
} from '@angular/core';
|
|
|
|
|
|
|
|
|
|
|
|
import * as linkifyString from 'linkifyjs/string';
|
|
|
|
import * as linkify from 'linkifyjs';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Pipe({
|
|
|
|
@Pipe({
|
|
|
@ -22,13 +22,27 @@ export class SplitMessagePipe implements PipeTransform {
|
|
|
|
|
|
|
|
|
|
|
|
let regexp = RegExp('(' + exps.join('|') + ')');
|
|
|
|
let regexp = RegExp('(' + exps.join('|') + ')');
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: do not split URLs
|
|
|
|
let options = new linkify.options.Options();
|
|
|
|
let tokens = message.split(regexp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tokens.map((token: any) => {
|
|
|
|
let result = [];
|
|
|
|
let e = emotes.filter((emote: any) => emote.title == token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|