@antv/dumi-theme-antv 0.3.0-beta.12 → 0.3.0-beta.13

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.
@@ -133,10 +133,12 @@ export var CodeEditor = function CodeEditor(_ref) {
133
133
 
134
134
 
135
135
  execute(compiled, containerId, playground === null || playground === void 0 ? void 0 : playground.container, replaceId);
136
- }, 300), [containerId, currentEditorTab]);
136
+ }, 300), [exampleId, currentEditorTab]); // 案例变化的时候,修改期待吗
137
+
137
138
  useEffect(function () {
138
139
  setCode(source);
139
- }, [source]);
140
+ }, [exampleId]); // 代码变化的时候,运行代码
141
+
140
142
  useEffect(function () {
141
143
  executeCode(code);
142
144
  }, [code]);
@@ -149,6 +151,12 @@ export var CodeEditor = function CodeEditor(_ref) {
149
151
  }, 100));
150
152
  }
151
153
 
154
+ return function () {
155
+ dom && clear(dom);
156
+ };
157
+ }, []); // 生命周期
158
+
159
+ useEffect(function () {
152
160
  onReady();
153
161
 
154
162
  if (playground !== null && playground !== void 0 && playground.playgroundDidMount) {
@@ -156,7 +164,6 @@ export var CodeEditor = function CodeEditor(_ref) {
156
164
  }
157
165
 
158
166
  return function () {
159
- dom && clear(dom);
160
167
  onDestroy();
161
168
 
162
169
  if (playground !== null && playground !== void 0 && playground.playgroundWillUnmount) {
@@ -175,16 +182,22 @@ export var CodeEditor = function CodeEditor(_ref) {
175
182
  setEditorTabs([EDITOR_TABS.JAVASCRIPT, EDITOR_TABS.DATA]);
176
183
  setData(data);
177
184
  });
185
+ } else {
186
+ setEditorTabs([EDITOR_TABS.JAVASCRIPT]);
178
187
  }
179
- }, []);
180
- useEffect(function () {
181
- if (monacoRef.current) {
182
- var v = currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2);
183
- monacoRef.current.setValue(v);
184
- }
185
- }, [currentEditorTab]);
186
- var onCodeChange = useCallback(function (value) {
187
- if (currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
188
+ }, [exampleId]); // 切换 tab
189
+
190
+ var onTabChange = useCallback(function (tab) {
191
+ setCurrentEditorTab(tab);
192
+ }, [exampleId]); // useEffect(() => {
193
+ // if (monacoRef.current) {
194
+ // const v = currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2);
195
+ // monacoRef.current.setValue(v);
196
+ // }
197
+ // }, [currentEditorTab]);
198
+
199
+ var onCodeChange = useCallback(function (value, event) {
200
+ if (!event.isFlush && currentEditorTab === EDITOR_TABS.JAVASCRIPT) {
188
201
  setCode(value);
189
202
  }
190
203
  }, [currentEditorTab]);
@@ -202,7 +215,7 @@ export var CodeEditor = function CodeEditor(_ref) {
202
215
  onExecuteCode: function onExecuteCode() {
203
216
  return executeCode(code);
204
217
  },
205
- onEditorTabChange: setCurrentEditorTab,
218
+ onEditorTabChange: onTabChange,
206
219
  onToggleFullscreen: onFullscreen
207
220
  }), /*#__PURE__*/React.createElement("div", {
208
221
  className: styles.monaco,
@@ -210,9 +223,9 @@ export var CodeEditor = function CodeEditor(_ref) {
210
223
  height: 'calc(100% - 36px)'
211
224
  }
212
225
  }, /*#__PURE__*/React.createElement(MonacoEditor, {
213
- language: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? 'javascript' : 'json' // value={currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2)}
226
+ language: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? 'javascript' : 'json',
227
+ value: currentEditorTab === EDITOR_TABS.JAVASCRIPT ? code : JSON.stringify(data, null, 2) // defaultValue={code}
214
228
  ,
215
- defaultValue: code,
216
229
  path: relativePath,
217
230
  loading: /*#__PURE__*/React.createElement(Loading, null),
218
231
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.3.0-beta.12",
3
+ "version": "0.3.0-beta.13",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "types": "dist/types.d.ts",
6
6
  "scripts": {