mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-03 02:16:51 +00:00
Merge "When pasting, try to use original range"
This commit is contained in:
commit
4291b2a308
|
@ -718,17 +718,35 @@ ve.ce.Surface.prototype.onPaste = function ( e ) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pasteData = slice.getBalancedData();
|
|
||||||
|
|
||||||
// Annotate
|
try {
|
||||||
ve.dm.Document.addAnnotationsToData( pasteData, this.model.getInsertionAnnotations() );
|
// Try to paste in the orignal data
|
||||||
|
// Take a copy to prevent the data being annotated a second time in the catch block
|
||||||
|
pasteData = ve.copy( slice.getData() );
|
||||||
|
|
||||||
// Transaction
|
// Annotate
|
||||||
tx = ve.dm.Transaction.newFromInsertion(
|
ve.dm.Document.addAnnotationsToData( pasteData, this.model.getInsertionAnnotations() );
|
||||||
view.documentView.model,
|
|
||||||
selection.start,
|
// Transaction
|
||||||
pasteData
|
tx = ve.dm.Transaction.newFromInsertion(
|
||||||
);
|
view.documentView.model,
|
||||||
|
selection.start,
|
||||||
|
pasteData
|
||||||
|
);
|
||||||
|
} catch ( e ) {
|
||||||
|
// If that fails, balance the data before pasting
|
||||||
|
pasteData = slice.getBalancedData();
|
||||||
|
|
||||||
|
// Annotate
|
||||||
|
ve.dm.Document.addAnnotationsToData( pasteData, this.model.getInsertionAnnotations() );
|
||||||
|
|
||||||
|
// Transaction
|
||||||
|
tx = ve.dm.Transaction.newFromInsertion(
|
||||||
|
view.documentView.model,
|
||||||
|
selection.start,
|
||||||
|
pasteData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore focus and scroll position
|
// Restore focus and scroll position
|
||||||
view.documentView.documentNode.$[0].focus();
|
view.documentView.documentNode.$[0].focus();
|
||||||
|
|
Loading…
Reference in a new issue