2020-10-16 09:02:12 +02:00
|
|
|
import { MessageText } from '../../shared/message/text.js';
|
2021-03-24 09:59:26 +01:00
|
|
|
import { directive, html } from 'lit-html';
|
2020-10-16 09:02:12 +02:00
|
|
|
import { until } from 'lit-html/directives/until.js';
|
|
|
|
|
|
|
|
async function transform (t) {
|
|
|
|
await t.addTemplates();
|
|
|
|
return t.payload;
|
|
|
|
}
|
|
|
|
|
2021-03-24 09:59:26 +01:00
|
|
|
function renderer (text, offset, mentions, options) {
|
|
|
|
const t = new MessageText(text, offset, mentions, Object.assign(options, { 'show_images': false }));
|
2020-10-16 09:02:12 +02:00
|
|
|
return html`${until(transform(t), html`${t}`)}`;
|
|
|
|
}
|
|
|
|
|
2021-03-24 09:59:26 +01:00
|
|
|
export const renderStylingDirectiveBody = directive((txt, offset, mentions, options) =>
|
|
|
|
p => p.setValue(renderer(txt, offset, mentions, options))
|
|
|
|
);
|