@antv/dumi-theme-antv 0.3.0-beta.3 → 0.3.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/layouts/DocLayout.js +13 -9
- package/dist/pages/Example/index.js +8 -49
- package/dist/pages/Example/index.module.less +50 -8
- package/dist/pages/Examples/components/GalleryPageContent/DemoCard/index.js +1 -1
- package/dist/pages/Examples/index.js +13 -2
- package/dist/pages/Examples/index.module.less +2 -0
- package/dist/plugin/examples.d.ts +10 -5
- package/dist/plugin/examples.js +6 -3
- package/dist/plugin/index.js +4 -0
- package/dist/slots/Cases/index.d.ts +1 -0
- package/dist/slots/CodeEditor/Toolbar.js +4 -16
- package/dist/slots/CodeEditor/index.js +8 -2
- package/dist/slots/CodePreview/CodeHeader.js +2 -2
- package/dist/slots/CodePreview/index.module.less +3 -5
- package/dist/slots/CodeRunner/index.d.ts +2 -2
- package/dist/slots/CodeRunner/index.js +4 -2
- package/dist/slots/CodeRunner/utils.d.ts +3 -2
- package/dist/slots/CodeRunner/utils.js +1 -1
- package/dist/slots/Detail/News.d.ts +1 -0
- package/dist/slots/Detail/index.d.ts +1 -0
- package/dist/slots/Detail/index.js +1 -1
- package/dist/slots/ExampleSider/index.d.ts +0 -35
- package/dist/slots/ExampleSider/index.js +20 -42
- package/dist/slots/ExampleSider/index.module.less +1 -1
- package/dist/slots/Features/FeatureCard.d.ts +1 -0
- package/dist/slots/Features/index.js +2 -1
- package/dist/slots/Header/Navs.js +3 -1
- package/dist/slots/Header/index.js +8 -7
- package/dist/slots/Loading/index.d.ts +6 -1
- package/dist/slots/Loading/index.js +24 -10
- package/dist/slots/Loading/index.module.less +276 -9
- package/dist/slots/ManualContent/index.js +19 -9
- package/dist/slots/hooks.d.ts +3 -3
- package/dist/slots/utils.d.ts +4 -19
- package/dist/slots/utils.js +77 -119
- package/dist/types.d.ts +84 -0
- package/dist/typings.d.ts +0 -116
- package/package.json +4 -4
- package/dist/slots/Loading.d.ts +0 -5
- package/dist/slots/Loading.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { useOutlet, useLocation } from 'dumi';
|
|
3
3
|
import { Index } from "./entry/Index";
|
|
4
4
|
import { API } from "./entry/API";
|
|
@@ -11,25 +11,29 @@ import "../slots/_.less";
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export default (function () {
|
|
14
|
+
// 打印控制台文案
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
console.log("%cAntV 让数据栩栩如生", "color:#5B7102; font-size: 20px;"), console.log("%c新一代数据可视化解决方案", "color:#5B7102;"), console.log("--------------------------"), console.log("%c关注我们的微信公众号 %c“数据可视化 AntV”%c,获取我们团队最新的进展、动态、分享,也欢迎加入我们!", "color: red", "color: pink", "color: red");
|
|
17
|
+
}, []);
|
|
14
18
|
var outlet = useOutlet();
|
|
15
19
|
|
|
16
20
|
var _useLocation = useLocation(),
|
|
17
21
|
pathname = _useLocation.pathname;
|
|
18
22
|
|
|
19
|
-
var
|
|
20
|
-
// 做一些跳转,比如:/zh/examples/xxx -> /examples/xxx
|
|
21
|
-
// 首页
|
|
23
|
+
var path = pathname.toLowerCase(); // 统一去掉中英文前缀
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
var p = path.replace('/zh/', '/').replace('/en/', '/'); // 首页
|
|
24
26
|
|
|
25
|
-
if (p
|
|
26
|
-
|
|
27
|
+
if (p === '/' || p === '/zh' || p === '/en' || p === '/en/') return /*#__PURE__*/React.createElement(Index, null); // API 页面
|
|
28
|
+
|
|
29
|
+
if (p.startsWith('/api') || // 这两个是兼容之前的
|
|
30
|
+
p.startsWith('/docs/api')) {
|
|
27
31
|
return /*#__PURE__*/React.createElement(API, null, " ", outlet, " ");
|
|
28
32
|
} // 教程页面
|
|
29
33
|
|
|
30
34
|
|
|
31
|
-
if (p.startsWith('/manual') ||
|
|
32
|
-
p.startsWith('/
|
|
35
|
+
if (p.startsWith('/manual') || // 这两个是兼容之前的
|
|
36
|
+
p.startsWith('/docs/manual')) {
|
|
33
37
|
return /*#__PURE__*/React.createElement(Manual, null, " ", outlet, " ");
|
|
34
38
|
} // More router, add here...
|
|
35
39
|
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
2
|
|
|
9
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -39,8 +33,6 @@ var Example = function Example() {
|
|
|
39
33
|
var nav = useNavigate();
|
|
40
34
|
|
|
41
35
|
var _useParams = useParams(),
|
|
42
|
-
_useParams$language = _useParams.language,
|
|
43
|
-
language = _useParams$language === void 0 ? 'zh' : _useParams$language,
|
|
44
36
|
topic = _useParams.topic,
|
|
45
37
|
example = _useParams.example;
|
|
46
38
|
/** 示例页面的元数据信息 */
|
|
@@ -56,51 +48,17 @@ var Example = function Example() {
|
|
|
56
48
|
currentDemo = _useState2[0],
|
|
57
49
|
setCurrentDemo = _useState2[1];
|
|
58
50
|
|
|
51
|
+
var _useState3 = useState(false),
|
|
52
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
53
|
+
isCollapsed = _useState4[0],
|
|
54
|
+
setIsCollapsed = _useState4[1];
|
|
55
|
+
|
|
59
56
|
useEffect(function () {
|
|
60
57
|
if (topic && example && demo) {
|
|
61
58
|
var targetDemoInfo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
62
59
|
setCurrentDemo(targetDemoInfo);
|
|
63
60
|
}
|
|
64
|
-
}, [topic, example, hash]);
|
|
65
|
-
|
|
66
|
-
var getPath = function getPath(item) {
|
|
67
|
-
var _item$relativePath;
|
|
68
|
-
|
|
69
|
-
if (!item) {// @todo 怀策
|
|
70
|
-
// debugger
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var demoSlug = (_item$relativePath = item.relativePath) === null || _item$relativePath === void 0 ? void 0 : _item$relativePath.replace(/\/demo\/(.*)\..*/, function (_, filename) {
|
|
74
|
-
return "#".concat(filename);
|
|
75
|
-
});
|
|
76
|
-
return "/".concat(locale.id, "/examples/").concat(demoSlug);
|
|
77
|
-
}; // 一级菜单,二级菜单 数据 treeData + 二级菜单,示例 数据 result 写成一个 一级,二级,示例的三层树结构 数据
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var transformNode = function transformNode(data, result) {
|
|
81
|
-
return data.map(function (item) {
|
|
82
|
-
var _result$find;
|
|
83
|
-
|
|
84
|
-
if (item.children && !item.node) {
|
|
85
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
86
|
-
children: transformNode(item.children, result)
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var _item$node = item.node,
|
|
91
|
-
frontmatter = _item$node.frontmatter,
|
|
92
|
-
fields = _item$node.fields;
|
|
93
|
-
return _objectSpread(_objectSpread({}, frontmatter), {}, {
|
|
94
|
-
// 提前给二级菜单的key值加入 特殊值 好辨别
|
|
95
|
-
value: "secondaryKey-".concat(fields === null || fields === void 0 ? void 0 : fields.slug),
|
|
96
|
-
children: (_result$find = result.find(function (_ref) {
|
|
97
|
-
var k = _ref.title;
|
|
98
|
-
return k === frontmatter.title;
|
|
99
|
-
})) === null || _result$find === void 0 ? void 0 : _result$find.children
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
|
|
61
|
+
}, [topic, example, hash]);
|
|
104
62
|
return /*#__PURE__*/React.createElement("div", {
|
|
105
63
|
className: styles.example
|
|
106
64
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
@@ -112,7 +70,8 @@ var Example = function Example() {
|
|
|
112
70
|
width: 250,
|
|
113
71
|
trigger: null,
|
|
114
72
|
collapsible: true,
|
|
115
|
-
|
|
73
|
+
collapsed: isCollapsed,
|
|
74
|
+
className: styles.menuSider,
|
|
116
75
|
theme: "light"
|
|
117
76
|
}, currentDemo && /*#__PURE__*/React.createElement(ExampleSider, {
|
|
118
77
|
showExampleDemoTitle: true,
|
|
@@ -16,14 +16,6 @@
|
|
|
16
16
|
flex: 1;
|
|
17
17
|
background-color: #fff;
|
|
18
18
|
|
|
19
|
-
.sider {
|
|
20
|
-
height: 100%;
|
|
21
|
-
|
|
22
|
-
.exampleList {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
.content {
|
|
28
20
|
position: relative;
|
|
29
21
|
height: 100%;
|
|
@@ -38,3 +30,53 @@
|
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
}
|
|
33
|
+
|
|
34
|
+
.menuSider {
|
|
35
|
+
background-color: #f8f9fc;
|
|
36
|
+
border-right: 1px solid #ececec;
|
|
37
|
+
|
|
38
|
+
:global {
|
|
39
|
+
.ant-layout-sider-children {
|
|
40
|
+
overflow-y: hidden;
|
|
41
|
+
overflow-x: hidden;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
overflow-y: auto;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.trigger {
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
position: relative;
|
|
53
|
+
margin: auto;
|
|
54
|
+
color: #6c7f90;
|
|
55
|
+
left: -1px;
|
|
56
|
+
z-index: 4;
|
|
57
|
+
width: 22px;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: color 0.3s;
|
|
60
|
+
border: 1px solid #ececec;
|
|
61
|
+
border-left: none;
|
|
62
|
+
background-color: #fff;
|
|
63
|
+
height: 66px;
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
border-bottom-right-radius: 4px;
|
|
66
|
+
border-top-right-radius: 4px;
|
|
67
|
+
text-align: center;
|
|
68
|
+
|
|
69
|
+
&[type='menu-unfold'] {
|
|
70
|
+
background-color: #f8f9fc;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
svg {
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 3px;
|
|
76
|
+
top: 25px;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.trigger:hover {
|
|
81
|
+
color: @primary-color;
|
|
82
|
+
}
|
|
@@ -25,7 +25,7 @@ export var DemoCard = function DemoCard(props) {
|
|
|
25
25
|
|
|
26
26
|
return /*#__PURE__*/React.createElement(Link, {
|
|
27
27
|
className: styles.galleryCardLink,
|
|
28
|
-
to: "
|
|
28
|
+
to: "".concat(locale.id == 'zh' ? '' : '/en', "/examples/").concat(topicId, "/").concat(exampleId, "/#").concat(demo.id)
|
|
29
29
|
}, demo.isNew ? /*#__PURE__*/React.createElement(Badge.Ribbon, {
|
|
30
30
|
text: "new",
|
|
31
31
|
className: styles.customRibbon
|
|
@@ -11,7 +11,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
13
|
import React from 'react';
|
|
14
|
-
import { useContext } from 'react';
|
|
14
|
+
import { useContext, useEffect } from 'react';
|
|
15
|
+
import { useNavigate } from 'react-router-dom';
|
|
15
16
|
import { BackTop, Layout as AntLayout } from 'antd';
|
|
16
17
|
import { Header } from "../../slots/Header";
|
|
17
18
|
import { Footer } from "../../slots/Footer";
|
|
@@ -30,15 +31,25 @@ import styles from "./index.module.less";
|
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
33
|
var Example = function Example() {
|
|
34
|
+
var nav = useNavigate();
|
|
33
35
|
/** 示例页面的元数据信息 */
|
|
36
|
+
|
|
34
37
|
var metaData = useContext(ThemeAntVContext);
|
|
35
38
|
var exampleTopics = metaData.meta.exampleTopics;
|
|
36
39
|
|
|
37
40
|
var _usePrevAndNext = usePrevAndNext(),
|
|
38
41
|
_usePrevAndNext2 = _slicedToArray(_usePrevAndNext, 2),
|
|
39
42
|
prev = _usePrevAndNext2[0],
|
|
40
|
-
next = _usePrevAndNext2[1];
|
|
43
|
+
next = _usePrevAndNext2[1]; // 为 zh 做兜底
|
|
44
|
+
|
|
41
45
|
|
|
46
|
+
useEffect(function () {
|
|
47
|
+
var p = window.location.pathname;
|
|
48
|
+
|
|
49
|
+
if (p.includes('/zh/')) {
|
|
50
|
+
nav(p.replace('/zh/', '/'));
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
42
53
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Header, {
|
|
43
54
|
isHomePage: false
|
|
44
55
|
}), /*#__PURE__*/React.createElement(AntLayout, {
|
|
@@ -268,6 +268,7 @@
|
|
|
268
268
|
.sider {
|
|
269
269
|
width: 280px !important;
|
|
270
270
|
height: inherit;
|
|
271
|
+
background-color: #fff;
|
|
271
272
|
|
|
272
273
|
// menu 滚动
|
|
273
274
|
:global {
|
|
@@ -282,6 +283,7 @@
|
|
|
282
283
|
}
|
|
283
284
|
|
|
284
285
|
.affix {
|
|
286
|
+
background-color: #fff;
|
|
285
287
|
& > div {
|
|
286
288
|
height: 100%;
|
|
287
289
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { Example, ExampleTopic } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* 获取案例页面的所有主题
|
|
3
4
|
*
|
|
4
|
-
* @returns {
|
|
5
|
+
* @returns {ExampleTopic[]} 案例主题列表
|
|
5
6
|
* @author YuZhanglong <loveyzl1123@gmail.com>
|
|
6
7
|
*/
|
|
7
|
-
export declare const getExamplesPageTopics: (exampleTopics:
|
|
8
|
+
export declare const getExamplesPageTopics: (exampleTopics: ExampleTopic[]) => {
|
|
8
9
|
id: string;
|
|
9
|
-
title:
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
title: {
|
|
11
|
+
zh: string;
|
|
12
|
+
en: string;
|
|
13
|
+
};
|
|
14
|
+
icon: string;
|
|
15
|
+
examples: Example[];
|
|
16
|
+
childrenKey: string;
|
|
12
17
|
}[];
|
package/dist/plugin/examples.js
CHANGED
|
@@ -63,10 +63,12 @@ var getTopicExamples = (topicPath) => {
|
|
|
63
63
|
title: {
|
|
64
64
|
en: exampleMetaEnContent.attributes.title,
|
|
65
65
|
zh: exampleMetaZhContent.attributes.title
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
|
+
childrenKey: "demos",
|
|
68
|
+
order: exampleMetaZhContent.attributes.order || 0
|
|
67
69
|
};
|
|
68
70
|
return example;
|
|
69
|
-
});
|
|
71
|
+
}).sort((a, b) => a.order - b.order);
|
|
70
72
|
};
|
|
71
73
|
var getExamplesPageTopics = (exampleTopics) => {
|
|
72
74
|
return exampleTopics.map(({ id, slug, title, icon }) => {
|
|
@@ -81,7 +83,8 @@ var getExamplesPageTopics = (exampleTopics) => {
|
|
|
81
83
|
id: nid,
|
|
82
84
|
title,
|
|
83
85
|
icon,
|
|
84
|
-
examples
|
|
86
|
+
examples,
|
|
87
|
+
childrenKey: "examples"
|
|
85
88
|
};
|
|
86
89
|
});
|
|
87
90
|
};
|
package/dist/plugin/index.js
CHANGED
|
@@ -26,6 +26,10 @@ var import_examples = require("./examples");
|
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
27
|
var plugin_default = (api) => {
|
|
28
28
|
api.describe({ key: `dumi-theme:${require("../../package.json").name}` });
|
|
29
|
+
api.modifyDefaultConfig((memo) => {
|
|
30
|
+
memo.resolve.codeBlockMode = "passive";
|
|
31
|
+
return memo;
|
|
32
|
+
});
|
|
29
33
|
const pages = [
|
|
30
34
|
{
|
|
31
35
|
id: "dumi-theme-antv-example-list-zh",
|
|
@@ -19,7 +19,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
19
19
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20
20
|
|
|
21
21
|
import React, { useEffect, useState } from 'react';
|
|
22
|
-
import { CodeSandboxOutlined, PlayCircleOutlined, ThunderboltOutlined
|
|
22
|
+
import { CodeSandboxOutlined, PlayCircleOutlined, ThunderboltOutlined } from '@ant-design/icons';
|
|
23
23
|
import { Typography, Tooltip } from 'antd';
|
|
24
24
|
import { useLocale } from 'dumi';
|
|
25
25
|
import { getParameters } from 'codesandbox/lib/api/define';
|
|
@@ -68,8 +68,8 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
68
68
|
updateRiddleVisible = _useState2[1];
|
|
69
69
|
|
|
70
70
|
useEffect(function () {
|
|
71
|
-
ping(function (status) {
|
|
72
|
-
updateRiddleVisible(status === 'responded');
|
|
71
|
+
ping().then(function (status) {
|
|
72
|
+
return updateRiddleVisible(status === 'responded');
|
|
73
73
|
});
|
|
74
74
|
}, []);
|
|
75
75
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -129,19 +129,7 @@ export var Toolbar = function Toolbar(_ref) {
|
|
|
129
129
|
style: {
|
|
130
130
|
marginLeft: 6
|
|
131
131
|
}
|
|
132
|
-
}),
|
|
133
|
-
title: isFullScreen ? useT('离开全屏') : useT('进入全屏')
|
|
134
|
-
}, isFullScreen ? /*#__PURE__*/React.createElement(FullscreenExitOutlined, {
|
|
135
|
-
onClick: onToggleFullscreen,
|
|
136
|
-
style: {
|
|
137
|
-
marginLeft: 12
|
|
138
|
-
}
|
|
139
|
-
}) : /*#__PURE__*/React.createElement(FullscreenOutlined, {
|
|
140
|
-
onClick: onToggleFullscreen,
|
|
141
|
-
style: {
|
|
142
|
-
marginLeft: 12
|
|
143
|
-
}
|
|
144
|
-
})) : null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
132
|
+
}), /*#__PURE__*/React.createElement(Tooltip, {
|
|
145
133
|
title: useT('执行代码')
|
|
146
134
|
}, /*#__PURE__*/React.createElement(PlayCircleOutlined, {
|
|
147
135
|
onClick: onExecuteCode,
|
|
@@ -16,6 +16,7 @@ import { useSiteData, useLocale } from 'dumi';
|
|
|
16
16
|
import { debounce, noop } from 'lodash-es';
|
|
17
17
|
import { replaceInsertCss, execute, compile } from "./utils";
|
|
18
18
|
import { Toolbar, EDITOR_TABS } from "./Toolbar";
|
|
19
|
+
import { Loading } from "../Loading";
|
|
19
20
|
import styles from "./index.module.less";
|
|
20
21
|
loader.config({
|
|
21
22
|
'vs/nls': {
|
|
@@ -149,6 +150,11 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
152
|
}, []);
|
|
153
|
+
useEffect(function () {
|
|
154
|
+
if (monacoRef.current) {
|
|
155
|
+
monacoRef.current.setValue(currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2));
|
|
156
|
+
}
|
|
157
|
+
}, [currentEditorTab]);
|
|
152
158
|
var onCodeChange = useCallback(function (value) {
|
|
153
159
|
if (currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
|
|
154
160
|
setCode(value);
|
|
@@ -177,9 +183,9 @@ export var CodeEditor = function CodeEditor(_ref) {
|
|
|
177
183
|
}
|
|
178
184
|
}, /*#__PURE__*/React.createElement(MonacoEditor, {
|
|
179
185
|
language: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? 'javascript' : 'json',
|
|
180
|
-
value:
|
|
186
|
+
value: code,
|
|
181
187
|
path: relativePath,
|
|
182
|
-
loading:
|
|
188
|
+
loading: /*#__PURE__*/React.createElement(Loading, null),
|
|
183
189
|
options: {
|
|
184
190
|
readOnly: currentEditorTab === EDITOR_TABS.DATA,
|
|
185
191
|
automaticLayout: true,
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { PageHeader, Tooltip, Space, Divider } from 'antd';
|
|
3
3
|
import { EditOutlined } from '@ant-design/icons';
|
|
4
4
|
import { useT } from "../hooks";
|
|
5
|
-
import {
|
|
5
|
+
import { getGithubSourceURL } from "../utils";
|
|
6
6
|
import styles from "./CodeHeader.module.less";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -18,7 +18,7 @@ export var CodeHeader = function CodeHeader(_ref) {
|
|
|
18
18
|
subTitle: /*#__PURE__*/React.createElement(Tooltip, {
|
|
19
19
|
title: useT('在 GitHub 上编辑')
|
|
20
20
|
}, /*#__PURE__*/React.createElement("a", {
|
|
21
|
-
href:
|
|
21
|
+
href: getGithubSourceURL(githubUrl, relativePath, 'examples'),
|
|
22
22
|
target: "_blank",
|
|
23
23
|
rel: "noopener noreferrer",
|
|
24
24
|
className: styles.editOnGtiHubButton
|
|
@@ -10,24 +10,22 @@
|
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
12
|
.header {
|
|
13
|
-
flex: 0
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
.content {
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
16
|
position: relative;
|
|
17
|
+
flex: 1;
|
|
18
|
+
min-height: 0;
|
|
20
19
|
|
|
21
20
|
:global(#playgroundScriptContainer) {
|
|
22
|
-
flex: 1;
|
|
23
21
|
position: relative;
|
|
24
22
|
width: 100%;
|
|
25
23
|
height: 100%;
|
|
26
24
|
|
|
27
25
|
:global(#container) {
|
|
26
|
+
position: relative;
|
|
28
27
|
width: 100%;
|
|
29
28
|
height: 100%;
|
|
30
|
-
position: relative;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ExampleTopic } from '../../types';
|
|
3
3
|
declare type CodeRunnerProps = {
|
|
4
4
|
topic: string;
|
|
5
5
|
example: string;
|
|
6
6
|
demo: string;
|
|
7
|
-
exampleTopics:
|
|
7
|
+
exampleTopics: ExampleTopic[];
|
|
8
8
|
notFound?: React.Element;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
@@ -40,7 +40,8 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
40
40
|
var _useSiteData = useSiteData(),
|
|
41
41
|
themeConfig = _useSiteData.themeConfig;
|
|
42
42
|
|
|
43
|
-
var githubUrl = themeConfig.githubUrl
|
|
43
|
+
var githubUrl = themeConfig.githubUrl,
|
|
44
|
+
playground = themeConfig.playground;
|
|
44
45
|
|
|
45
46
|
var _useState = useState(),
|
|
46
47
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -71,6 +72,7 @@ export var CodeRunner = function CodeRunner(_ref) {
|
|
|
71
72
|
onError: setError,
|
|
72
73
|
onFullscreen: setFullscreen,
|
|
73
74
|
onDestroy: noop,
|
|
74
|
-
onReady: noop
|
|
75
|
+
onReady: noop,
|
|
76
|
+
playground: playground
|
|
75
77
|
}));
|
|
76
78
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Demo, ExampleTopic } from '../../types';
|
|
1
2
|
/**
|
|
2
3
|
* 将数据结构转化成 map,便于后续检索的速度
|
|
3
4
|
* @param exampleTopics
|
|
4
5
|
* @returns
|
|
5
6
|
*/
|
|
6
|
-
export declare function getExampleTopicMap(exampleTopics:
|
|
7
|
+
export declare function getExampleTopicMap(exampleTopics: ExampleTopic[]): Map<string, Demo>;
|
|
7
8
|
/**
|
|
8
9
|
* 从 Context 信息中,获取到 Example 相关的信息,用于页面渲染
|
|
9
10
|
*/
|
|
10
|
-
export declare function getDemoInfo(exampleTopics:
|
|
11
|
+
export declare function getDemoInfo(exampleTopics: ExampleTopic[], topic: string, example: string, demo: string): Demo;
|
|
@@ -5,12 +5,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import { map } from 'lodash-es';
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* 将数据结构转化成 map,便于后续检索的速度
|
|
10
11
|
* @param exampleTopics
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
14
|
export function getExampleTopicMap(exampleTopics) {
|
|
15
15
|
var exampleTopicMap = new Map();
|
|
16
16
|
map(exampleTopics, function (topic) {
|
|
@@ -81,7 +81,7 @@ export var Detail = function Detail(_ref) {
|
|
|
81
81
|
link = _ref2.link,
|
|
82
82
|
shape = _ref2.shape;
|
|
83
83
|
return /*#__PURE__*/React.createElement("a", {
|
|
84
|
-
key: text,
|
|
84
|
+
key: ic(text),
|
|
85
85
|
className: cx(styles.buttonLink, styles[type || ''], type === 'primary' ? 'primary-button' : 'common-button'),
|
|
86
86
|
style: _objectSpread({
|
|
87
87
|
borderRadius: shape === 'square' ? '4px' : '1000px'
|
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface PlayGroundItemProps {
|
|
3
|
-
source: string;
|
|
4
|
-
examples: PlayGroundItemProps[];
|
|
5
|
-
babeledSource: string;
|
|
6
|
-
absolutePath?: string;
|
|
7
|
-
relativePath?: string;
|
|
8
|
-
screenshot?: string;
|
|
9
|
-
recommended?: boolean;
|
|
10
|
-
filename: string;
|
|
11
|
-
title?: string;
|
|
12
|
-
location?: Location;
|
|
13
|
-
playground?: {
|
|
14
|
-
container?: string;
|
|
15
|
-
playgroundDidMount?: string;
|
|
16
|
-
playgroundWillUnmount?: string;
|
|
17
|
-
dependencies?: {
|
|
18
|
-
[key: string]: string;
|
|
19
|
-
};
|
|
20
|
-
devDependencies?: {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
};
|
|
23
|
-
htmlCodeTemplate?: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface TreeItem {
|
|
27
|
-
title?: string;
|
|
28
|
-
value?: string;
|
|
29
|
-
key?: string;
|
|
30
|
-
children?: any;
|
|
31
|
-
icon?: string;
|
|
32
|
-
relativePath?: string;
|
|
33
|
-
filename?: string;
|
|
34
|
-
screenshot?: string;
|
|
35
|
-
node?: any;
|
|
36
|
-
}
|
|
37
2
|
export interface ExampleSiderProps {
|
|
38
3
|
/**
|
|
39
4
|
* 当前 Example (受控)
|