From 0dc781559981090ae298e233bf53c25540582092 Mon Sep 17 00:00:00 2001 From: dongfang <1136005348@qq.com> Date: Fri, 6 Jan 2023 12:36:43 +0800 Subject: [PATCH] fix: missing css code in demo code preview (#39471) * fix: missing demo style in windows * fix: missing css code in demo preview * fix: change TabPane to tabs items * fix: change cn why-open url --- .../theme/builtins/Previewer/fromDumiProps.tsx | 3 +-- .dumi/theme/common/CodePreview.tsx | 18 +++++++++--------- .dumi/theme/plugin.ts | 2 +- components/dropdown/index.zh-CN.md | 4 ++-- components/tooltip/index.zh-CN.md | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.dumi/theme/builtins/Previewer/fromDumiProps.tsx b/.dumi/theme/builtins/Previewer/fromDumiProps.tsx index e0eb1151b612..0a5de19a3e85 100644 --- a/.dumi/theme/builtins/Previewer/fromDumiProps.tsx +++ b/.dumi/theme/builtins/Previewer/fromDumiProps.tsx @@ -86,8 +86,7 @@ export default function fromDumiProps

( location, src: demoUrl, expand, - // FIXME: confirm is there has any case? - highlightedStyle: '', + highlightedStyle: meta.style ? Prism.highlight(meta.style, Prism.languages.css, 'css') : '', } as P; return ; diff --git a/.dumi/theme/common/CodePreview.tsx b/.dumi/theme/common/CodePreview.tsx index 1f399a122163..492b05849788 100644 --- a/.dumi/theme/common/CodePreview.tsx +++ b/.dumi/theme/common/CodePreview.tsx @@ -1,8 +1,6 @@ import React from 'react'; import { Tabs } from 'antd'; -const { TabPane } = Tabs; - const LANGS = { tsx: 'TypeScript', jsx: 'JavaScript', @@ -23,13 +21,15 @@ const CodePreview: React.FC = ({ toReactComponent, codes, onCo content = toReactComponent(['pre', { lang: langList[0], highlighted: codes[langList[0]] }]); } else { content = ( - - {langList.map((lang) => ( - - {toReactComponent(['pre', { lang, highlighted: codes[lang] }])} - - ))} - + ({ + label: LANGS[lang], + key: lang, + children: toReactComponent(['pre', { lang, highlighted: codes[lang] }]), + }))} + /> ); } diff --git a/.dumi/theme/plugin.ts b/.dumi/theme/plugin.ts index baf0b3dc44f8..c095f2625cd5 100644 --- a/.dumi/theme/plugin.ts +++ b/.dumi/theme/plugin.ts @@ -26,7 +26,7 @@ class AntdReactTechStack extends ReactTechStack { const description = md.match( new RegExp(`(?:^|\\n)## ${locale}([^]+?)(\\n## [a-z]|\\n\`\`\`|\\n