@ray-js/code-sandbox 0.0.3-beta-1 → 0.0.3-beta-2

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.
@@ -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,8 @@ export interface CodeSandboxProps {
6
6
  txpCode: string;
7
7
  pageName: string;
8
8
  baseUri: string;
9
+ langKey?: string;
10
+ emptyText?: string;
9
11
  }
10
12
  export declare const CodeSandbox: React.FC<CodeSandboxProps>;
11
13
  export declare const checkShowCodeSandbox: (code: string) => boolean;
@@ -16,4 +18,6 @@ export declare const CodeSandboxButton: React.FC<{
16
18
  tooltip?: string;
17
19
  pageName: string;
18
20
  baseUri: string;
21
+ langKey?: string;
22
+ emptyText?: string;
19
23
  }>;
@@ -13,7 +13,9 @@ export const CodeSandbox = _ref => {
13
13
  title,
14
14
  show,
15
15
  pageName = 'playground',
16
- baseUri
16
+ baseUri,
17
+ langKey,
18
+ emptyText
17
19
  } = _ref;
18
20
  const iframeRef = useRef();
19
21
  const [ts, setTs] = useState(Date.now());
@@ -48,6 +50,8 @@ export const CodeSandbox = _ref => {
48
50
  postCode(newCode);
49
51
  }
50
52
  })), /*#__PURE__*/React.createElement(Right, null, /*#__PURE__*/React.createElement(Demo, {
53
+ emptyText: emptyText,
54
+ langKey: langKey,
51
55
  baseUri: baseUri,
52
56
  txpCode: txpCode,
53
57
  ts: ts,
@@ -72,7 +76,9 @@ export const CodeSandboxButton = _ref2 => {
72
76
  txpCode,
73
77
  tooltip = '在线编辑预览效果!',
74
78
  pageName,
75
- baseUri
79
+ baseUri,
80
+ emptyText,
81
+ langKey
76
82
  } = _ref2;
77
83
  const [show, setShow] = useState(false);
78
84
  const ref = useRef();
@@ -111,6 +117,8 @@ export const CodeSandboxButton = _ref2 => {
111
117
  setShow(false);
112
118
  }
113
119
  }, /*#__PURE__*/React.createElement(CodeSandbox, {
120
+ emptyText: emptyText,
121
+ langKey: langKey,
114
122
  baseUri: baseUri,
115
123
  txpCode: txpCode,
116
124
  pageName: pageName,
@@ -6,6 +6,8 @@ export interface DemoProps {
6
6
  ts?: number;
7
7
  txpCode: string;
8
8
  baseUri: string;
9
+ langKey?: string;
10
+ emptyText: string;
9
11
  }
10
12
  export interface DemoRef {
11
13
  postMsg(data: any): void;
@@ -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
  });
@@ -3,5 +3,6 @@ export interface SandboxProps {
3
3
  src: string;
4
4
  style?: React.CSSProperties;
5
5
  sandboxId?: string;
6
+ emptyText?: string;
6
7
  }
7
8
  export declare const Sandbox: React.ForwardRefExoticComponent<SandboxProps & React.RefAttributes<HTMLIFrameElement>>;
@@ -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: "\u6682\u65E0\u6F14\u793A"
16
+ description: emptyText
16
17
  });
17
18
  if (loading) {
18
19
  content = /*#__PURE__*/React.createElement(SandboxSkeleton, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/code-sandbox",
3
- "version": "0.0.3-beta-1",
3
+ "version": "0.0.3-beta-2",
4
4
  "description": "小程序 CodeSandbox 容器",
5
5
  "main": "lib/index",
6
6
  "files": [