New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting cm editor instance and swapping doc #468
Comments
I've realised I was looking at version 5 documentation. What's the version 6 equivalent? For some more context: I'm working on a note taking app and would like a different instance for each note opened, for history and similar purposes. I believe |
What version are you sure you are using? |
Latest |
@UhMarco https://codesandbox.io/embed/react-codemirror-example-codemirror-6-https-github-com-uiwjs-react-codemirror-issues-468-it0dlh?fontsize=14&hidenavigation=1&theme=dark import CodeMirror from "@uiw/react-codemirror";
import { StreamLanguage } from "@codemirror/language";
import { shell } from "@codemirror/legacy-modes/mode/shell";
import { useEffect, useRef } from "react";
const code = `x = 10`;
export default function App() {
const ref = useRef();
useEffect(() => {
console.log("ref:", ref.current);
}, []);
return (
<CodeMirror
ref={ref}
value={code}
height="200px"
readOnly={false}
extensions={[StreamLanguage.define(shell)]}
onChange={(value, viewUpdate) => {
console.log("value:", value);
}}
/>
);
}
`` |
Thanks. What is the equivalent of |
I've been looking but haven't found anything that looks similar... |
@jaywcjlove Perhaps if I give some more context you'll be able to point me in the right direction. The way I'm currently swapping between notes is just by setting the content. If I perform an undo command, the content goes back to the previous note. From my understand |
https://discuss.codemirror.net/ @UhMarco Possibility to ask questions to the CM author. |
Solved, thanks for your help. |
I've seen previous, similar questions but I'm not sure they're providing what I'm after. I'd like an instance of code mirror where I can run methods such as
cm.getDoc()
andcm.swapDoc()
as seen in the documentation here:Could anyone clear this up for me?
The text was updated successfully, but these errors were encountered: