11import { FC , useMemo } from 'react'
22// TODO: Maybe can custom
33import 'highlight.js/styles/zenburn.css'
4- import { useEditorTheme } from 'components/editor/theme'
5- import classNames from 'classnames'
6- import useI18n from 'libs/web/hooks/use-i18n'
74import UIState from 'libs/web/state/ui'
85import InnerHTML from 'dangerously-set-html-content'
96import { NoteModel } from 'libs/shared/note'
107import pupa from 'pupa'
8+ import MainEditor from 'components/editor/main-editor'
9+
10+ const MAX_WIDTH = 900
1111
1212export const PostContainer : FC < {
13- post ?: string
1413 small ?: boolean
1514 note ?: NoteModel
16- } > = ( { post = '' , small = false , note } ) => {
17- const { t } = useI18n ( )
18- const editorTheme = useEditorTheme ( )
15+ } > = ( { small = false , note } ) => {
1916 const {
2017 settings : {
2118 settings : { injection } ,
@@ -29,134 +26,22 @@ export const PostContainer: FC<{
2926 } )
3027 } , [ injection , note ] )
3128
32- const articleClassName = useMemo (
33- ( ) =>
34- classNames ( 'prose mx-auto pb-10 prose-sm px-4 md:px-0' , {
35- 'md:prose-2xl' : ! small ,
36- } ) ,
37- [ small ]
38- )
29+ const className = 'pt-10 px-6 m-auto max-w-full w-[900px]'
3930
4031 return (
4132 < >
42- < article className = { articleClassName } >
43- < header >
44- < h1 className = "pt-10" > { note ?. title ?? t ( 'Untitled' ) } </ h1 >
45- </ header >
46- < main
47- dangerouslySetInnerHTML = { {
48- __html : post ,
49- } }
50- > </ main >
51- < style jsx > { `
52- .prose :glboal(img) {
53- margin: auto;
54- }
55-
56- .prose :glboal([title='left-50']) {
57- float: left;
58- width: 50%;
59- margin-right: 2em;
60- margin-bottom: 1em;
61- clear: initial;
62- }
63-
64- .prose :glboal([title='right-50']) {
65- float: right;
66- width: 50%;
67- margin-left: 2em;
68- margin-bottom: 1em;
69- clear: initial;
70- }
71-
72- .prose :glboal(figcaption) {
73- text-align: center;
74- }
75-
76- .prose :global(.task-list-item) {
77- padding-left: 0;
78- }
79-
80- .prose :global(.task-list-item::before) {
81- content: none;
82- }
83-
84- .prose :global(.task-list-item label) {
85- margin-left: 6px;
86- }
87-
88- .prose :global(.notice) {
89- display: flex;
90- align-items: center;
91- background: ${ editorTheme . noticeInfoBackground } ;
92- color: ${ editorTheme . noticeInfoText } ;
93- border-radius: 4px;
94- padding: 8px 16px;
95- margin: 8px 0;
96- }
97-
98- .prose :global(.notice *) {
99- margin: 0;
100- color: currentColor;
101- }
102-
103- .prose :global(.notice .icon) {
104- width: 1.5em;
105- height: 1.5em;
106- align-self: flex-start;
107- margin-right: 4px;
108- position: relative;
109- top: 1px;
110- }
111-
112- .prose :global(.notice svg) {
113- width: 100%;
114- height: 100%;
115- }
116-
117- .prose :global(.notice .content) {
118- flex-grow: 1;
119- }
120-
121- .prose :global(.notice a) {
122- color: ${ editorTheme . noticeInfoText } ;
123- }
124- .prose :global(.notice a:not(.heading-name)) {
125- text-decoration: underline;
126- }
127-
128- .prose :global(.notice-tip) {
129- background: ${ editorTheme . noticeTipBackground } ;
130- color: ${ editorTheme . noticeTipText } ;
131- }
132-
133- .prose :global(.notice-tip a) {
134- color: ${ editorTheme . noticeTipText } ;
135- }
136- .prose :global(.notice-warning) {
137- background: ${ editorTheme . noticeWarningBackground } ;
138- color: ${ editorTheme . noticeWarningText } ;
139- }
140-
141- .prose: global(.notice-warning a) {
142- color: ${ editorTheme . noticeWarningText } ;
143- }
144-
145- .prose :global(table *) {
146- margin: 0;
147- }
148- ` } </ style >
149- </ article >
33+ < MainEditor small = { small } note = { note } className = { className } readOnly />
15034 { small ? null : (
15135 < >
15236 { injection ? (
15337 < InnerHTML
15438 id = "snippet-injection"
155- className = { articleClassName }
39+ className = { className }
40+ style = { { width : MAX_WIDTH } }
15641 html = { injectionHTML }
15742 />
15843 ) : null }
159- < footer className = "text-gray-300 text-center my-20 text-sm" >
44+ < footer className = "pb-10 text-gray-300 text-center my-20 text-sm" >
16045 Built with{ ' ' }
16146 < a
16247 href = "https://cinwell.com/notea/"
0 commit comments