mirror of https://github.com/msgbyte/tailchat
refactor: add messageTextDecorators
parent
c3bc5fb729
commit
60495359a7
@ -1,8 +1,19 @@
|
||||
import React from 'react';
|
||||
import { regMessageRender } from '@capital/common';
|
||||
import { regMessageRender, regMessageTextDecorators } from '@capital/common';
|
||||
import { BBCode } from './bbcode';
|
||||
import './tags/__all__';
|
||||
|
||||
regMessageRender((message) => {
|
||||
return <BBCode plainText={message} />;
|
||||
});
|
||||
|
||||
regMessageTextDecorators(() => ({
|
||||
url: (plain) => `[url]${plain}[/url]`,
|
||||
image: (plain, attrs) => {
|
||||
if (attrs.height && attrs.width) {
|
||||
return `[img height=${attrs.height} width=${attrs.width}]${plain}[/img]`;
|
||||
}
|
||||
|
||||
return `[img]${plain}[/img]`;
|
||||
},
|
||||
}));
|
||||
|
Loading…
Reference in New Issue