mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
33 lines
817 B
TypeScript
33 lines
817 B
TypeScript
import { CommentTextBlock } from '~/components/comment/CommentTextBlock';
|
|
|
|
export const COMMENT_BLOCK_TYPES = {
|
|
TEXT: 'TEXT',
|
|
MARK: 'MARK',
|
|
EMBED: 'EMBED',
|
|
};
|
|
|
|
export const COMMENT_BLOCK_DETECTORS = [
|
|
{
|
|
type: COMMENT_BLOCK_TYPES.EMBED,
|
|
test: /(https?:\/\/(www\.)?(youtube\.com|youtu\.be)\/(watch)?(\?v=)?[\w\-]+)/gim,
|
|
},
|
|
{
|
|
type: COMMENT_BLOCK_TYPES.MARK,
|
|
test: /^[\n\s]{0,}?<\.{3}>[\n\s]{0,}$/gi,
|
|
},
|
|
{
|
|
type: COMMENT_BLOCK_TYPES.TEXT,
|
|
test: /^.*$/gi,
|
|
},
|
|
];
|
|
|
|
export type ICommentBlock = {
|
|
type: typeof COMMENT_BLOCK_TYPES[keyof typeof COMMENT_BLOCK_TYPES];
|
|
content: string;
|
|
};
|
|
|
|
export const COMMENT_BLOCK_RENDERERS = {
|
|
[COMMENT_BLOCK_TYPES.TEXT]: CommentTextBlock,
|
|
[COMMENT_BLOCK_TYPES.MARK]: CommentTextBlock,
|
|
[COMMENT_BLOCK_TYPES.EMBED]: CommentTextBlock,
|
|
};
|