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

Drop to the coursor. #64

Open
pahaz opened this issue Oct 27, 2015 · 2 comments
Open

Drop to the coursor. #64

pahaz opened this issue Oct 27, 2015 · 2 comments
Assignees
Projects
Milestone

Comments

@pahaz
Copy link

pahaz commented Oct 27, 2015

Hi. We use InlineAttacjment with CodeMirror 5.6.0.

When dropping file to the editor it drop to the previous coursor position (not to the line where we release mouse).

Do you know about this?

Is this a correct behavior?

@Rovak
Copy link
Owner

Rovak commented Oct 27, 2015

Hi Pahaz,

I was not aware of the issue, i will test it out and make a fix when i got the time

@Rovak Rovak added this to the 3.0 milestone Oct 25, 2016
@Rovak Rovak self-assigned this Oct 25, 2016
@dae721
Copy link

dae721 commented Nov 22, 2017

I was able to work around the problem by adding a drop handler which repositions the cursor to the drop location when it detects a file is being dropped. Here's the typescript from our editor subclass, where this.cm is of type CodeMirror.Editor:

this.cm.on('drop', (editor, e: DragEvent) => {
    if (e.dataTransfer.files.length > 0) {
        let pos = this.cm.coordsChar({left: e.clientX, top: e.clientY}, 'window');
        this.cm.getDoc().setCursor(pos);
    }
});

This has to be done before the call to codemirror4.attach() so it gets called before the inlineAttachment drop handler.

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

No branches or pull requests

3 participants