mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
paste handler no longer causes fast viewport shift when pasting
This commit is contained in:
parent
13921a0468
commit
f84fc1cbf1
Notes:
Gabriel Wicke
2012-02-27 16:40:01 +00:00
|
@ -157,6 +157,6 @@ include( '../../modules/sandbox/base.php' );
|
|||
<!-- sandbox -->
|
||||
<script src="main.js"></script>
|
||||
|
||||
<div id="paste" contenteditable="true" style="height: 1px; width: 1px; position: absolute; left: -20000px;"></div>
|
||||
<div id="paste" contenteditable="true" style="height: 1px; width: 1px; display: none; opacity: 0; position: absolute;"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -55,19 +55,15 @@ ve.es.Surface = function( $container, model ) {
|
|||
var insertionPoint = _this.getSelection().start;
|
||||
console.log(_this.clipboard);
|
||||
|
||||
var scrollTop = $(window).scrollTop();
|
||||
|
||||
$('#paste').html('');
|
||||
$('#paste').focus();
|
||||
$('#paste').html('').show().css('top', $(window).scrollTop()).css('left', $(window).scrollLeft()).focus();
|
||||
|
||||
setTimeout(function() {
|
||||
var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,"");
|
||||
var key = $('#paste').hide().text().replace(/( |\r\n|\n|\r|\t)/gm,"");
|
||||
|
||||
if (_this.clipboard[key]) {
|
||||
var tx = _this.documentView.model.prepareInsertion( insertionPoint, _this.clipboard[key]);
|
||||
_this.documentView.model.commit(tx);
|
||||
_this.showCursorAt(insertionPoint + _this.clipboard[key].length);
|
||||
$(window).scrollTop(scrollTop);
|
||||
} else {
|
||||
alert('i can only handle copy/paste from hybrid surface. sorry. :(');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue