mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-09-30 00:41:09 +00:00
Ignore line breaks in small notes
This commit is contained in:
parent
2c2ed06a23
commit
9bffb0ee67
@ -47,6 +47,7 @@ const ParsedNote: Component<{
|
||||
note: PrimalNote,
|
||||
id?: string,
|
||||
ignoreMedia?: boolean,
|
||||
ignoreLinebreaks?: boolean,
|
||||
noLinks?: 'links' | 'text',
|
||||
noPreviews?: boolean,
|
||||
}> = (props) => {
|
||||
@ -57,7 +58,9 @@ const ParsedNote: Component<{
|
||||
const [renderedUrl, setRenderedUrl] = createStore<Record<string, any>>({});
|
||||
|
||||
const parseContent = () => {
|
||||
const content = props.note.post.content.replace(linebreakRegex, ' __LB__ ').replace(/\s+/g, ' __SP__ ');
|
||||
const content = props.ignoreLinebreaks ?
|
||||
props.note.post.content.replace(/\s+/g, ' __SP__ ') :
|
||||
props.note.post.content.replace(linebreakRegex, ' __LB__ ').replace(/\s+/g, ' __SP__ ');
|
||||
const tokens = content.split(/[\s]+/);
|
||||
|
||||
setTokens(() => [...tokens]);
|
||||
@ -81,7 +84,7 @@ const ParsedNote: Component<{
|
||||
|
||||
if (index > 0) {
|
||||
const prefix = token.slice(0, index);
|
||||
|
||||
|
||||
const matched = token.match(urlExtractRegex)[0];
|
||||
if (matched) {
|
||||
const suffix = token.substring(matched.length + index, token.length);
|
||||
|
@ -97,7 +97,7 @@ const SmallNote: Component<{ note: PrimalNote, children?: JSXElement, id?: strin
|
||||
</div>
|
||||
<div class={styles.message}>
|
||||
<div>
|
||||
<ParsedNote note={props.note} noLinks="text" ignoreMedia={true} />
|
||||
<ParsedNote note={props.note} noLinks="text" ignoreMedia={true} ignoreLinebreaks={true} />
|
||||
</div>
|
||||
</div>
|
||||
</A>
|
||||
|
Loading…
Reference in New Issue
Block a user