@ray-js/code-sandbox 0.0.7-beta-12 → 0.0.7-beta-14
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,4 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
/* eslint-disable no-await-in-loop */
|
|
2
3
|
import { Skeleton } from 'antd';
|
|
3
4
|
import React, { useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
5
|
import { getComponentResource } from '../../services';
|
|
@@ -107,22 +108,16 @@ export const CodeEditor = /*#__PURE__*/React.forwardRef((_ref, parentRef) => {
|
|
|
107
108
|
};
|
|
108
109
|
}, [show, fileName]);
|
|
109
110
|
useEffect(() => {
|
|
110
|
-
|
|
111
|
+
return () => {
|
|
111
112
|
const api = ref.current;
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
model.dispose();
|
|
117
|
-
}
|
|
113
|
+
if (api) {
|
|
114
|
+
const model = api.getModel();
|
|
115
|
+
if (model) {
|
|
116
|
+
model.dispose();
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
};
|
|
121
|
-
|
|
122
|
-
return () => {
|
|
123
|
-
destroyOnClose();
|
|
124
|
-
};
|
|
125
|
-
}, [show]);
|
|
120
|
+
}, []);
|
|
126
121
|
useImperativeHandle(parentRef, () => ref.current);
|
|
127
122
|
const loaderConfig = {
|
|
128
123
|
paths: {
|
|
@@ -36,8 +36,9 @@ export interface UseCodeSandboxDrawerOps {
|
|
|
36
36
|
styMap?: any;
|
|
37
37
|
cssParse?: (css: string) => Promise<string>;
|
|
38
38
|
noTypeInit?: boolean;
|
|
39
|
+
extra?: React.ReactNode;
|
|
39
40
|
}
|
|
40
|
-
export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, editorApi, cssCode, styMap, cssParse, noTypeInit, }: UseCodeSandboxDrawerOps) => {
|
|
41
|
+
export declare const useCodeSandboxDrawer: ({ getContainer, title, height, placement, isZhLanguage, pageName, txpCode, emptyText, langKey, baseUri, code, editorApi, cssCode, styMap, cssParse, noTypeInit, extra, }: UseCodeSandboxDrawerOps) => {
|
|
41
42
|
modal: React.JSX.Element;
|
|
42
43
|
show: boolean;
|
|
43
44
|
setShow: React.Dispatch<React.SetStateAction<boolean>>;
|
|
@@ -58,4 +59,5 @@ export declare const CodeSandboxButton: React.FC<{
|
|
|
58
59
|
styMap?: any;
|
|
59
60
|
noTypeInit?: boolean;
|
|
60
61
|
cssParse?: (css: string) => Promise<string>;
|
|
62
|
+
extra?: React.ReactNode;
|
|
61
63
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
const _excluded = ["tooltip", "buttonProps"];
|
|
4
|
+
const _excluded = ["tooltip", "buttonProps", "extra"];
|
|
5
5
|
/* eslint-disable react/self-closing-comp */
|
|
6
6
|
import { Button, Drawer, Tooltip } from 'antd';
|
|
7
7
|
import _ from 'lodash';
|
|
@@ -138,7 +138,8 @@ export const useCodeSandboxDrawer = _ref2 => {
|
|
|
138
138
|
cssCode,
|
|
139
139
|
styMap,
|
|
140
140
|
cssParse,
|
|
141
|
-
noTypeInit
|
|
141
|
+
noTypeInit,
|
|
142
|
+
extra
|
|
142
143
|
} = _ref2;
|
|
143
144
|
const [show, setShow] = useState(false);
|
|
144
145
|
return {
|
|
@@ -152,6 +153,7 @@ export const useCodeSandboxDrawer = _ref2 => {
|
|
|
152
153
|
style: {
|
|
153
154
|
padding: 0
|
|
154
155
|
},
|
|
156
|
+
extra: extra,
|
|
155
157
|
placement: placement,
|
|
156
158
|
destroyOnClose: true,
|
|
157
159
|
open: show,
|
|
@@ -181,12 +183,14 @@ export const useCodeSandboxDrawer = _ref2 => {
|
|
|
181
183
|
export const CodeSandboxButton = _ref3 => {
|
|
182
184
|
let {
|
|
183
185
|
tooltip,
|
|
184
|
-
buttonProps
|
|
186
|
+
buttonProps,
|
|
187
|
+
extra
|
|
185
188
|
} = _ref3,
|
|
186
189
|
props = _objectWithoutProperties(_ref3, _excluded);
|
|
187
190
|
const api = useCodeSandboxDrawer(_objectSpread(_objectSpread({}, props), {}, {
|
|
188
191
|
height: '90vh',
|
|
189
|
-
getContainer: () => ref.current
|
|
192
|
+
getContainer: () => ref.current,
|
|
193
|
+
extra
|
|
190
194
|
}));
|
|
191
195
|
const ref = useRef();
|
|
192
196
|
return /*#__PURE__*/React.createElement(DrawerContain, {
|