Skip to content
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

Setting editor to "nocursor" readonly mode should still allow c&p #1099

Closed
SoftwareDreamer opened this issue Dec 18, 2012 · 2 comments
Closed

Comments

@SoftwareDreamer
Copy link

As the topic title says: Setting editor to "nocursor" readonly mode should still allow copy&paste operations.

The problem with readOnly : true is, that it implies "writability" for the normal user, as the cursor blinks, which is really confusing. But in "nocursor" mode, copying is suppressed, which is also irritating and not the xpected behavior (at least from me and 2 collegues).

It would be nice to fix that, if it's an unintentional oversight. Thanks!

edit: this is observed the behavior in FF 18 beta and newest Chrome

@marijnh
Copy link
Member

marijnh commented Dec 18, 2012

This is intentional. Nocursor implies no selection. Just use readOnly: true if you want things to be selectable. You can style the cursor to be invisible if you don't want it to show up (use something like .CodeMirror-cursor { display: none !important })

@marijnh marijnh closed this as completed Dec 18, 2012
@dchacke
Copy link

dchacke commented Apr 29, 2016

I came here from Google wondering about the same thing. In case anyone is wondering how to apply this only to some text editors and not all, this worked for me:

var cm = CodeMirror.fromTextArea(htmlElement, { /* options */ });

// Some condition to apply this to only text editors that are meant to be readonly
if (readonly) {
    var $wrapper = $(cm.getWrapperElement());
    $wrapper.addClass('CodeMirror-readonly'); // hides cursor
}

Paired with the following css:

/* Hide cursor in readonly fields */
.CodeMirror-readonly .CodeMirror-cursor {
  display: none !important
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants