More random cleanup
This commit is contained in:
parent
01880160dc
commit
183f5a050d
|
@ -236,9 +236,10 @@ const useUploadMutation = (editor: Editor | null) =>
|
||||||
|
|
||||||
export function RichContent(props: {
|
export function RichContent(props: {
|
||||||
content: JSONContent | string
|
content: JSONContent | string
|
||||||
|
className?: string
|
||||||
smallImage?: boolean
|
smallImage?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { content, smallImage } = props
|
const { className, content, smallImage } = props
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
editorProps: { attributes: { class: proseClass } },
|
editorProps: { attributes: { class: proseClass } },
|
||||||
extensions: [
|
extensions: [
|
||||||
|
@ -254,19 +255,24 @@ export function RichContent(props: {
|
||||||
})
|
})
|
||||||
useEffect(() => void editor?.commands?.setContent(content), [editor, content])
|
useEffect(() => void editor?.commands?.setContent(content), [editor, content])
|
||||||
|
|
||||||
return <EditorContent editor={editor} />
|
return <EditorContent className={className} editor={editor} />
|
||||||
}
|
}
|
||||||
|
|
||||||
// backwards compatibility: we used to store content as strings
|
// backwards compatibility: we used to store content as strings
|
||||||
export function Content(props: {
|
export function Content(props: {
|
||||||
content: JSONContent | string
|
content: JSONContent | string
|
||||||
|
className?: string
|
||||||
smallImage?: boolean
|
smallImage?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { content } = props
|
const { className, content } = props
|
||||||
return typeof content === 'string' ? (
|
return typeof content === 'string' ? (
|
||||||
<div className="whitespace-pre-line font-light leading-relaxed">
|
<Linkify
|
||||||
<Linkify text={content} />
|
className={clsx(
|
||||||
</div>
|
className,
|
||||||
|
'whitespace-pre-line font-light leading-relaxed'
|
||||||
|
)}
|
||||||
|
text={content}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<RichContent {...props} />
|
<RichContent {...props} />
|
||||||
)
|
)
|
||||||
|
|
|
@ -137,7 +137,7 @@ export function FreeResponseContractCommentsActivity(props: {
|
||||||
contract={contract}
|
contract={contract}
|
||||||
user={user}
|
user={user}
|
||||||
answer={answer}
|
answer={answer}
|
||||||
answerComments={commentsByOutcome[answer.number.toString()]}
|
answerComments={commentsByOutcome[answer.number.toString()] ?? []}
|
||||||
tips={tips}
|
tips={tips}
|
||||||
betsByUserId={betsByUserId}
|
betsByUserId={betsByUserId}
|
||||||
commentsByUserId={commentsByUserId}
|
commentsByUserId={commentsByUserId}
|
||||||
|
|
|
@ -193,7 +193,6 @@ export function FeedComment(props: {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<>
|
|
||||||
{bought} {money}
|
{bought} {money}
|
||||||
{contract.outcomeType !== 'FREE_RESPONSE' && betOutcome && (
|
{contract.outcomeType !== 'FREE_RESPONSE' && betOutcome && (
|
||||||
<>
|
<>
|
||||||
|
@ -207,7 +206,6 @@ export function FeedComment(props: {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
|
||||||
<CopyLinkDateTimeComponent
|
<CopyLinkDateTimeComponent
|
||||||
prefix={contract.creatorUsername}
|
prefix={contract.creatorUsername}
|
||||||
slug={contract.slug}
|
slug={contract.slug}
|
||||||
|
@ -215,9 +213,11 @@ export function FeedComment(props: {
|
||||||
elementId={comment.id}
|
elementId={comment.id}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-2 text-[15px] text-gray-700">
|
<Content
|
||||||
<Content content={content || text} smallImage />
|
className="mt-2 text-[15px] text-gray-700"
|
||||||
</div>
|
content={content || text}
|
||||||
|
smallImage
|
||||||
|
/>
|
||||||
<Row className="mt-2 items-center gap-6 text-xs text-gray-500">
|
<Row className="mt-2 items-center gap-6 text-xs text-gray-500">
|
||||||
<Tipper comment={comment} tips={tips ?? {}} />
|
<Tipper comment={comment} tips={tips ?? {}} />
|
||||||
{onReplyClick && (
|
{onReplyClick && (
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
|
import clsx from 'clsx'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
import { SiteLink } from './site-link'
|
import { SiteLink } from './site-link'
|
||||||
|
|
||||||
// Return a JSX span, linkifying @username, #hashtags, and https://...
|
// Return a JSX span, linkifying @username, #hashtags, and https://...
|
||||||
// TODO: Use a markdown parser instead of rolling our own here.
|
// TODO: Use a markdown parser instead of rolling our own here.
|
||||||
export function Linkify(props: { text: string; gray?: boolean }) {
|
export function Linkify(props: {
|
||||||
const { text, gray } = props
|
text: string
|
||||||
|
className?: string
|
||||||
|
gray?: boolean
|
||||||
|
}) {
|
||||||
|
const { text, className, gray } = props
|
||||||
// Replace "m1234" with "ϻ1234"
|
// Replace "m1234" with "ϻ1234"
|
||||||
// const mRegex = /(\W|^)m(\d+)/g
|
// const mRegex = /(\W|^)m(\d+)/g
|
||||||
// text = text.replace(mRegex, (_, pre, num) => `${pre}ϻ${num}`)
|
// text = text.replace(mRegex, (_, pre, num) => `${pre}ϻ${num}`)
|
||||||
|
@ -38,7 +43,7 @@ export function Linkify(props: { text: string; gray?: boolean }) {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<span className="break-anywhere">
|
<span className={clsx(className, 'break-anywhere')}>
|
||||||
{text.split(regex).map((part, i) => (
|
{text.split(regex).map((part, i) => (
|
||||||
<Fragment key={i}>
|
<Fragment key={i}>
|
||||||
{part}
|
{part}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user