@ray-js/code-sandbox 0.0.5 → 0.0.6
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DrawerProps } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { EditorAPI } from '@saber2pr/monaco';
|
|
3
4
|
export interface CodeSandboxProps {
|
|
4
5
|
code: string;
|
|
5
6
|
title: string;
|
|
@@ -10,6 +11,7 @@ export interface CodeSandboxProps {
|
|
|
10
11
|
langKey?: string;
|
|
11
12
|
emptyText?: string;
|
|
12
13
|
isZhLanguage?: boolean;
|
|
14
|
+
editorApi?: EditorAPI;
|
|
13
15
|
}
|
|
14
16
|
export declare const CodeSandbox: React.FC<CodeSandboxProps>;
|
|
15
17
|
export declare const checkShowCodeSandbox: (code: string) => boolean;
|
|
@@ -25,8 +27,9 @@ export interface UseCodeSandboxDrawerOps {
|
|
|
25
27
|
isZhLanguage?: boolean;
|
|
26
28
|
code: string;
|
|
27
29
|
langKey?: string;
|
|
30
|
+
editorApi?: EditorAPI;
|
|
28
31
|
}
|
|
29
|
-
export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, }: UseCodeSandboxDrawerOps) => {
|
|
32
|
+
export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, editorApi, }: UseCodeSandboxDrawerOps) => {
|
|
30
33
|
modal: React.JSX.Element;
|
|
31
34
|
show: boolean;
|
|
32
35
|
setShow: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -41,4 +44,5 @@ export declare const CodeSandboxButton: React.FC<{
|
|
|
41
44
|
baseUri: string;
|
|
42
45
|
emptyText?: string;
|
|
43
46
|
isZhLanguage?: boolean;
|
|
47
|
+
editorApi?: EditorAPI;
|
|
44
48
|
}>;
|
|
@@ -19,11 +19,12 @@ export const CodeSandbox = _ref => {
|
|
|
19
19
|
baseUri,
|
|
20
20
|
langKey,
|
|
21
21
|
emptyText,
|
|
22
|
-
isZhLanguage
|
|
22
|
+
isZhLanguage,
|
|
23
|
+
editorApi
|
|
23
24
|
} = _ref;
|
|
24
25
|
const iframeRef = useRef();
|
|
25
26
|
const [ts, setTs] = useState(Date.now());
|
|
26
|
-
const apiRef = useRef();
|
|
27
|
+
const apiRef = useRef(editorApi);
|
|
27
28
|
useEffect(() => {
|
|
28
29
|
const handle = event => {
|
|
29
30
|
var _event$data;
|
|
@@ -86,7 +87,8 @@ export const useCodeSandboxDrawer = _ref2 => {
|
|
|
86
87
|
emptyText,
|
|
87
88
|
langKey,
|
|
88
89
|
baseUri,
|
|
89
|
-
code
|
|
90
|
+
code,
|
|
91
|
+
editorApi
|
|
90
92
|
} = _ref2;
|
|
91
93
|
const [show, setShow] = useState(false);
|
|
92
94
|
return {
|
|
@@ -107,6 +109,7 @@ export const useCodeSandboxDrawer = _ref2 => {
|
|
|
107
109
|
setShow(false);
|
|
108
110
|
}
|
|
109
111
|
}, /*#__PURE__*/React.createElement(CodeSandbox, {
|
|
112
|
+
editorApi: editorApi,
|
|
110
113
|
isZhLanguage: isZhLanguage,
|
|
111
114
|
emptyText: emptyText,
|
|
112
115
|
langKey: langKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/code-sandbox",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "小程序 CodeSandbox 容器",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
20
|
-
"build": "patch-package && ray build --type=component",
|
|
20
|
+
"build": "export BROWSERSLIST='Last 3 versions' && patch-package && ray build --type=component",
|
|
21
21
|
"watch": "ray start --type=component --output ./example/src/lib",
|
|
22
22
|
"build:tuya": "ray build ./example",
|
|
23
23
|
"build:wechat": "ray build ./example --target=wechat",
|