Open 58bcbedf47bd91439c opened 1 year ago
import React, { useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";
export default function App() {
const [code, setCode] = useState('')
const onChange = React.useCallback((value, viewUpdate) => {
console.log("value:", value);
}, []);
setTimeout(() => {
setCode('123')
}, 5000)
return (
<div>
<CodeMirror
value={code}
height="200px"
theme="dark"
extensions={[javascript({ jsx: true })]}
onChange={onChange}
/>
<CodeMirror
value="console.log('hello world!');"
height="200px"
extensions={[javascript({ jsx: true })]}
onChange={(value, viewUpdate) => {
console.log("value:", value);
}}
/>
</div>
);
}
Assuming setTimeout is the initialization interface calling interface, obtain the code of the remote interface
@58bcbedf47bd91439c What's wrong with the example
@58bcbedf47bd91439c What's wrong with the example
Hello, for the first time entering, ctrl+z will clear all content
@58bcbedf47bd91439c This is the system shortcut key "undo previous step" operation. You can disable this shortcut
@58bcbedf47bd91439c This is the system shortcut key "undo previous step" operation. You can disable this shortcut
How to disable it? I couldn't find this setting
@58bcbedf47bd91439c https://codesandbox.io/embed/react-codemirror-example-codemirror-6-https-github-com-uiwjs-react-codemirror-issues-529-srgk4x?fontsize=14&hidenavigation=1&theme=dark
<CodeMirror
value="console.log('hello world!');"
height="200px"
theme="dark"
basicSetup={{
+ history: false
}}
extensions={[javascript({ jsx: true })]}
onChange={onChange}
/>
https://codesandbox.io/embed/react-codemirror-example-codemirror-6-slvju?fontsize=14&hidenavigation=1&theme=dark
Originally posted by @jaywcjlove in https://github.com/uiwjs/react-codemirror/issues/261#issuecomment-1040119334