predikt/oracle/web/components/dashboard/dashboard-text-card.tsx
caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

50 lines
1.4 KiB
TypeScript

import { JSONContent } from '@tiptap/core'
import { JSONEmpty } from '../contract/contract-description'
import { Col } from '../layout/col'
import { Content, TextEditor, useTextEditor } from '../widgets/editor'
import { MAX_DESCRIPTION_LENGTH } from 'common/contract'
import { useEffectCheckEquality } from 'web/hooks/use-effect-check-equality'
export const DashboardText = (props: {
content: JSONContent | undefined
editing?: boolean
onSave?: (content: JSONContent) => void
}) => {
const { content, editing, onSave } = props
if (editing) {
return <DashboardTextEditor onSave={onSave} initialContent={content} />
}
if (!content || JSONEmpty(content)) {
return null
}
return (
<Col className="bg-canvas-0 rounded-2xl px-4 py-2 drop-shadow-md xl:px-6 xl:py-4">
<Content content={content} size="lg" />
</Col>
)
}
function DashboardTextEditor(props: {
onSave?: (content: JSONContent) => void
initialContent?: JSONContent
}) {
const { onSave, initialContent } = props
const editor = useTextEditor({
size: 'lg',
max: MAX_DESCRIPTION_LENGTH,
placeholder: 'Write something, or add an image, tweet, or video.',
defaultValue: initialContent,
})
const editorContent = editor?.getJSON()
useEffectCheckEquality(() => {
if (editorContent) onSave?.(editorContent)
}, [editorContent])
return <TextEditor editor={editor} className="border-none drop-shadow-md" />
}