Browse Source

chore:backup

代强 1 year ago
parent
commit
029224f0bf

+ 71 - 2
content/plus/CodeHighlight/index.md

@@ -2,18 +2,21 @@
 localeCode: zh-CN
 order: 0
 category: Plus
-title:  代码高亮
+title:  CodeHighlight 代码高亮
 icon: doc-configprovider
 dir: column
 brief: 根据语法高亮页面中的代码块
 ---
 
+Semi 代码高亮组件使用了 prismjs,支持297 种编程语言的高亮(已自动配置 `JavaScript` `CSS` `类 C` `html` `svg` 等,其他语言需要手动引入),同时具有高扩展性和丰富的插件生态。
+
+向 `code` props 传入代码纯文本,并在 `language` 传入编程语言名称。支持的编程语言和对应名称在 [Prismjs 官网](https://prismjs.com/#supported-languages) 查看
+
 
 ## 代码演示
 
 ### 如何引入
 
-Semi 代码高亮组件使用了 prismjs,支持297 种编程语言的高亮,同时具有高扩展性和丰富的插件生态。
 
 ```jsx
 import { CodeHighlight } from '@douyinfe/semi-ui';
@@ -25,6 +28,8 @@ import "prismjs/themes/prism.min.css";  // 手动引入高亮主题
 ### 基本用法
 
 ```jsx live=true dir=column
+import { CodeHighlight } from '@douyinfe/semi-ui';
+import "prismjs/themes/prism.min.css";
 
 function Demo() {
 
@@ -47,6 +52,8 @@ const Test = ()=>{
 **CSS**
 
 ```jsx live=true dir=column
+import { CodeHighlight } from '@douyinfe/semi-ui';
+import "prismjs/themes/prism.min.css";
 
 function Demo() {
 
@@ -72,3 +79,65 @@ function Demo() {
 ```
 
 
+### 支持其他语言
+
+支持 297 种语言,除去 `JavaScript` `CSS` `类 C` `html` `svg` 外,支持其他语言需要手动引入配置。 
+
+
+例如,高亮用于编写 GTK 程序前端 UI 的 Vala 语言,需要引入 `prism-vala.js` 
+
+```javascript
+import "prismjs/components/prism-vala.js"
+```
+
+```jsx live=true dir=column
+import { CodeHighlight } from '@douyinfe/semi-ui';
+import "prismjs/themes/prism.min.css";
+import "prismjs/components/prism-vala.js"
+
+function Demo() {
+    return <CodeHighlight 
+        className="codeHighlightDemo" // 用于防止 Semi 文档站样式影响 Demo 展示效果,实际项目不需要该 ClassName
+        language={"vala"} code={
+        `public class ExampleApp : Gtk.Application {
+    public ExampleApp () {
+        Object (application_id: "com.example.App");
+    }
+
+    public override void activate () {
+        var win = new Gtk.ApplicationWindow (this);
+
+        var btn = new Gtk.Button.with_label ("Hello World");
+        btn.clicked.connect (win.close);
+
+        win.child = btn;
+        win.present ();
+    }
+
+    public static int main (string[] args) {
+        var app = new ExampleApp ();
+        return app.run (args);
+    }
+}
+`
+    }/>
+}
+
+```
+
+
+### API
+
+| 属性        | 说明    | 类型     | 默认值 |
+|-----------|-------|--------|-----|
+| className | 类名    | string | -   |
+| code      | 代码纯文本 | string | -   |
+| language  | 语言类型  | string | -   |
+|lineNumber | 是佛开启行数显示 | boolean | true |
+| style | 样式 | CSSProperties | - |
+
+## 设计变量
+
+<DesignToken/>
+
+

+ 9 - 6
content/plus/markdownrender/index-en-US.md

@@ -134,12 +134,15 @@ Just write JSX directly in Markdown
 ```
 
 
-### MarkdownRender
-
-| PROPERTIES         | INSTRUCTIONS                         | TYPE                                    | DEFAULT |
-|------------|----------------------------|---------------------------------------| --- |
-| mdxRaw     | Plain text in Markdown or MDX        | string                                | - |
-| components | Used to cover Markdown elements and also add custom components | Record<string, JSXElementConstructor> | - |
+### API
+
+| Properties | Description | Type | Default Value |
+|------------|-----------------------------|------ ------------------------|-------|
+| className | class name | string | - |
+| components | Used to override Markdown elements and add custom components | Record<string, JSXElementConstructor> | - |
+| format | The incoming raw type, whether it is pure Markdown | 'md'\|'mdx' | 'mdx' |
+| raw | plain text in Markdown or MDX | string | - |
+| style | style | CSSProperties | - |
 
 ## Design Token
 

+ 4 - 2
content/plus/markdownrender/index.md

@@ -173,13 +173,15 @@ function Demo() {
 ```
 
 
-### MarkdownRender
+### API
 
 | 属性         | 说明                         | 类型                                    | 默认值   |
 |------------|----------------------------|---------------------------------------|-------|
+| className | 类名    | string | -   |
 | components | 用于覆盖 Markdown 元素,也可添加自定义组件 | Record<string, JSXElementConstructor> | -     |
-| raw        | Markdown 或 MDX 的纯文本        | string                                | -     |
 | format     | 传入的 raw 类型,是否是纯 Markdown   | 'md'\|'mdx'                           | 'mdx' |
+| raw        | Markdown 或 MDX 的纯文本        | string                                | -     |
+| style | 样式 | CSSProperties | - |
 
 ## 设计变量
 

+ 1 - 1
package.json

@@ -49,7 +49,7 @@
         "@douyinfe/semi-site-banner": "^0.1.5",
         "@douyinfe/semi-site-doc-style": "0.0.2",
         "@douyinfe/semi-site-header": "^0.0.29",
-        "@douyinfe/semi-site-markdown-blocks": "^0.0.9",
+        "@douyinfe/semi-site-markdown-blocks": "^0.0.14",
         "@mdx-js/mdx": "1.6.22",
         "@mdx-js/react": "^1.6.22",
         "@storybook/react-webpack5": "^7.0.7",

+ 1 - 0
src/components/layout.js

@@ -33,6 +33,7 @@ import Footer from './Footer';
 import { itemsArr } from 'utils/category';
 import { getLocale, _t } from 'utils/locale';
 import { useIde } from './useIde';
+import "prismjs/components/prism-vala.js"
 
 
 const insertScript = scriptText => {

+ 1 - 1
src/styles/layout.scss

@@ -32,7 +32,7 @@ body[theme-mode="dark"] {
     }
 }
 
-.markdown > pre {
+pre:not(.codeHighlightDemo),code:not(.codeHighlightDemo *) {
     font-family: Inconsolata, monospace;
     background-color: var(--semi-color-fill-1);
     margin-left: 4px;

+ 9 - 9
yarn.lock

@@ -1667,20 +1667,20 @@
     lodash-es "^4.17.21"
     react-i18next "^11.12.0"
 
-"@douyinfe/semi-site-markdown-blocks@^0.0.9":
-  version "0.0.9"
-  resolved "https://registry.npmjs.org/@douyinfe/semi-site-markdown-blocks/-/semi-site-markdown-blocks-0.0.9.tgz#df0c02b0867b08e499143b26a189280c909bb438"
-  integrity sha512-mEKHb9LNlo5QjDK6Rw3RkjGBmE5Ivg5ChCAPeqtNsBkzNcF78D7SvrL5U8U6R/F4iIfTqw7gHfvuMte1L559iw==
+"@douyinfe/semi-site-markdown-blocks@^0.0.14":
+  version "0.0.14"
+  resolved "https://registry.npmjs.org/@douyinfe/semi-site-markdown-blocks/-/semi-site-markdown-blocks-0.0.14.tgz#ac657263b5546e6e7be1f4fd4af878af32377889"
+  integrity sha512-kbPe0xxdeDmikgQSW3ORNB47EpvszgIe6DBsDY/dwR6Y2nZv4bEURLdgEXhsZKauwhzB+BygP/wtV0qMlEp7/w==
   dependencies:
-    "@douyinfe/semi-site-playground" "0.0.9"
+    "@douyinfe/semi-site-playground" "0.0.13"
     classnames "^2.2.6"
     prism-react-renderer "^1.0.1"
     prop-types "^15.7.2"
 
-"@douyinfe/[email protected].9":
-  version "0.0.9"
-  resolved "https://registry.npmjs.org/@douyinfe/semi-site-playground/-/semi-site-playground-0.0.9.tgz#cb1362c636f73f7251c887a1e2b03e4e34153ee3"
-  integrity sha512-ojp5HQUN/2PD5CQEszUdU5oXsQIYUacZhbzfSw+Y7YdU1UPh/L31GmXfOjXccziIYZoqAyk6foqLIU1wtg+Ipw==
+"@douyinfe/[email protected].13":
+  version "0.0.13"
+  resolved "https://registry.npmjs.org/@douyinfe/semi-site-playground/-/semi-site-playground-0.0.13.tgz#70adad18d7a99944ad8529596c554ab49897ecf2"
+  integrity sha512-z5Kj53K1dM02oSuR7Ca10aVsoXo6q/E0UOX7VF2VBmi8vShknL1VRMXsxev20IFSVxZOXlAYGO4SkL1KqWxdSg==
   dependencies:
     "@douyinfe/semi-icons" "^2.0.0"
     "@douyinfe/semi-ui" "^2.0.0"