aloha_src/static/js/plugins/common/paste/lib/paste-plugin.js
/**
	 * Prepare each editable that is created to handle its paste events via the
	 * invisible paste div.
	 *
	 * Bind appropriate events handlers to the given editable element to be
	 * able to intercept paste events target tot it.
	 *
	 *  TODO: Move to paste command?
	 *  http://support.mozilla.com/en-US/kb/Granting%20JavaScript%20access%20to%20the%20clipboard
	 *  https://code.google.com/p/zeroclipboard/
	 *
	 * @param {jQuery.<HTMLElement>} $editable jQuery object containing an
	 *                                         editable DOM element.
	 */
Prepare each editable that is created to handle its paste events via the
invisible paste div.

Bind appropriate events handlers to the given editable element to be
able to intercept paste events target tot it.

Move to paste command.

@param {jQuery.} $editable jQuery object containing an
editable DOM element.
Prepare each editable that is created to handle its paste events via the invisible paste div . Bind appropriate events handlers to the given editable element to be able to intercept paste events target tot it . Move to paste command . @param { jQuery . } $editable jQuery object containing an editable DOM element .
function prepare($editable) {
		var doc = $editable[0].ownerDocument;
		if (isIEorDocModeGreater9(doc)) {
			$editable.bind('beforepaste', function ($event) {
				scrollPositionBeforePaste.x = window.scrollX ||
					document.documentElement.scrollLeft;
				scrollPositionBeforePaste.y = window.scrollY ||
					document.documentElement.scrollTop;
				ieRangeBeforePaste = CopyPaste.getRange();
				redirect(ieRangeBeforePaste, $CLIPBOARD);
				$event.stopPropagation();
			});
		} else {
			$editable.bind('paste', function ($event) {
				scrollPositionBeforePaste.x = window.scrollX ||
					document.documentElement.scrollLeft;
				scrollPositionBeforePaste.y = window.scrollY ||
					document.documentElement.scrollTop;
				var range = CopyPaste.getRange();
				redirect(range, $CLIPBOARD);
				if (IS_IE) {
					$event.preventDefault();
					var tmpRange = document.selection.createRange();
					tmpRange.execCommand('paste');
				}
				onPaste($event, range);
			});
		}
	}
function prepare ( $editable ) { var doc = $editable [ 0 ] . ownerDocument ; if ( isIEorDocModeGreater9 ( doc ) ) { $editable . bind ( 'beforepaste' , function ( $event ) { scrollPositionBeforePaste . x = window . scrollX || document . documentElement . scrollLeft ; scrollPositionBeforePaste . y = window . scrollY || document . documentElement . scrollTop ; ieRangeBeforePaste = CopyPaste . getRange ( ) ; redirect ( ieRangeBeforePaste , $CLIPBOARD ) ; $event . stopPropagation ( ) ; } ) ; } else { $editable . bind ( 'paste' , function ( $event ) { scrollPositionBeforePaste . x = window . scrollX || document . documentElement . scrollLeft ; scrollPositionBeforePaste . y = window . scrollY || document . documentElement . scrollTop ; var range = CopyPaste . getRange ( ) ; redirect ( range , $CLIPBOARD ) ; if ( IS_IE ) { $event . preventDefault ( ) ; var tmpRange = document . selection . createRange ( ) ; tmpRange . execCommand ( 'paste' ) ; } onPaste ( $event , range ) ; } ) ; } }
Prepare each editable that is created to handle its paste events via the
 invisible paste div.
Prepare each editable that is created to handle its paste events via the invisible paste div .
// Clipboard in IE can no be used, because it does not return HTML content, just text // (http://msdn.microsoft.com/en-us/library/ie/ms536436(v=vs.85).aspx). // We relay on range.execCommand('paste') for the paste, but for IE9 and above the pasted content // is treated differently (it replaces '\n' by '<br>').