Hi,
Paste from the clipboard into a CodeMirror (textarea) instance in my application/web page is not working. I have successfully pasted in a standalone (test) page, so it must be something that I am doing in the page. I am using version 5.25.2, and have tested this in Chrome (current - version Version 60.0.3112.113) and Firefox (current - version 55.0.3).
In the page, CodeMirror is instantiated for a jquery dialog window - triggered when a menu selection is made, where the html - containing the textarea used for CodeMirror - is generated dynamically.
ie. (a snippet)
var html = ‘<div id=“node-edit-codemirror-editor-div”>’
+ ‘<textarea id=“node-edit-codemirror-editor” name=“node-edit-codemirror-editor” rows=“2” cols=“50”>’ + template_content + ‘’
+ ‘</div>’;
codemirror_editor = CodeMirror.fromTextArea(document.getElementById(“node-edit-codemirror-editor”), {
mode: {name: “python”,
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 4,
matchBrackets: true,
autoRefresh: true
});
$("#show-template-editor-dialog").dialog(…); – displays the window
Is there any option I should add to enable this?
I tried adding a ‘paste’ listener, but this does nothing - the handler function never gets called
eg.
document.addEventListener(“paste”, onPaste);
function onPaste(e) {
…
}
I also tried a ‘keydown’ handler, which does get called, but has no clipboard data.
Please help. What am I missing?
Colin Goldberg