react-codemirror icon indicating copy to clipboard operation
react-codemirror copied to clipboard

@supunkavinda There is no such problem in the example.

Open 58bcbedf47bd91439c opened this issue 2 years ago • 6 comments

          @supunkavinda There is no such problem in the example.

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

58bcbedf47bd91439c avatar Jun 29 '23 03:06 58bcbedf47bd91439c

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 avatar Jun 29 '23 03:06 58bcbedf47bd91439c

@58bcbedf47bd91439c What's wrong with the example

jaywcjlove avatar Jun 29 '23 06:06 jaywcjlove

@58bcbedf47bd91439c What's wrong with the example

Hello, for the first time entering, ctrl+z will clear all content

58bcbedf47bd91439c avatar Jun 29 '23 06:06 58bcbedf47bd91439c

@58bcbedf47bd91439c This is the system shortcut key "undo previous step" operation. You can disable this shortcut

jaywcjlove avatar Jun 29 '23 08:06 jaywcjlove

@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 avatar Jun 29 '23 09:06 58bcbedf47bd91439c

@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}
/>

jaywcjlove avatar Jun 29 '23 13:06 jaywcjlove