From 971de9a50fcda344529671ffc6e487eb9a3d46d3 Mon Sep 17 00:00:00 2001 From: mereith Date: Wed, 22 Mar 2023 11:28:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20markdown=20=E5=9B=BE=E7=89=87=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E4=B8=AD=E6=94=AF=E6=8C=81=20dataURL=20=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/admin/src/components/Editor/index.tsx | 7 ++++++- packages/website/components/Markdown/index.tsx | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/admin/src/components/Editor/index.tsx b/packages/admin/src/components/Editor/index.tsx index f8261675f..59335e344 100644 --- a/packages/admin/src/components/Editor/index.tsx +++ b/packages/admin/src/components/Editor/index.tsx @@ -27,6 +27,11 @@ import { Heading } from './plugins/heading'; import { customCodeBlock } from './plugins/codeBlock'; import { LinkTarget } from './plugins/linkTarget'; +const sanitize = (schema) => { + schema.protocols.src.push('data') + return schema +} + export default function EditorComponent(props: { value: string; onChange: (string: string) => void; @@ -65,7 +70,7 @@ export default function EditorComponent(props: { plugins={plugins} onChange={props.onChange} locale={cn} - + sanitize={sanitize} uploadImages={async (files: File[]) => { setLoading(true); const res = []; diff --git a/packages/website/components/Markdown/index.tsx b/packages/website/components/Markdown/index.tsx index cce347d61..b29473852 100644 --- a/packages/website/components/Markdown/index.tsx +++ b/packages/website/components/Markdown/index.tsx @@ -22,9 +22,12 @@ const plugins = [ LinkTarget(), Heading(), ] - +const sanitize = (schema) => { + schema.protocols.src.push('data') + return schema +} export default function ({ content }: { content: string }) { return
- +
}