mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-01 01:16:30 +00:00
Support for pasting into a range
Change-Id: I13e29caba4d912db2477a2c3c4edeca5d21d06b4
This commit is contained in:
parent
2bd615c6d2
commit
cf63a2dd36
|
@ -186,7 +186,7 @@ ve.ce.Surface.prototype.onCutCopy = function( e ) {
|
||||||
selection = _this.getSelectionRange();
|
selection = _this.getSelectionRange();
|
||||||
|
|
||||||
// Transact
|
// Transact
|
||||||
var tx = ve.dm.Transaction.newFromRemoval( _this.documentView.model, selection );
|
tx = ve.dm.Transaction.newFromRemoval( _this.documentView.model, selection );
|
||||||
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
||||||
|
|
||||||
// Place cursor
|
// Place cursor
|
||||||
|
@ -200,7 +200,14 @@ ve.ce.Surface.prototype.onCutCopy = function( e ) {
|
||||||
*/
|
*/
|
||||||
ve.ce.Surface.prototype.onPaste = function( e ) {
|
ve.ce.Surface.prototype.onPaste = function( e ) {
|
||||||
var _this = this,
|
var _this = this,
|
||||||
insertionPoint = _this.getSelectionRange().start;
|
selection = this.getSelectionRange(),
|
||||||
|
tx = null;
|
||||||
|
|
||||||
|
// Pasting into a range? Remove first.
|
||||||
|
if (!rangy.getSelection().isCollapsed) {
|
||||||
|
tx = ve.dm.Transaction.newFromRemoval( _this.documentView.model, selection );
|
||||||
|
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
||||||
|
}
|
||||||
|
|
||||||
$('#paste').html('').show().focus();
|
$('#paste').html('').show().focus();
|
||||||
|
|
||||||
|
@ -220,12 +227,12 @@ ve.ce.Surface.prototype.onPaste = function( e ) {
|
||||||
|
|
||||||
// Transact
|
// Transact
|
||||||
tx = ve.dm.Transaction.newFromInsertion(
|
tx = ve.dm.Transaction.newFromInsertion(
|
||||||
_this.documentView.model, insertionPoint, pasteData
|
_this.documentView.model, selection.start, pasteData
|
||||||
);
|
);
|
||||||
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
||||||
|
|
||||||
// Place cursor
|
// Place cursor
|
||||||
_this.showCursor( insertionPoint + pasteData.length );
|
_this.showCursor( selection.start + pasteData.length );
|
||||||
_this.documentView.documentNode.$.focus();
|
_this.documentView.documentNode.$.focus();
|
||||||
}, 1 );
|
}, 1 );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue