mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed comment text splitting
This commit is contained in:
parent
0666237586
commit
d786606924
2 changed files with 7 additions and 10 deletions
5
.env
5
.env
|
@ -1,5 +0,0 @@
|
|||
#API_HOST = http://localhost:7777/
|
||||
#REMOTE_CURRENT = http://localhost:7777/static/
|
||||
REACT_APP_API_HOST = https://pig.staging.vault48.org/
|
||||
REACT_APP_REMOTE_CURRENT = https://pig.staging.vault48.org/static/
|
||||
EXPOSE = 4000
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue