how do i hide the codemirror caret

Author: mpt-htmlCreated Feb 3, 2025Updated May 12, 2025

again, im working on a github clone except i want to hide the caret shown. how do i do this?

javascript
const c = {
    lineNumbers: true,
    mode: "javascript",
    theme: "csmpt-code", // custom theme
    gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
    lineWrapping: true,
    readOnly: true,
    autoCloseBrackets: {
      pairs: "()[]{}''\"\"``<>",
      triples: "",
      explode: "[]{}()<>",
    },
  };

        const e = CodeMirror.fromTextArea(textArea, c);

// Ensure that the editor is properly initialized
e.refresh(); // Refresh to handle any layout issues

// Focus the editor programmatically after initialization
e.focus(); // Focus the editor

// Set the code content
e.setValue(snippet.code);

// Function to remove 'CodeMirror-focused' class
const removeFocusedClass = () => {
  const wrapper = e.getWrapperElement();
  wrapper.classList.remove('CodeMirror-focused');
};

// Remove class initially
setTimeout(removeFocusedClass, 0);

// Continuously remove the 'CodeMirror-focused' class on focus
e.getWrapperElement().addEventListener('focus', removeFocusedClass, true);