From d3bf590d01d561cff1aa79bcbd955914e2d64713 Mon Sep 17 00:00:00 2001 From: rdmclin2 Date: Thu, 21 Mar 2024 14:33:05 +0800 Subject: [PATCH 1/3] :arrow_up: chore: upgrade shikiji to shiki --- package.json | 2 +- src/Highlight/hooks/useShiki.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f5f44e6a..f15da566 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "remark-gfm": "^3.0.1", "remark-math": "^5.1.1", "rxjs": "^7.8.1", - "shikiji": "^0.6.13", + "shiki": "^1.2.0", "type-fest": "^3.13.1", "use-merge-value": "^1.2.0", "yjs": "^13.6.11", diff --git a/src/Highlight/hooks/useShiki.tsx b/src/Highlight/hooks/useShiki.tsx index 76143ffc..398655a2 100644 --- a/src/Highlight/hooks/useShiki.tsx +++ b/src/Highlight/hooks/useShiki.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { getHighlighter, type Highlighter } from 'shikiji'; +import { getHighlighter, type Highlighter } from 'shiki/bundle/web'; import { themeConfig } from '../theme'; import { languageMap } from './useHighlight'; From cb0a31d99012b6339b6f4383828a7f207e5c7b06 Mon Sep 17 00:00:00 2001 From: rdmclin2 Date: Thu, 21 Mar 2024 15:19:00 +0800 Subject: [PATCH 2/3] :sparkles: feat: remove highlight.js and use shiki only --- package.json | 1 - .../components/HighLightJS/index.tsx | 65 --------------- src/Highlight/components/HighLightJS/style.ts | 82 ------------------- .../components/HighLighter/index.tsx | 38 +++------ src/Highlight/demos/lineNumber.tsx | 4 - src/Highlight/demos/shiki.tsx | 15 ---- src/Highlight/demos/theme.tsx | 4 - src/Highlight/hooks/useHighlight.tsx | 56 ------------- src/Highlight/hooks/useShiki.tsx | 25 ++++-- src/Highlight/index.en-US.md | 4 +- src/Highlight/index.tsx | 7 +- src/Highlight/index.zh-CN.md | 4 +- src/Snippet/index.tsx | 2 +- 13 files changed, 35 insertions(+), 272 deletions(-) delete mode 100644 src/Highlight/components/HighLightJS/index.tsx delete mode 100644 src/Highlight/components/HighLightJS/style.ts delete mode 100644 src/Highlight/demos/shiki.tsx delete mode 100644 src/Highlight/hooks/useHighlight.tsx diff --git a/package.json b/package.json index f15da566..6c1bb9b6 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,6 @@ "copy-to-clipboard": "^3.3.3", "diff": "^5.1.0", "fast-deep-equal": "^3.1.3", - "highlight.js": "~10.5.0", "immer": "^9.0.21", "lodash.flatten": "^4.4.0", "lodash.get": "^4.4.2", diff --git a/src/Highlight/components/HighLightJS/index.tsx b/src/Highlight/components/HighLightJS/index.tsx deleted file mode 100644 index 22b4dcd4..00000000 --- a/src/Highlight/components/HighLightJS/index.tsx +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 高亮能力基于highlight.js 的语法解析能力 https://highlightjs.org/ - * 听说过的还算有名的语言放在langugaes中了,需要新增语言时在languages文件夹中添加并import使用,加入到 languageMap中 - * 如果没有在 https://github.com/highlightjs/highlight.js/tree/master/src/languages 中查找是否支持,然后添加 - * 优先支持主流语言,没有import在代码中使用的不会打包 - */ -import classNames from 'classnames'; -import { memo, useEffect, useState } from 'react'; -import { useHighlight } from '../../hooks/useHighlight'; -import { HighlightProps } from '../../index'; -import { THEME_LIGHT } from '../../theme'; -import HighlightCell from '../HighlightCell'; -import { useStyles } from './style'; - -export type HighLighJSProps = Pick< - HighlightProps, - 'language' | 'children' | 'theme' | 'lineNumber' ->; - -const HighLighJS: React.FC = memo((props) => { - const { children, lineNumber = false, theme = THEME_LIGHT, language } = props; - const [codeBlock, setCodeBlock] = useState(null); - const { styles } = useStyles(theme); - const { renderHighlight } = useHighlight(language); - - const highlightCode = () => { - // 数据为空即跳过渲染 - if (!children) { - return; - } - - // 构造table展示codeblock - const value = renderHighlight(children); - const sourceData = value.split(/\r?\n/); - // 构造整个list所需要的内容(行号和内容) - const rowList = sourceData.map((rowValue, index) => ({ - value: rowValue, - index: index + 1, - })); - setCodeBlock( - rowList.map((src, index) => { - return ( - - - - ); - }), - ); - }; - - // 触发重新渲染 - useEffect(() => { - highlightCode(); - }, [children, theme, language, lineNumber]); - - return ( -
-      
-        {codeBlock}
-      
-
- ); -}); - -export default HighLighJS; diff --git a/src/Highlight/components/HighLightJS/style.ts b/src/Highlight/components/HighLightJS/style.ts deleted file mode 100644 index 83361018..00000000 --- a/src/Highlight/components/HighLightJS/style.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { createStyles } from '../../../theme'; -import { getThemeColor } from '../../theme/colors'; - -export const useStyles = createStyles(({ css, cx }, theme) => { - const { - colorBlue, - colorGreen, - colorOrange, - colorRed, - colorText, - colorTextSecondary, - colorTextTertiary, - } = getThemeColor(theme === 'dark'); - - return { - theme: cx( - css` - display: block; - overflow-x: auto; - color: ${colorText}; - background-color: ${colorTextSecondary}; - - /* Comment */ - .hljs-comment, - .hljs-quote { - color: ${colorTextTertiary}; - } - - /* Red */ - .hljs-variable, - .hljs-attribute, - .hljs-template-variable, - .hljs-tag, - .hljs-name, - .hljs-selector-id, - .hljs-selector-class, - .hljs-regexp, - .hljs-title, - .hljs-deletion { - color: ${colorRed}; - } - - /* Orange */ - - .hljs-builtin-name, - .hljs-literal, - .hljs-type, - .hljs-params, - .hljs-meta, - .hljs-link { - color: ${colorOrange}; - } - - /* Green */ - .hljs-string, - .hljs-number, - .hljs-symbol, - .hljs-bullet, - .hljs-addition { - color: ${colorGreen}; - } - - /* Blue */ - .hljs-keyword, - .hljs-doctag, - .hljs-built_in, - .hljs-selector-tag, - .hljs-section { - color: ${colorBlue}; - } - - .hljs-emphasis { - font-style: italic; - } - - .hljs-strong { - font-weight: bold; - } - `, - ), - }; -}); diff --git a/src/Highlight/components/HighLighter/index.tsx b/src/Highlight/components/HighLighter/index.tsx index a1d16939..662b6d71 100644 --- a/src/Highlight/components/HighLighter/index.tsx +++ b/src/Highlight/components/HighLighter/index.tsx @@ -7,46 +7,30 @@ import { THEME_LIGHT } from '@/Highlight/theme'; import { Loading3QuartersOutlined as Loading } from '@ant-design/icons'; import classNames from 'classnames'; -import { memo, useMemo } from 'react'; +import { memo } from 'react'; import { Center } from 'react-layout-kit'; import { useShiki } from '../../hooks/useShiki'; import { HighlightProps } from '../../index'; -import HighLightJS from '../HighLightJS'; import { useStyles } from './style'; export type ShikiProps = Pick< HighlightProps, - 'language' | 'children' | 'theme' | 'lineNumber' | 'shiki' | 'className' | 'style' + 'language' | 'children' | 'theme' | 'lineNumber' | 'className' | 'style' >; const HighLighter: React.FC = memo((props) => { - const { children, lineNumber = false, theme = THEME_LIGHT, language, shiki = true } = props; + const { children, lineNumber = false, theme = THEME_LIGHT, language } = props; const { styles } = useStyles({ lineNumber, theme }); - const { renderShiki, loading } = useShiki(language, theme, shiki); + const { renderShiki, loading } = useShiki(language, theme); - const HighlightJSBlock = useMemo( - () => ( - - {children} - - ), - [lineNumber, theme, language, children], - ); - - return shiki === false ? ( - HighlightJSBlock - ) : ( + return ( <> - {loading ? ( - HighlightJSBlock - ) : ( -
- )} +
{loading ? (
diff --git a/src/Highlight/demos/lineNumber.tsx b/src/Highlight/demos/lineNumber.tsx index d3a099c3..eb018142 100644 --- a/src/Highlight/demos/lineNumber.tsx +++ b/src/Highlight/demos/lineNumber.tsx @@ -1,7 +1,3 @@ -/** - - */ - import { Highlight } from '@ant-design/pro-editor'; export default () => ( diff --git a/src/Highlight/demos/shiki.tsx b/src/Highlight/demos/shiki.tsx deleted file mode 100644 index 14bbb93e..00000000 --- a/src/Highlight/demos/shiki.tsx +++ /dev/null @@ -1,15 +0,0 @@ -/** - * - */ - -import { Highlight } from '@ant-design/pro-editor'; - -export default () => ( - - {`public class HelloWorld { - public static void main(String[] args) { - System.out.println("Hello World!"); - } - }`} - -); diff --git a/src/Highlight/demos/theme.tsx b/src/Highlight/demos/theme.tsx index b5946f0d..a8526b2b 100644 --- a/src/Highlight/demos/theme.tsx +++ b/src/Highlight/demos/theme.tsx @@ -1,7 +1,3 @@ -/** - - */ - import { Highlight } from '@ant-design/pro-editor'; import { Select, Space } from 'antd'; import { useState } from 'react'; diff --git a/src/Highlight/hooks/useHighlight.tsx b/src/Highlight/hooks/useHighlight.tsx deleted file mode 100644 index f8c5411f..00000000 --- a/src/Highlight/hooks/useHighlight.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import hljs from 'highlight.js/lib/core'; -import { default as bash, default as sh } from 'highlight.js/lib/languages/bash'; -import css from 'highlight.js/lib/languages/css'; -import java from 'highlight.js/lib/languages/java'; -import { default as javascript, default as jsx } from 'highlight.js/lib/languages/javascript'; -import json from 'highlight.js/lib/languages/json'; -import markdown from 'highlight.js/lib/languages/markdown'; -import python from 'highlight.js/lib/languages/python'; -import sql from 'highlight.js/lib/languages/sql'; -import { default as tsx, default as typescript } from 'highlight.js/lib/languages/typescript'; -import xml from 'highlight.js/lib/languages/xml'; -import yaml from 'highlight.js/lib/languages/yaml'; -import { useEffect } from 'react'; - -// 目前支持的语言列表 -export const languageMap = { - javascript, - typescript, - css, - json, - markdown, - xml, - html: xml, - yaml, - tsx, - jsx, - java, - python, - sql, - bash, - sh, -}; - -export const useHighlight = (language) => { - // 按需加载语言 - useEffect(() => { - if (language && languageMap[language]) { - hljs.registerLanguage(language, languageMap[language]); - } else { - Object.keys(languageMap).forEach((lan) => { - hljs.registerLanguage(lan, languageMap[lan]); - }); - } - }, [language]); - - const renderHighlight = (content) => { - let result = null; - if (language & languageMap[language]) { - result = hljs.highlight(language, content || '').value; - } else { - result = hljs.highlightAuto(content).value; - } - return result; - }; - return { renderHighlight }; -}; diff --git a/src/Highlight/hooks/useShiki.tsx b/src/Highlight/hooks/useShiki.tsx index 398655a2..87a96ca3 100644 --- a/src/Highlight/hooks/useShiki.tsx +++ b/src/Highlight/hooks/useShiki.tsx @@ -1,12 +1,27 @@ import { useEffect, useState } from 'react'; import { getHighlighter, type Highlighter } from 'shiki/bundle/web'; import { themeConfig } from '../theme'; -import { languageMap } from './useHighlight'; // 目前支持的语言列表 -export const HIGHLIGHT_LANGUAGES = Object.keys(languageMap); +export const HIGHLIGHT_LANGUAGES = [ + 'javascript', + 'typescript', + 'css', + 'json', + 'markdown', + 'xml', + 'html', + 'yaml', + 'tsx', + 'jsx', + 'java', + 'python', + 'sql', + 'bash', + 'sh', +]; -export const useShiki = (language, theme, isShiki) => { +export const useShiki = (language, theme) => { const [shiki, setShiki] = useState(null); const initShiki = async () => { @@ -18,8 +33,8 @@ export const useShiki = (language, theme, isShiki) => { }; useEffect(() => { - if (isShiki) initShiki(); - }, [isShiki]); + initShiki(); + }, []); const renderShiki = (content) => { if (shiki && shiki.getLoadedLanguages().includes(language)) { diff --git a/src/Highlight/index.en-US.md b/src/Highlight/index.en-US.md index 0fb43287..68b40d35 100644 --- a/src/Highlight/index.en-US.md +++ b/src/Highlight/index.en-US.md @@ -6,14 +6,12 @@ group: Basic # Highlight -Used to display code, Highlight defaults to using [Shiki](https://github.com/shikijs/shiki) for rendering. Shiki uses a TextMate grammar for more precision, but it requires loading additional wasm files, which may result in a poor experience in case of poor network conditions. If initialization fails, the component will set the renderer to [highlight.js](https://highlightjs.org/) as a replacement. +Used to display code, Highlight defaults to using [Shiki](https://github.com/shikijs/shiki) for rendering. Shiki uses a TextMate grammar for more precision. ## Code Demo - - = memo((props) => { @@ -78,7 +74,6 @@ const BaseHighlight: React.FC = memo((props) => { copyable = true, theme: outTheme = THEME_AUTO, language = 'tsx', - shiki = true, showLanguage = true, type = 'block', onCopy, @@ -103,7 +98,7 @@ const BaseHighlight: React.FC = memo((props) => { {showLanguage && language && ( {language.toLowerCase()} )} - + {children}
diff --git a/src/Highlight/index.zh-CN.md b/src/Highlight/index.zh-CN.md index 616aa375..425768b1 100644 --- a/src/Highlight/index.zh-CN.md +++ b/src/Highlight/index.zh-CN.md @@ -6,14 +6,12 @@ group: 基础组件 # Highlight 代码高亮 -展示代码时使用,Highlight 默认使用 [Shiki](https://github.com/shikijs/shiki) 渲染,Shiki 使用 TextMate 语法器更加精确,不过需要加载额外的 wasm 文件,在网络不好的情况下体验不佳,若初始化失败组件会设定渲染器为 [highlight.js](https://highlightjs.org/) 来替代。 +展示代码时使用,Highlight 使用 [Shiki](https://github.com/shikijs/shiki) 渲染,Shiki 使用 TextMate 语法器更加精确。 ## 代码演示 - - ((props) => {
{spotlight && }
- + {symbol ? [symbol, children].join(' ') : children}
From 6bf177173d181524608fb9218836fbfa3af943ab Mon Sep 17 00:00:00 2001 From: rdmclin2 Date: Thu, 21 Mar 2024 15:24:04 +0800 Subject: [PATCH 3/3] :camera_flash: chore: update snapshot --- tests/__snapshots__/demo.test.tsx.snap | 3849 ++++-------------------- 1 file changed, 645 insertions(+), 3204 deletions(-) diff --git a/tests/__snapshots__/demo.test.tsx.snap b/tests/__snapshots__/demo.test.tsx.snap index 35a31495..76b80899 100644 --- a/tests/__snapshots__/demo.test.tsx.snap +++ b/tests/__snapshots__/demo.test.tsx.snap @@ -10428,69 +10428,12 @@ P .emotion-4:hover { background: rgba(0, 0, 0, 0.15); } -.emotion-5 { - display: block; - overflow-x: auto; - color: #333333; - background-color: #666666; -} - -.emotion-5 .hljs-comment, -.emotion-5 .hljs-quote { - color: #aaaaaa; -} - -.emotion-5 .hljs-variable, -.emotion-5 .hljs-attribute, -.emotion-5 .hljs-template-variable, -.emotion-5 .hljs-tag, -.emotion-5 .hljs-name, -.emotion-5 .hljs-selector-id, -.emotion-5 .hljs-selector-class, -.emotion-5 .hljs-regexp, -.emotion-5 .hljs-title, -.emotion-5 .hljs-deletion { - color: #ec5e41; -} - -.emotion-5 .hljs-builtin-name, -.emotion-5 .hljs-literal, -.emotion-5 .hljs-type, -.emotion-5 .hljs-params, -.emotion-5 .hljs-meta, -.emotion-5 .hljs-link { - color: #ff802b; -} - -.emotion-5 .hljs-string, -.emotion-5 .hljs-number, -.emotion-5 .hljs-symbol, -.emotion-5 .hljs-bullet, -.emotion-5 .hljs-addition { - color: #55b467; -} - -.emotion-5 .hljs-keyword, -.emotion-5 .hljs-doctag, -.emotion-5 .hljs-built_in, -.emotion-5 .hljs-selector-tag, -.emotion-5 .hljs-section { - color: #369eff; -} - -.emotion-5 .hljs-emphasis { - font-style: italic; -} - -.emotion-5 .hljs-strong { - font-weight: bold; +.emotion-5 .shiki { + overflow-x: scroll; + background: none!important; } .emotion-6 { - width: 100%; -} - -.emotion-11 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -10509,7 +10452,7 @@ P .emotion-4:hover { gap: 8px; } -.emotion-12 { +.emotion-7 { -webkit-backdrop-filter: saturate(180%) blur(10px); backdrop-filter: saturate(180%) blur(10px); position: absolute; @@ -10534,7 +10477,7 @@ P .emotion-4:hover { border-radius: 6; } -.emotion-13 { +.emotion-8 { color: #aaaaaa; } @@ -10592,127 +10535,25 @@ P .emotion-4:hover { > java -
-      
-        
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-        
-      
- - public - - - - - class - - - - HelloWorld - - - - { -
- - - public - - - - static - - - - void - - - - - main - - ( - - - String - - [] args - - ) - - { -
- System.out.println( - - "Hello World!" - - ); -
- } -
- } -
-
+
+        
+          public class HelloWorld {
+    public static void main(String[] args) {
+      System.out.println("Hello World!");
+    }
+  }
+        
+      
+
java -
-      
-        
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-        
-      
- - public - - - - - class - - - - HelloWorld - - - - { -
- - - public - - - - static - - - - void - - - - - main - - ( - - - String - - [] args - - ) - - { -
- System.out.println( - - "Hello World!" - - ); -
- } -
- } -
-
+
+        
+          public class HelloWorld {
+    public static void main(String[] args) {
+      System.out.println("Hello World!");
+    }
+  }
+        
+      
+
java -
+      
+        
+          public class HelloWorld {
+    public static void main(String[] args) {
+      System.out.println("Hello World!");
+    }
+  }
+        
+      
+
+
- - - - - - - - - - - - - - - - - - - - - - - -
- 1 - - - public - - - - - class - - - - HelloWorld - - - - { -
- 2 - - - - public - - - - static - - - - void - - - - - main - - ( - - - String - - [] args - - ) - - { -
- 3 - - System.out.println( - - "Hello World!" - - ); -
- 4 - - } -
- 5 - - } -
- -
-
-
- - - java - -
-      
-        
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-          
-            
-          
-        
-      
+ - - public - - - - - class - - - - HelloWorld - - - - { -
- System.out.println( - - "Hello World!" - - ); -
- } -
- } -
-
-
-
-`; - -exports[` > renders theme.tsx correctly 1`] = ` -.emotion-0 { - background-color: #fafafa; - position: relative; - margin: 0; - border-radius: 6px; - -webkit-transition: background-color 100ms cubic-bezier(0.215, 0.61, 0.355, 1); - transition: background-color 100ms cubic-bezier(0.215, 0.61, 0.355, 1); -} - -.emotion-0:not(:hover) .ant-editor-highlight-copy { - visibility: hidden; - opacity: 0; -} - -.emotion-0:not(:hover) .ant-editor-highlight-tag { - visibility: hidden; - opacity: 0; -} - -.emotion-0 pre { - margin: 0!important; - padding: 16px 24px!important; - background: none!important; -} - -.emotion-0 code { - background: transparent!important; -} - -.emotion-1 { - position: absolute; - top: 16px; - right: 16px; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - width: 16px; - height: 16px; - padding: 0; - overflow: hidden; - border: 0; - outline: none; - cursor: pointer; - opacity: 0.6; - -webkit-transition: opacity 0.2s; - transition: opacity 0.2s; - background-color: #fafafa; -} - -.emotion-1:hover { - opacity: 0.8; -} - -.emotion-2 { - width: 16px; - color: #333333; - height: 16px; - font-size: 16px; -} - -.emotion-2.scoll { - -webkit-animation: copy-button-trans 2s; - animation: copy-button-trans 2s; - -webkit-animation-play-state: running; - animation-play-state: running; -} - -.emotion-4 { - color: #333333!important; - border-radius: 6px; - position: absolute; - z-index: 2; - right: 0; - bottom: 8px; - background-color: hsla(0, 0%, 95.1%, 0.9); - font-family: 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,Courier,monospace; - color: #666666; - -webkit-transition: opacity 0.1s; - transition: opacity 0.1s; -} - -P .emotion-4:hover { - color: #333333; - background: rgba(0, 0, 0, 0.15); -} - -.emotion-5 { - display: block; - overflow-x: auto; - color: #333333; - background-color: #666666; -} - -.emotion-5 .hljs-comment, -.emotion-5 .hljs-quote { - color: #aaaaaa; -} - -.emotion-5 .hljs-variable, -.emotion-5 .hljs-attribute, -.emotion-5 .hljs-template-variable, -.emotion-5 .hljs-tag, -.emotion-5 .hljs-name, -.emotion-5 .hljs-selector-id, -.emotion-5 .hljs-selector-class, -.emotion-5 .hljs-regexp, -.emotion-5 .hljs-title, -.emotion-5 .hljs-deletion { - color: #ec5e41; -} - -.emotion-5 .hljs-builtin-name, -.emotion-5 .hljs-literal, -.emotion-5 .hljs-type, -.emotion-5 .hljs-params, -.emotion-5 .hljs-meta, -.emotion-5 .hljs-link { - color: #ff802b; -} - -.emotion-5 .hljs-string, -.emotion-5 .hljs-number, -.emotion-5 .hljs-symbol, -.emotion-5 .hljs-bullet, -.emotion-5 .hljs-addition { - color: #55b467; -} - -.emotion-5 .hljs-keyword, -.emotion-5 .hljs-doctag, -.emotion-5 .hljs-built_in, -.emotion-5 .hljs-selector-tag, -.emotion-5 .hljs-section { - color: #369eff; -} - -.emotion-5 .hljs-emphasis { - font-style: italic; -} - -.emotion-5 .hljs-strong { - font-weight: bold; -} - -.emotion-6 { - width: 100%; -} - -.emotion-20 { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-box-pack: center; - -ms-flex-pack: center; - -webkit-justify-content: center; - justify-content: center; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - gap: 8px; -} - -.emotion-21 { - -webkit-backdrop-filter: saturate(180%) blur(10px); - backdrop-filter: saturate(180%) blur(10px); - position: absolute; - top: 0; - right: 0; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-align-items: center; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - -webkit-box-pack: center; - -ms-flex-pack: center; - -webkit-justify-content: center; - justify-content: center; - height: 36px; - padding: 0 8px; - font-family: 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,Courier,monospace; - color: #aaaaaa; - border-radius: 6; -} - -.emotion-22 { - color: #aaaaaa; -} - -
-
-
-
- 语言选择: -
-
-
-
- - - - - Typescript - -
-
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - class - - - - MyClass - - - - { -
- - - public - - - - static - - myValue: - - string - - ; -
- - - - constructor - - ( - - init: - - string - - - ) - - { -
- - - this - - .myValue = init; -
- } -
- } -
- - import - - fs = - - require - - ( - - "fs" - - ); -
- - module - - MyModule { -
- - - export - - - - interface - - MyInterface - - extends - - Other { -
- - - myProperty - - : - - any - - ; -
- } -
- } -
- - declare - - magicNumber - - number - - ; -
- myArray.forEach( - - () => - - { }); - - // fat arrow syntax - -
- -
- > renders code.tsx correctly 1`] = ` flex: 1; } -.emotion-4 { - display: block; - overflow-x: auto; - color: #333333; - background-color: #666666; -} - -.emotion-4 .hljs-comment, -.emotion-4 .hljs-quote { - color: #aaaaaa; -} - -.emotion-4 .hljs-variable, -.emotion-4 .hljs-attribute, -.emotion-4 .hljs-template-variable, -.emotion-4 .hljs-tag, -.emotion-4 .hljs-name, -.emotion-4 .hljs-selector-id, -.emotion-4 .hljs-selector-class, -.emotion-4 .hljs-regexp, -.emotion-4 .hljs-title, -.emotion-4 .hljs-deletion { - color: #ec5e41; -} - -.emotion-4 .hljs-builtin-name, -.emotion-4 .hljs-literal, -.emotion-4 .hljs-type, -.emotion-4 .hljs-params, -.emotion-4 .hljs-meta, -.emotion-4 .hljs-link { - color: #ff802b; -} - -.emotion-4 .hljs-string, -.emotion-4 .hljs-number, -.emotion-4 .hljs-symbol, -.emotion-4 .hljs-bullet, -.emotion-4 .hljs-addition { - color: #55b467; -} - -.emotion-4 .hljs-keyword, -.emotion-4 .hljs-doctag, -.emotion-4 .hljs-built_in, -.emotion-4 .hljs-selector-tag, -.emotion-4 .hljs-section { - color: #369eff; -} - -.emotion-4 .hljs-emphasis { - font-style: italic; -} - -.emotion-4 .hljs-strong { - font-weight: bold; +.emotion-4 .shiki { + overflow-x: scroll; + background: none!important; } .emotion-5 { - width: 100%; -} - -.emotion-7 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -16573,7 +15413,7 @@ exports[` > renders code.tsx correctly 1`] = ` gap: 8px; } -.emotion-8 { +.emotion-6 { -webkit-backdrop-filter: saturate(180%) blur(10px); backdrop-filter: saturate(180%) blur(10px); position: absolute; @@ -16598,11 +15438,11 @@ exports[` > renders code.tsx correctly 1`] = ` border-radius: 6; } -.emotion-9 { +.emotion-7 { color: #aaaaaa; } -.emotion-10 { +.emotion-8 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -16619,21 +15459,21 @@ exports[` > renders code.tsx correctly 1`] = ` transition: color 600ms cubic-bezier(0.215, 0.61, 0.355, 1),scale 400ms cubic-bezier(0.215, 0.61, 0.355, 1),background-color 100ms cubic-bezier(0.215, 0.61, 0.355, 1); } -.emotion-10:hover { +.emotion-8:hover { color: rgba(0, 0, 0, 0.88)!important; } -.emotion-10:active { +.emotion-8:active { scale: 0.8; color: rgba(0, 0, 0, 0.88); } -.emotion-11 { +.emotion-9 { background-color: rgba(0, 0, 0, 0.04); border-radius: 6px; } -.emotion-12:not(:last-child) { +.emotion-10:not(:last-child) { margin-block-start: 1em; margin-block-end: 1em; -webkit-margin-start: 0; @@ -16642,11 +15482,11 @@ exports[` > renders code.tsx correctly 1`] = ` margin-inline-end: 0; } -.emotion-12 pre { +.emotion-10 pre { padding: 12px!important; } -.emotion-13 { +.emotion-11 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -16664,16 +15504,16 @@ exports[` > renders code.tsx correctly 1`] = ` width: 100%; } -.emotion-14 { +.emotion-12 { padding: 4px 8px; width: auto!important; } -.emotion-14 .ant-editor-markdown-btn:hover { +.emotion-12 .ant-editor-markdown-btn:hover { color: rgba(0, 0, 0, 0.65)!important; } -.emotion-15 { +.emotion-13 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -16692,60 +15532,60 @@ exports[` > renders code.tsx correctly 1`] = ` height: 24px!important; } -.emotion-15:hover { +.emotion-13:hover { color: rgba(0, 0, 0, 0.88)!important; } -.emotion-15:active { +.emotion-13:active { scale: 0.8; color: rgba(0, 0, 0, 0.88); } -.emotion-16.ant-select-multiple:not(.emotion-16.ant-select-customize-input) .emotion-16.ant-select.ant-select-selector:hover { +.emotion-14.ant-select-multiple:not(.emotion-14.ant-select-customize-input) .emotion-14.ant-select.ant-select-selector:hover { color: rgba(0, 0, 0, 0.88); background-color: rgba(0, 0, 0, 0.04); border-color: transparent; } -.emotion-16.ant-select-multiple:not(.emotion-16.ant-select-customize-input) .emotion-16.ant-select.ant-select-selector:focus { +.emotion-14.ant-select-multiple:not(.emotion-14.ant-select-customize-input) .emotion-14.ant-select.ant-select-selector:focus { color: rgba(0, 0, 0, 0.88)!important; background-color: rgba(0, 0, 0, 0.02)!important; border-color: #1677ff!important; box-shadow: none; } -.emotion-16.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector { +.emotion-14.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector { border-color: transparent; } -.emotion-16.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector:hover { +.emotion-14.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector:hover { color: rgba(0, 0, 0, 0.88); background-color: rgba(0, 0, 0, 0.04); border-color: transparent; } -.emotion-16.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector:focus { +.emotion-14.ant-select:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector:focus { color: rgba(0, 0, 0, 0.88)!important; background-color: rgba(0, 0, 0, 0.02)!important; border-color: #1677ff!important; box-shadow: none; } -.emotion-16.ant-select-focused:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector { +.emotion-14.ant-select-focused:not(.ant-select-disabled):not(.ant-select-customize-input):hover .ant-select-selector { color: rgba(0, 0, 0, 0.88)!important; background-color: rgba(0, 0, 0, 0.02)!important; border-color: #1677ff!important; box-shadow: none; } -.emotion-16.ant-select-focused:not(.ant-select-disabled):not(.ant-select-customize-input) .ant-select-selector { +.emotion-14.ant-select-focused:not(.ant-select-disabled):not(.ant-select-customize-input) .ant-select-selector { color: rgba(0, 0, 0, 0.88)!important; background-color: rgba(0, 0, 0, 0.02)!important; border-color: #1677ff!important; box-shadow: none; } -.emotion-16 .ant-select-arrow { +.emotion-14 .ant-select-arrow { top: 13px; right: 8px; width: 10px; @@ -16753,20 +15593,20 @@ exports[` > renders code.tsx correctly 1`] = ` font-size: 10px; } -.emotion-17 { +.emotion-15 { min-width: 100px; } -.emotion-17 .ant-select-selector { +.emotion-15 .ant-select-selector { -webkit-padding-end: 4px!important; padding-inline-end: 4px!important; } -.emotion-17 .ant-select-selection-overflow-item-suffix .ant-select-selection-search { +.emotion-15 .ant-select-selection-overflow-item-suffix .ant-select-selection-search { display: none; } -.emotion-18 { +.emotion-16 { min-width: 100px; display: -webkit-box; display: -webkit-flex; @@ -16778,11 +15618,11 @@ exports[` > renders code.tsx correctly 1`] = ` justify-content: center; } -.emotion-18 span { +.emotion-16 span { font-family: 'SFMono-Regular',Consolas,'Liberation Mono',Menlo,Courier,monospace!important; } -.emotion-19 { +.emotion-17 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -16803,21 +15643,21 @@ exports[` > renders code.tsx correctly 1`] = ` padding-left: 6px; } -.emotion-19:hover { +.emotion-17:hover { color: rgba(0, 0, 0, 0.88)!important; } -.emotion-19:active { +.emotion-17:active { scale: 0.8; color: rgba(0, 0, 0, 0.88); } -.emotion-20 { +.emotion-18 { max-height: 400px; overflow: auto; } -.emotion-21 { +.emotion-19 { background-color: #fafafa; position: relative; margin: 0; @@ -16826,23 +15666,23 @@ exports[` > renders code.tsx correctly 1`] = ` transition: background-color 100ms cubic-bezier(0.215, 0.61, 0.355, 1); } -.emotion-21:not(:hover) .ant-editor-highlight-copy { +.emotion-19:not(:hover) .ant-editor-highlight-copy { visibility: hidden; opacity: 0; } -.emotion-21:not(:hover) .ant-editor-highlight-tag { +.emotion-19:not(:hover) .ant-editor-highlight-tag { visibility: hidden; opacity: 0; } -.emotion-21 pre { +.emotion-19 pre { margin: 0!important; padding: 16px 24px!important; background: none!important; } -.emotion-21 code { +.emotion-19 code { background: transparent!important; } @@ -16861,36 +15701,22 @@ exports[` > renders code.tsx correctly 1`] = `
-
-            
-              
-                
-                  
-                
-                
-                  
-              
-            
- $ pnpm install -
-
-
+
+              
+                $ pnpm install
+
+              
+            
+
+
> renders code.tsx correctly 1`] = `
+ +
+
+
+
+
+                
+                  
+
+
+                  
+                  
+
+                  
+                  
+
+                  
+                    Custom Html Dom Render
+                  
+                  
+
+
+
+                  
+ Custom Html Dom Render +
+ + +
    + + +
  • + Ant Desgin +
  • + + +
  • + Ant Desgin Pro +
  • + + +
  • + Ant Desgin Pro Components +
  • + + +
+ + + + + +
+
+