Skip to content

Commit 589188a

Browse files
committed
chore: update website example.
1 parent 1aebd4f commit 589188a

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ export default class CodePreview extends React.PureComponent<CodePreviewProps, I
250250
mode: language,
251251
}}
252252
{...editProps}
253-
onChange={(editor) => {
253+
onChange={(editor, change) => {
254254
this.executeCode(editor.getValue());
255+
if (editProps && editProps.onChange) {
256+
editProps.onChange(editor, change)
257+
}
255258
}}
256259
/>
257260
)}

website/Example.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ const Example = () => {
9191
const newstate = { ...state, [`${keyName}`]: e.target.checked };
9292
setState({ ...newstate });
9393
}
94-
console.log('code:', code)
9594
return (
9695
<Fragment>
9796
<CodePreview
@@ -101,8 +100,29 @@ const Example = () => {
101100
noScroll={state.noScroll}
102101
bgWhite={state.bgWhite}
103102
noCode={state.noCode}
103+
editProps={{
104+
onChange: (editor) => {
105+
setCode(editor.getValue())
106+
setState({
107+
...state,
108+
codeSandbox: {
109+
...state.codeSandbox,
110+
files: {
111+
...state.codeSandbox.files,
112+
"src/index.js": {
113+
content: editor.getValue()
114+
},
115+
}
116+
},
117+
codePen: {
118+
...state.codePen,
119+
js: editor.getValue()
120+
}
121+
})
122+
}
123+
}}
104124
noPreview={state.noPreview}
105-
codeSandboxOptions={state.codeSandbox}
125+
codeSandboxOptions={state.codeSandboxShow ? state.codeSandbox : undefined}
106126
codePenOption={state.codePenShow ? state.codePen : undefined}
107127
/>
108128
<div>

0 commit comments

Comments
 (0)