jenkins-bot has submitted this change and it was merged.

Change subject: Pasted content is annotated
......................................................................


Pasted content is annotated

Applying insertionAnnotations to pasted content.

Change-Id: I8f8a240ae8970624c34ae005290acc77cea73180
---
M modules/ve/ce/ve.ce.Surface.js
M modules/ve/dm/ve.dm.Surface.js
2 files changed, 21 insertions(+), 22 deletions(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 1517f73..865b840 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -629,8 +629,8 @@
        scrollTop = $window.scrollTop();
        this.$pasteTarget.html( '' ).show().focus();
 
-       setTimeout( function () {
-               var pasteText, pasteData, tx,
+       setTimeout( ve.bind( function () {
+               var pasteData, slice, tx,
                        key = '';
 
                // Create key from text and element names
@@ -641,26 +641,25 @@
 
                // Get linear model from clipboard or create array from unknown 
pasted content
                if ( view.clipboard[key] ) {
-                       pasteData = view.clipboard[key];
+                       slice = view.clipboard[key];
                } else {
-                       pasteText = view.$pasteTarget.text().replace( /\n/gm, 
'' );
-                       pasteData = new ve.dm.DocumentSlice( ve.splitClusters( 
pasteText ) );
+                       slice = new ve.dm.DocumentSlice(
+                               ve.splitClusters(
+                                       view.$pasteTarget.text().replace( 
/\n/gm, '' )
+                               )
+                       );
                }
+               pasteData = slice.getBalancedData();
 
-               // Transact
-               try {
-                       tx = ve.dm.Transaction.newFromInsertion(
-                               view.documentView.model,
-                               selection.start,
-                               pasteData.getData()
-                       );
-               } catch ( e ) {
-                       tx = ve.dm.Transaction.newFromInsertion(
-                               view.documentView.model,
-                               selection.start,
-                               pasteData.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
                view.documentView.documentNode.$.focus();
@@ -673,7 +672,7 @@
 
                // Allow pasting again
                view.pasting = false;
-       } );
+       }, this ) );
 };
 
 /**
@@ -1247,7 +1246,7 @@
        if ( !rangeToRemove.isCollapsed() ) {
                // If after processing removal transaction range is not 
collapsed it means that not
                // everything got merged nicely (at this moment transaction 
processor is capable of merging
-               // nodes of the same type and at the same depth level only), so 
we process with another 
+               // nodes of the same type and at the same depth level only), so 
we process with another
                // merging that takes remaing data from "endNode" and inserts 
it at the end of "startNode",
                // "endNode" or recrusivly its parent (if have only one child) 
gets removed.
                endNode = this.documentView.getNodeFromOffset( 
rangeToRemove.end, false );
diff --git a/modules/ve/dm/ve.dm.Surface.js b/modules/ve/dm/ve.dm.Surface.js
index 7a5462e..95d214d 100644
--- a/modules/ve/dm/ve.dm.Surface.js
+++ b/modules/ve/dm/ve.dm.Surface.js
@@ -149,7 +149,7 @@
  * Get annotations that will be used upon insertion.
  *
  * @method
- * @returns {ve.dm.AnnotationSet|null} Insertion anotations or null if not 
being used
+ * @returns {ve.dm.AnnotationSet} Insertion anotations
  */
 ve.dm.Surface.prototype.getInsertionAnnotations = function () {
        return this.insertionAnnotations.clone();

-- 
To view, visit https://gerrit.wikimedia.org/r/70924
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8f8a240ae8970624c34ae005290acc77cea73180
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Christian <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to