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

Revision: 110908
Author:   christian
Date:     2012-02-08 02:12:21 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
cut support

Modified Paths:
--------------
    trunk/extensions/VisualEditor/demos/ce/main.js
    trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js

Modified: trunk/extensions/VisualEditor/demos/ce/main.js
===================================================================
--- trunk/extensions/VisualEditor/demos/ce/main.js      2012-02-08 01:15:53 UTC 
(rev 110907)
+++ trunk/extensions/VisualEditor/demos/ce/main.js      2012-02-08 02:12:21 UTC 
(rev 110908)
@@ -8,12 +8,76 @@
                                        'content': { 'text': 'Having real-world 
metaphors for objects and actions can make it easier for a user to learn and 
use an interface (some might say that the interface is more natural or 
intuitive), and rapid, incremental feedback allows a user to make fewer errors 
and complete tasks in less time, because they can see the results of an action 
before completing the action, thus evaluating the output and compensating for 
mistakes.' }
                                },
                                {
+                                       'type': 'table',
+                                       'attributes': { 'html/style': 'width: 
300px; float: left; margin: 0 1em 1em 0; border: solid 1px;' },
+                                       'children': [
+                                               {
+                                                       'type': 'tableRow',
+                                                       'children': [
+                                                               {
+                                                                       'type': 
'tableCell',
+                                                                       
'attributes': { 'html/style': 'border: solid 1px;' },
+                                                                       
'children': [
+                                                                               
{
+                                                                               
        'type': 'paragraph',
+                                                                               
        'content': { 'text': 'row 1 & cell 1' }
+                                                                               
}
+                                                                       ]
+                                                               },
+                                                               {
+                                                                       'type': 
'tableCell',
+                                                                       
'attributes': { 'html/style': 'border: solid 1px;' },
+                                                                       
'children': [
+                                                                               
{
+                                                                               
        'type': 'paragraph',
+                                                                               
        'content': { 'text': 'row 1 & cell 2' }
+                                                                               
}
+                                                                       ]
+                                                               }
+                                                       ]
+                                               },
+                                               {
+                                                       'type': 'tableRow',
+                                                       'children': [
+                                                               {
+                                                                       'type': 
'tableCell',
+                                                                       
'attributes': { 'html/style': 'border: solid 1px;' },
+                                                                       
'children': [
+                                                                               
{
+                                                                               
        'type': 'paragraph',
+                                                                               
        'content': { 'text': 'row 2 & cell 1' }
+                                                                               
}
+                                                                       ]
+                                                               },
+                                                               {
+                                                                       'type': 
'tableCell',
+                                                                       
'attributes': { 'html/style': 'border: solid 1px;' },
+                                                                       
'children': [
+                                                                               
{
+                                                                               
        'type': 'paragraph',
+                                                                               
        'content': { 'text': 'row 2 & cell 2' }
+                                                                               
}
+                                                                       ]
+                                                               }
+                                                       ]
+                                               }
+                                       ]
+                               },                              
+                               {
                                        'type': 'paragraph',
                                        'content': { 'text': 'Test 1' }
                                },
                                {
                                        'type': 'paragraph',
                                        'content': { 'text': 'Test 2' }
+                               },
+                               {
+                                       'type': 'paragraph',
+                                       'content': { 'text': 'Having real-world 
metaphors for objects and actions can make it easier for a user to learn and 
use an interface (some might say that the interface is more natural or 
intuitive), and rapid, incremental feedback allows a user to make fewer errors 
and complete tasks in less time, because they can see the results of an action 
before completing the action, thus evaluating the output and compensating for 
mistakes.' }
+                               },
+                               {
+                                       'type': 'paragraph',
+                                       'content': { 'text': 'Having real-world 
metaphors for objects and actions can make it easier for a user to learn and 
use an interface (some might say that the interface is more natural or 
intuitive), and rapid, incremental feedback allows a user to make fewer errors 
and complete tasks in less time, because they can see the results of an action 
before completing the action, thus evaluating the output and compensating for 
mistakes.' }
                                }
                        ]
                },

Modified: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js
===================================================================
--- trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js        
2012-02-08 01:15:53 UTC (rev 110907)
+++ trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js        
2012-02-08 02:12:21 UTC (rev 110908)
@@ -37,27 +37,25 @@
                        _this.paste[key] = ve.copyArray( 
_this.documentView.model.getData( _this.getSelection() ) );
                        
                        if (event.type == 'cut') {
-                               //not supported yet
-                               return;
-                               
-                               var range = _this.getSelection();
-                               if ( range.start != range.end ) {
-                                       event.preventDefault();
-                                       var tx = 
_this.model.getDocument().prepareRemoval( range );
-                                       _this.model.transact( tx );
-                               }
+                               var selection = _this.getSelection();
 
+                               setTimeout(function() {
+                                       var tx = 
_this.model.getDocument().prepareRemoval( selection );
+                                       _this.model.transact( tx );
+                                       _this.showCursorAt(selection.start);
+                               }, 1);
                        }
+                       
                })
                .on('beforepaste paste', function(event) {
-                       var insertionPoint = _this.getSelection().to;
+                       var insertionPoint = _this.getSelection().start;
                        
                        $('#paste').html('');
                        $('#paste').focus();
                        
                        setTimeout(function() {
                                var key = $('#paste').text().replace(/( 
|\r\n|\n|\r|\t)/gm,"");
-                               
+
                                if (_this.paste[key]) {
                                        var tx = 
_this.documentView.model.prepareInsertion( insertionPoint, _this.paste[key]);
                                        _this.documentView.model.commit(tx);


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to