InlineAttachment icon indicating copy to clipboard operation
InlineAttachment copied to clipboard

Drop to the coursor.

Open pahaz opened this issue 9 years ago • 2 comments

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?

pahaz avatar Oct 27 '15 15:10 pahaz

Hi Pahaz,

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

Rovak avatar Oct 27 '15 22:10 Rovak

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.

dae721 avatar Nov 22 '17 17:11 dae721