Ignore line breaks in small notes

This commit is contained in:
Bojan Mojsilovic 2023-10-23 15:28:20 +02:00
parent 2c2ed06a23
commit 9bffb0ee67
2 changed files with 6 additions and 3 deletions

View File

@ -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);

View File

@ -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>