Skip to content

how do i hide the codemirror caret #7118

@mpt-html

Description

@mpt-html

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

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions