From 027373993e0111c8157e61612ccc2d2792df5f8f Mon Sep 17 00:00:00 2001 From: liqingwei Date: Sat, 3 Jul 2021 16:27:42 +0800 Subject: [PATCH 1/4] refactor: use the editor to render the sharing page --- components/container/post-container.tsx | 133 +---------- components/editor/edit-title.tsx | 4 +- components/editor/editor.tsx | 7 +- components/editor/main-editor.tsx | 15 +- libs/web/state/editor.ts | 2 +- pages/[id].tsx | 3 +- pages/api/file/[...file].ts | 20 +- pages/share/[id].tsx | 6 +- tailwind.config.js | 3 +- yarn.lock | 305 +++++++++++++++++++----- 10 files changed, 277 insertions(+), 221 deletions(-) diff --git a/components/container/post-container.tsx b/components/container/post-container.tsx index 34983c7e2..0828cd3db 100644 --- a/components/container/post-container.tsx +++ b/components/container/post-container.tsx @@ -1,21 +1,18 @@ import { FC, useMemo } from 'react' // TODO: Maybe can custom import 'highlight.js/styles/zenburn.css' -import { useEditorTheme } from 'components/editor/theme' -import classNames from 'classnames' -import useI18n from 'libs/web/hooks/use-i18n' import UIState from 'libs/web/state/ui' import InnerHTML from 'dangerously-set-html-content' import { NoteModel } from 'libs/shared/note' import pupa from 'pupa' +import MainEditor from 'components/editor/main-editor' + +const MAX_WIDTH = 900 export const PostContainer: FC<{ - post?: string small?: boolean note?: NoteModel -}> = ({ post = '', small = false, note }) => { - const { t } = useI18n() - const editorTheme = useEditorTheme() +}> = ({ small = false, note }) => { const { settings: { settings: { injection }, @@ -29,134 +26,22 @@ export const PostContainer: FC<{ }) }, [injection, note]) - const articleClassName = useMemo( - () => - classNames('prose mx-auto pb-10 prose-sm px-4 md:px-0', { - 'md:prose-2xl': !small, - }), - [small] - ) + const className = 'pt-10 px-6 m-auto max-w-full w-[900px]' return ( <> -
-
-

{note?.title ?? t('Untitled')}

-
-
- -
+ {small ? null : ( <> {injection ? ( ) : null} -