From eefceb13e1b5b9a3096c73cc230d785d8499a2df Mon Sep 17 00:00:00 2001 From: "cinwell.li" Date: Sat, 3 Jul 2021 17:02:51 +0800 Subject: [PATCH] refactor: use the editor to render the sharing page (#82) --- components/container/post-container.tsx | 133 +-------- components/editor/edit-title.tsx | 4 +- components/editor/editor.tsx | 7 +- components/editor/main-editor.tsx | 27 +- components/portal/preview-modal.tsx | 16 +- libs/server/connect.ts | 1 - libs/server/middlewares/post.ts | 19 -- libs/shared/markdown/notice-plugin.tsx | 35 --- libs/shared/markdown/render.tsx | 49 --- libs/web/state/editor.ts | 7 +- package.json | 6 - pages/[id].tsx | 5 +- pages/api/file/[...file].ts | 20 +- pages/share/[id].tsx | 6 +- tailwind.config.js | 3 +- yarn.lock | 380 +++++++++++++++--------- 16 files changed, 295 insertions(+), 423 deletions(-) delete mode 100644 libs/server/middlewares/post.ts delete mode 100644 libs/shared/markdown/notice-plugin.tsx delete mode 100644 libs/shared/markdown/render.tsx diff --git a/components/container/post-container.tsx b/components/container/post-container.tsx index 34983c7e2..38c178c1e 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} -