mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +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();
|
||||
|
||||
// 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 );
|
||||
|
||||
// Place cursor
|
||||
|
@ -200,7 +200,14 @@ ve.ce.Surface.prototype.onCutCopy = function( e ) {
|
|||
*/
|
||||
ve.ce.Surface.prototype.onPaste = function( e ) {
|
||||
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();
|
||||
|
||||
|
@ -220,12 +227,12 @@ ve.ce.Surface.prototype.onPaste = function( e ) {
|
|||
|
||||
// Transact
|
||||
tx = ve.dm.Transaction.newFromInsertion(
|
||||
_this.documentView.model, insertionPoint, pasteData
|
||||
_this.documentView.model, selection.start, pasteData
|
||||
);
|
||||
ve.dm.TransactionProcessor.commit( _this.documentView.model, tx );
|
||||
|
||||
// Place cursor
|
||||
_this.showCursor( insertionPoint + pasteData.length );
|
||||
_this.showCursor( selection.start + pasteData.length );
|
||||
_this.documentView.documentNode.$.focus();
|
||||
}, 1 );
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue