User:Gryllida/js/pasteWithQuotes.js

mw.loader.using(['mediawiki.api'], function {	"use strict";	function insertTextAtCursor(text) {	    var sel, range, html;	    if (window.getSelection) {	        sel = window.getSelection;	        if (sel.getRangeAt && sel.rangeCount) {	            range = sel.getRangeAt(0);	            range.deleteContents;	            range.insertNode( document.createTextNode(text) );	        }	    } else if (document.selection && document.selection.createRange) {	        document.selection.createRange.text = text;	    }	}	$('.CodeMirror-line').each(function{ this.addEventListener('paste',function (e) { 			var clipboardData, pastedData;			e.stopPropagation; 			e.preventDefault;	    	clipboardData = e.clipboardData || window.clipboardData;	    	pastedData = clipboardData.getData('Text');			pastedData = '"' + pastedData + '"';			insertTextAtCursor(pastedData);		}); }); });