https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113419

Revision: 113419
Author:   catrope
Date:     2012-03-08 23:21:17 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
Add replace operation

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.Transaction.js
    trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js

Modified: trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.Transaction.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.Transaction.js    
2012-03-08 23:02:23 UTC (rev 113418)
+++ trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.Transaction.js    
2012-03-08 23:21:17 UTC (rev 113419)
@@ -89,6 +89,21 @@
 };
 
 /**
+ * Adds a replace operation
+ * 
+ * @method
+ * @param {Array} remove Data to remove
+ * @param {Array] replacement Data to replace 'remove' with
+ */
+ve.dm.Transaction.prototype.pushReplace = function( remove, replacement ) {
+       this.operations.push( {
+               'type': 'replace',
+               'remove': remove,
+               'replacement': replacement
+       } );
+};
+
+/**
  * Adds an element attribute change operation.
  * 
  * @method

Modified: 
trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js   
2012-03-08 23:02:23 UTC (rev 113418)
+++ trunk/extensions/VisualEditor/modules/ve/dm/ve.dm.TransactionProcessor.js   
2012-03-08 23:21:17 UTC (rev 113419)
@@ -42,6 +42,14 @@
                        this.insert( op );
                }
        },
+       'replace': {
+               'commit': function( op ) {
+                       this.replace( op, false );
+               },
+               'rollback': function( op ) {
+                       this.replace( op, true );
+               }
+       },
        // Change element attributes
        'attribute': {
                'commit': function( op ) {
@@ -445,6 +453,10 @@
        }
 };
 
+ve.dm.TransactionProcessor.prototype.replace = function( op, invert ) {
+       // TODO
+};
+
 ve.dm.TransactionProcessor.prototype.attribute = function( op, invert ) {
        var element = this.model.data[this.cursor];
        if ( element.type === undefined ) {


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

Reply via email to