From 41e61bcdae7ee84aa0d92f1fc14e8c15d389140d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Sun, 29 Dec 2024 00:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Create/components/Editor/index.tsx | 10 +--------- src/pages/Create/components/Editor/plugins.tsx | 18 ++++++++---------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/pages/Create/components/Editor/index.tsx b/src/pages/Create/components/Editor/index.tsx index 14167cb..57bed86 100644 --- a/src/pages/Create/components/Editor/index.tsx +++ b/src/pages/Create/components/Editor/index.tsx @@ -6,9 +6,7 @@ import { baseURL } from '@/utils/request'; import { useUserStore } from '@/stores'; import { Editor } from '@bytemd/react'; -import gfm from '@bytemd/plugin-gfm' -import gemoji from '@bytemd/plugin-gemoji' -import highlight from '@bytemd/plugin-highlight'; +import plugins from './plugins'; import 'highlight.js/styles/vs2015.css'; import 'bytemd/dist/index.css'; import zh from 'bytemd/lib/locales/zh_Hans.json'; @@ -20,12 +18,6 @@ interface Props { onChange: (value: string) => void; } -const plugins = [ - gfm(), - gemoji(), - highlight() -]; - const EditorMD = ({ value, onChange }: Props) => { const store = useUserStore(); const [loading, setLoading] = useState(false) diff --git a/src/pages/Create/components/Editor/plugins.tsx b/src/pages/Create/components/Editor/plugins.tsx index b909819..84af135 100644 --- a/src/pages/Create/components/Editor/plugins.tsx +++ b/src/pages/Create/components/Editor/plugins.tsx @@ -22,7 +22,7 @@ const markers = (): BytemdPlugin => { remark: (processor) => processor.use(remarkFlexibleMarkers), actions: [ { - title: 'markers', + title: '标记', icon: markerSvg, handler: { type: 'action', @@ -50,13 +50,13 @@ const callouts = (): BytemdPlugin => { icon: calloutSvg, handler: { type: 'dropdown', - actions: calloutTypes.map(type => ({ - title: type.title, - icon: type.icon, + actions: calloutTypes.map(({ title, icon, blockType }) => ({ + title, + icon, handler: { type: 'action', click: (ctx) => { - ctx.appendBlock(`> ${type.blockType} ${type.title}\n> `); + ctx.appendBlock(`> ${blockType} ${title}\n> `); } } })) @@ -66,13 +66,11 @@ const callouts = (): BytemdPlugin => { } } -const plugins = [ +export default [ gfm({ singleTilde: false }), - markers(), + // markers(), gemoji(), math(), highlight(), callouts() -] - -export default plugins; \ No newline at end of file +]; \ No newline at end of file