Closed UhMarco closed 1 year ago
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 .swapDoc()
would have been a solution in v5.
What version are you sure you are using?
What version are you sure you are using?
Latest
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 .swapDoc()
in the latest version?
@UhMarco You need to check the CM 6
documentation for this.
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 swapDoc()
would have been what I needed to prevent this from happening and also keep other notes in memory. Is there an equivalent for version 6? I have read through the docs you sent and have not seen something directly similar.
https://discuss.codemirror.net/
@UhMarco Possibility to ask questions to the CM author.
Solved, thanks for your help. https://discuss.codemirror.net/t/swapdoc-v6-equivalent/5973
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?