1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed comment text splitting

This commit is contained in:
Fedor Katurov 2021-02-24 14:36:15 +07:00
parent 0666237586
commit d786606924
2 changed files with 7 additions and 10 deletions

View file

@ -94,8 +94,8 @@ export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof
};
export const formatText = pipe(
formatTextSanitizeYoutube,
formatTextSanitizeTags,
formatTextSanitizeYoutube,
formatTextClickableUsernames,
formatTextComments,
formatTextTodos,
@ -112,10 +112,12 @@ export const findBlockType = (line: string): ValueOf<typeof COMMENT_BLOCK_TYPES>
};
export const splitCommentByBlocks = (text: string): ICommentBlock[] =>
text.split('\n').map(line => ({
type: findBlockType(line),
content: line,
}));
text
.split(/(https?:\/\/(?:www\.)(?:youtube\.com|youtu\.be)\/(?:watch)(?:\?v=)[\w\-\&\=]+)/)
.map(line => ({
type: findBlockType(line),
content: line,
}));
export const formatCommentText = (author: string, text: string): ICommentBlock[] =>
text ? splitCommentByBlocks(formatText(text)) : null;