firepad icon indicating copy to clipboard operation
firepad copied to clipboard

Drag/Drop on CodeMirror

Open q-state opened this issue 10 years ago • 4 comments

Hi,

Is this something that is being looked at/re-enabled?

q-state avatar May 31 '15 17:05 q-state

I haven't looked at it recently.

You could try commenting out the line:

// Don't allow drag/drop because it causes issues.  See https://github.com/firebase/firepad/issues/36
utils.on(editorWrapper, 'dragstart', utils.stopEvent);

in lib/firepad.js, rebuilding firepad (grunt build) and see how it works for you. It seems like last time I tried it, there were still bugs but I don't recall the details. Sorry.

mikelehen avatar Jun 01 '15 15:06 mikelehen

Affects Ace also.

adamjimenez avatar Jan 15 '16 09:01 adamjimenez

Happy to accept a PR to limit the change to CodeMirror only if this is affecting folks using Ace.

mikelehen avatar Jan 15 '16 16:01 mikelehen

im testing this cm.on("beforeChange", function(, change) { if (change.origin == "dragstart") change.cancel() if (change.origin == "dragenter") change.cancel() if (change.origin == "dragover") change.cancel() if (change.origin == "drop") change.cancel() }); cm.on('drop', function(data, e) { console.log(e); var coords = cm.coordsChar({ left: e.x, top: e.y }); var pos = firepad.codeMirror.indexFromPos(coords); var html = firepad.getHtmlFromSelection(); firepad.codeMirror_.replaceSelection('', 'end', '+input'); cm.setCursor(coords); setTimeout(function(){ firepad.insertHtmlAtCursor(html); }, 100); firepad.codeMirror_.focus(); e.preventDefault(); e.stopPropagation(); return false; });

avrahamzvv avatar Dec 27 '19 19:12 avrahamzvv