@ray-js/code-sandbox 0.0.3-beta-1 → 0.0.3-beta-3
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/lib/txp/codesandbox/code-editor/index.d.ts +1 -0
- package/lib/txp/codesandbox/code-editor/index.js +16 -12
- package/lib/txp/codesandbox/index.d.ts +6 -0
- package/lib/txp/codesandbox/index.js +14 -2
- package/lib/txp/demo/index.d.ts +2 -0
- package/lib/txp/demo/index.js +6 -3
- package/lib/txp/sandbox/index.d.ts +1 -0
- package/lib/txp/sandbox/index.js +3 -2
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ export interface CodeEditorProps {
|
|
|
7
7
|
height: string;
|
|
8
8
|
txpCode: string;
|
|
9
9
|
baseUri: string;
|
|
10
|
+
isZhLanguage: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare const CodeEditor: React.ForwardRefExoticComponent<CodeEditorProps & React.RefAttributes<{
|
|
12
13
|
monaco: typeof import("monaco-editor");
|
|
@@ -14,7 +14,8 @@ export const CodeEditor = /*#__PURE__*/React.forwardRef((_ref, parentRef) => {
|
|
|
14
14
|
show,
|
|
15
15
|
height,
|
|
16
16
|
txpCode,
|
|
17
|
-
baseUri
|
|
17
|
+
baseUri,
|
|
18
|
+
isZhLanguage = true
|
|
18
19
|
} = _ref;
|
|
19
20
|
const [initloading, setInitLoading] = useState(true);
|
|
20
21
|
const ref = useRef();
|
|
@@ -107,20 +108,23 @@ export const CodeEditor = /*#__PURE__*/React.forwardRef((_ref, parentRef) => {
|
|
|
107
108
|
};
|
|
108
109
|
}, [show]);
|
|
109
110
|
useImperativeHandle(parentRef, () => ref.current);
|
|
111
|
+
const loaderConfig = {
|
|
112
|
+
paths: {
|
|
113
|
+
vs: `${baseUri}/static/txp-static-txp-monaco-editor/min/vs`
|
|
114
|
+
},
|
|
115
|
+
themeUri: `${baseUri}/static/txp-static-txp-monaco-editor/themes/`
|
|
116
|
+
};
|
|
117
|
+
if (isZhLanguage) {
|
|
118
|
+
loaderConfig['vs/nls'] = {
|
|
119
|
+
availableLanguages: {
|
|
120
|
+
'*': 'zh-cn'
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
110
124
|
return /*#__PURE__*/React.createElement(Spin, {
|
|
111
125
|
spinning: initloading
|
|
112
126
|
}, code && /*#__PURE__*/React.createElement(Editor, {
|
|
113
|
-
loaderConfig:
|
|
114
|
-
paths: {
|
|
115
|
-
vs: `${baseUri}/static/txp-static-txp-monaco-editor/min/vs`
|
|
116
|
-
},
|
|
117
|
-
'vs/nls': {
|
|
118
|
-
availableLanguages: {
|
|
119
|
-
'*': 'zh-cn'
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
themeUri: `${baseUri}/static/txp-static-txp-monaco-editor/themes/`
|
|
123
|
-
},
|
|
127
|
+
loaderConfig: loaderConfig,
|
|
124
128
|
theme: "monokai-bright",
|
|
125
129
|
style: {
|
|
126
130
|
height
|
|
@@ -6,6 +6,9 @@ export interface CodeSandboxProps {
|
|
|
6
6
|
txpCode: string;
|
|
7
7
|
pageName: string;
|
|
8
8
|
baseUri: string;
|
|
9
|
+
langKey?: string;
|
|
10
|
+
emptyText?: string;
|
|
11
|
+
isZhLanguage?: boolean;
|
|
9
12
|
}
|
|
10
13
|
export declare const CodeSandbox: React.FC<CodeSandboxProps>;
|
|
11
14
|
export declare const checkShowCodeSandbox: (code: string) => boolean;
|
|
@@ -16,4 +19,7 @@ export declare const CodeSandboxButton: React.FC<{
|
|
|
16
19
|
tooltip?: string;
|
|
17
20
|
pageName: string;
|
|
18
21
|
baseUri: string;
|
|
22
|
+
langKey?: string;
|
|
23
|
+
emptyText?: string;
|
|
24
|
+
isZhLanguage?: boolean;
|
|
19
25
|
}>;
|
|
@@ -13,7 +13,10 @@ export const CodeSandbox = _ref => {
|
|
|
13
13
|
title,
|
|
14
14
|
show,
|
|
15
15
|
pageName = 'playground',
|
|
16
|
-
baseUri
|
|
16
|
+
baseUri,
|
|
17
|
+
langKey,
|
|
18
|
+
emptyText,
|
|
19
|
+
isZhLanguage
|
|
17
20
|
} = _ref;
|
|
18
21
|
const iframeRef = useRef();
|
|
19
22
|
const [ts, setTs] = useState(Date.now());
|
|
@@ -37,6 +40,7 @@ export const CodeSandbox = _ref => {
|
|
|
37
40
|
}
|
|
38
41
|
}, 500), [show]);
|
|
39
42
|
return /*#__PURE__*/React.createElement(Contain, null, /*#__PURE__*/React.createElement(Content, null, /*#__PURE__*/React.createElement(Main, null, /*#__PURE__*/React.createElement(CodeEditor, {
|
|
43
|
+
isZhLanguage: isZhLanguage,
|
|
40
44
|
baseUri: baseUri,
|
|
41
45
|
txpCode: txpCode,
|
|
42
46
|
height: `calc(90vh - 103px + 48px)`,
|
|
@@ -48,6 +52,8 @@ export const CodeSandbox = _ref => {
|
|
|
48
52
|
postCode(newCode);
|
|
49
53
|
}
|
|
50
54
|
})), /*#__PURE__*/React.createElement(Right, null, /*#__PURE__*/React.createElement(Demo, {
|
|
55
|
+
emptyText: emptyText,
|
|
56
|
+
langKey: langKey,
|
|
51
57
|
baseUri: baseUri,
|
|
52
58
|
txpCode: txpCode,
|
|
53
59
|
ts: ts,
|
|
@@ -72,7 +78,10 @@ export const CodeSandboxButton = _ref2 => {
|
|
|
72
78
|
txpCode,
|
|
73
79
|
tooltip = '在线编辑预览效果!',
|
|
74
80
|
pageName,
|
|
75
|
-
baseUri
|
|
81
|
+
baseUri,
|
|
82
|
+
emptyText,
|
|
83
|
+
langKey,
|
|
84
|
+
isZhLanguage
|
|
76
85
|
} = _ref2;
|
|
77
86
|
const [show, setShow] = useState(false);
|
|
78
87
|
const ref = useRef();
|
|
@@ -111,6 +120,9 @@ export const CodeSandboxButton = _ref2 => {
|
|
|
111
120
|
setShow(false);
|
|
112
121
|
}
|
|
113
122
|
}, /*#__PURE__*/React.createElement(CodeSandbox, {
|
|
123
|
+
isZhLanguage: isZhLanguage,
|
|
124
|
+
emptyText: emptyText,
|
|
125
|
+
langKey: langKey,
|
|
114
126
|
baseUri: baseUri,
|
|
115
127
|
txpCode: txpCode,
|
|
116
128
|
pageName: pageName,
|
package/lib/txp/demo/index.d.ts
CHANGED
package/lib/txp/demo/index.js
CHANGED
|
@@ -11,10 +11,12 @@ export const Demo = /*#__PURE__*/React.forwardRef((_ref, parentRef) => {
|
|
|
11
11
|
style,
|
|
12
12
|
ts,
|
|
13
13
|
txpCode,
|
|
14
|
-
baseUri
|
|
14
|
+
baseUri,
|
|
15
|
+
langKey = 'zh',
|
|
16
|
+
emptyText
|
|
15
17
|
} = _ref;
|
|
16
18
|
let path = `${createCompnentUri(baseUri, txpCode, `index.html`)}?t=${ts || Date.now()}`;
|
|
17
|
-
path += `#!/pages/${comId}/index`;
|
|
19
|
+
path += `#!/pages/${comId}/index&langKey=${langKey}`;
|
|
18
20
|
const ref = useRef();
|
|
19
21
|
useImperativeHandle(parentRef, () => ({
|
|
20
22
|
postMsg: data => {
|
|
@@ -49,6 +51,7 @@ export const Demo = /*#__PURE__*/React.forwardRef((_ref, parentRef) => {
|
|
|
49
51
|
src: path,
|
|
50
52
|
style: {
|
|
51
53
|
borderRadius: 0
|
|
52
|
-
}
|
|
54
|
+
},
|
|
55
|
+
emptyText: emptyText
|
|
53
56
|
}));
|
|
54
57
|
});
|
package/lib/txp/sandbox/index.js
CHANGED
|
@@ -5,14 +5,15 @@ export const Sandbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
5
5
|
let {
|
|
6
6
|
src,
|
|
7
7
|
style,
|
|
8
|
-
sandboxId
|
|
8
|
+
sandboxId,
|
|
9
|
+
emptyText = '暂无演示'
|
|
9
10
|
} = _ref;
|
|
10
11
|
const {
|
|
11
12
|
data: hasUri,
|
|
12
13
|
loading
|
|
13
14
|
} = useTestUri(src);
|
|
14
15
|
let content = /*#__PURE__*/React.createElement(SandboxEmpty, {
|
|
15
|
-
description:
|
|
16
|
+
description: emptyText
|
|
16
17
|
});
|
|
17
18
|
if (loading) {
|
|
18
19
|
content = /*#__PURE__*/React.createElement(SandboxSkeleton, {
|