generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
component.tsx
77 lines (63 loc) · 2.04 KB
/
component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// eslint-disable-next-line simple-import-sort/imports
import dynamic from 'next/dynamic';
import { textJoin } from 'mobx-i18n';
import { observer } from 'mobx-react';
import Head from 'next/head';
import { compose, translator } from 'next-ssr-middleware';
import { FC, PropsWithChildren } from 'react';
import { Container } from 'react-bootstrap';
import { CodeBlock, EditorHTML } from 'idea-react';
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-jsx';
import 'prismjs/components/prism-typescript';
import 'prismjs/components/prism-tsx';
import { PageHead } from '../components/PageHead';
import { i18n } from '../models/Translation';
import RichEditData from './api/rich-edit.json';
const HTMLEditor = dynamic(() => import('../components/HTMLEditor'), {
ssr: false,
});
HTMLEditor.displayName = 'HTMLEditor';
const BlockEditor = dynamic(() => import('../components/BlockEditor'), {
ssr: false,
});
BlockEditor.displayName = 'BlockEditor';
const Example: FC<PropsWithChildren<{ title: string }>> = ({
title,
children,
}) => (
<>
<h2 className="mt-3">{title}</h2>
{children}
<CodeBlock language="tsx">{children}</CodeBlock>
</>
);
export const getServerSideProps = compose(translator(i18n));
const ComponentPage = observer(() => {
const { t } = i18n;
const title = textJoin(t('component'), t('examples'));
return (
<>
<Head>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/themes/prism.min.css"
/>
</Head>
<PageHead title={title} />
<Container>
<h1 className="my-4 text-center">{title}</h1>
<Example title="HTML Editor">
<HTMLEditor defaultValue="Hello, HTML!" onChange={console.log} />
</Example>
<Example title="Block Editor">
<BlockEditor name="content" defaultValue={RichEditData} />
</Example>
<Example title="Block Editor to HTML">
<EditorHTML data={RichEditData} />
</Example>
</Container>
</>
);
});
export default ComponentPage;