|
1 | 1 | import { Block, DocumentBlockModel, renderBlocks, WikiNode } from 'mobx-lark'; |
| 2 | +import { observer } from 'mobx-react'; |
2 | 3 | import { GetServerSideProps } from 'next'; |
3 | | -import { FC } from 'react'; |
| 4 | +import { FC, useContext } from 'react'; |
4 | 5 | import { Container } from 'react-bootstrap'; |
5 | 6 |
|
6 | 7 | import { GitDiffView } from '../../../components/GitDiffView'; |
7 | 8 | import { PageHead } from '../../../components/Layout/PageHead'; |
8 | 9 | import documentStore from '../../../models/Document'; |
| 10 | +import { I18nContext } from '../../../models/Translation'; |
9 | 11 | import wikiStore from '../../../models/Wiki'; |
10 | 12 | import { lark } from '../../api/Lark/core'; |
11 | 13 |
|
@@ -38,43 +40,43 @@ interface WikiDocumentDebuggerPageProps { |
38 | 40 | renderableBlocks: Block<any, any, any>[]; |
39 | 41 | } |
40 | 42 |
|
41 | | -const WikiDocumentDebuggerPage: FC<WikiDocumentDebuggerPageProps> = ({ |
42 | | - node, |
43 | | - rawBlocks, |
44 | | - renderableBlocks, |
45 | | -}) => { |
46 | | - const title = `${node.title} - Debugger`; |
47 | | - const rendered = renderBlocks(renderableBlocks); |
48 | | - |
49 | | - return ( |
50 | | - <Container> |
51 | | - <PageHead title={title} /> |
52 | | - <h1>{title}</h1> |
53 | | - |
54 | | - <section> |
55 | | - <h2>🔍Block diff</h2> |
56 | | - |
57 | | - <GitDiffView |
58 | | - oldFile={{ |
59 | | - fileName: 'raw-blocks.json', |
60 | | - content: JSON.stringify(rawBlocks, null, 2), |
61 | | - language: 'json', |
62 | | - }} |
63 | | - newFile={{ |
64 | | - fileName: 'renderable-blocks.json', |
65 | | - content: JSON.stringify(renderableBlocks, null, 2), |
66 | | - language: 'json', |
67 | | - }} |
68 | | - /> |
69 | | - </section> |
70 | | - |
71 | | - <section> |
72 | | - <h2>📄Document</h2> |
73 | | - |
74 | | - {rendered} |
75 | | - </section> |
76 | | - </Container> |
77 | | - ); |
78 | | -}; |
| 43 | +const WikiDocumentDebuggerPage: FC<WikiDocumentDebuggerPageProps> = observer( |
| 44 | + ({ node, rawBlocks, renderableBlocks }) => { |
| 45 | + const { t } = useContext(I18nContext); |
| 46 | + |
| 47 | + const title = `${node.title} - ${t('debugger')}`; |
| 48 | + const rendered = renderBlocks(renderableBlocks); |
| 49 | + |
| 50 | + return ( |
| 51 | + <Container> |
| 52 | + <PageHead title={title} /> |
| 53 | + <h1>{title}</h1> |
| 54 | + |
| 55 | + <section> |
| 56 | + <h2>🔍{t('block_diff')}</h2> |
| 57 | + |
| 58 | + <GitDiffView |
| 59 | + oldFile={{ |
| 60 | + fileName: 'raw-blocks.json', |
| 61 | + content: JSON.stringify(rawBlocks, null, 2), |
| 62 | + language: 'json', |
| 63 | + }} |
| 64 | + newFile={{ |
| 65 | + fileName: 'renderable-blocks.json', |
| 66 | + content: JSON.stringify(renderableBlocks, null, 2), |
| 67 | + language: 'json', |
| 68 | + }} |
| 69 | + /> |
| 70 | + </section> |
| 71 | + |
| 72 | + <section> |
| 73 | + <h2>📄{t('document')}</h2> |
| 74 | + |
| 75 | + {rendered} |
| 76 | + </section> |
| 77 | + </Container> |
| 78 | + ); |
| 79 | + }, |
| 80 | +); |
79 | 81 |
|
80 | 82 | export default WikiDocumentDebuggerPage; |
0 commit comments