From f471fb3bd1caf513d852efb70055d6f9540431a0 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 1 Nov 2023 15:51:46 +0800 Subject: [PATCH] feat: add no highlight component. (#586) --- core/README.md | 28 ++ core/nohighlight.d.ts | 13 + core/package.json | 14 + core/src/Context.tsx | 2 +- core/src/Editor.nohighlight.tsx | 264 ++++++++++++++++++ core/src/Editor.tsx | 156 +---------- core/src/Types.ts | 151 ++++++++++ core/src/components/DragBar/index.tsx | 2 +- core/src/components/TextArea/Markdown.tsx | 4 +- core/src/components/TextArea/Textarea.tsx | 2 +- .../components/TextArea/index.nohighlight.tsx | 109 ++++++++ core/src/components/TextArea/index.tsx | 2 +- core/src/components/Toolbar/Child.tsx | 2 +- core/src/components/Toolbar/index.tsx | 2 +- core/src/index.nohighlight.tsx | 16 ++ core/src/index.tsx | 2 + 16 files changed, 610 insertions(+), 159 deletions(-) create mode 100644 core/nohighlight.d.ts create mode 100644 core/src/Editor.nohighlight.tsx create mode 100644 core/src/Types.ts create mode 100644 core/src/components/TextArea/index.nohighlight.tsx create mode 100644 core/src/index.nohighlight.tsx diff --git a/core/README.md b/core/README.md index 54d628aa6..95f3ef3ad 100644 --- a/core/README.md +++ b/core/README.md @@ -137,6 +137,34 @@ export default function App() { } ``` +### Remove Code Highlight + +The following example can help you _exclude code highlighting code_ from being included in the bundle. `@uiw/react-md-editor/nohighlight` component does not contain the ~~`rehype-prism-plus`~~ code highlighting package, ~~`highlightEnable`~~, ~~`showLineNumbers`~~ and ~~`highlight line`~~ functions will no longer work. ([#586](https://github.com/uiwjs/react-md-editor/issues/586)) + +```jsx mdx:preview +import React from "react"; +import MDEditor from '@uiw/react-md-editor/nohighlight'; + +const code = `**Hello world!!!** +\`\`\`js +function demo() {} +\`\`\` +` + +export default function App() { + const [value, setValue] = React.useState(code); + return ( +