Index: trunk/extensions/VisualEditor/demos/ce/main.js |
— | — | @@ -8,12 +8,76 @@ |
9 | 9 | '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.' } |
10 | 10 | }, |
11 | 11 | { |
| 12 | + 'type': 'table', |
| 13 | + 'attributes': { 'html/style': 'width: 300px; float: left; margin: 0 1em 1em 0; border: solid 1px;' }, |
| 14 | + 'children': [ |
| 15 | + { |
| 16 | + 'type': 'tableRow', |
| 17 | + 'children': [ |
| 18 | + { |
| 19 | + 'type': 'tableCell', |
| 20 | + 'attributes': { 'html/style': 'border: solid 1px;' }, |
| 21 | + 'children': [ |
| 22 | + { |
| 23 | + 'type': 'paragraph', |
| 24 | + 'content': { 'text': 'row 1 & cell 1' } |
| 25 | + } |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + 'type': 'tableCell', |
| 30 | + 'attributes': { 'html/style': 'border: solid 1px;' }, |
| 31 | + 'children': [ |
| 32 | + { |
| 33 | + 'type': 'paragraph', |
| 34 | + 'content': { 'text': 'row 1 & cell 2' } |
| 35 | + } |
| 36 | + ] |
| 37 | + } |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + 'type': 'tableRow', |
| 42 | + 'children': [ |
| 43 | + { |
| 44 | + 'type': 'tableCell', |
| 45 | + 'attributes': { 'html/style': 'border: solid 1px;' }, |
| 46 | + 'children': [ |
| 47 | + { |
| 48 | + 'type': 'paragraph', |
| 49 | + 'content': { 'text': 'row 2 & cell 1' } |
| 50 | + } |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + 'type': 'tableCell', |
| 55 | + 'attributes': { 'html/style': 'border: solid 1px;' }, |
| 56 | + 'children': [ |
| 57 | + { |
| 58 | + 'type': 'paragraph', |
| 59 | + 'content': { 'text': 'row 2 & cell 2' } |
| 60 | + } |
| 61 | + ] |
| 62 | + } |
| 63 | + ] |
| 64 | + } |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
12 | 68 | 'type': 'paragraph', |
13 | 69 | 'content': { 'text': 'Test 1' } |
14 | 70 | }, |
15 | 71 | { |
16 | 72 | 'type': 'paragraph', |
17 | 73 | 'content': { 'text': 'Test 2' } |
| 74 | + }, |
| 75 | + { |
| 76 | + 'type': 'paragraph', |
| 77 | + '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.' } |
| 78 | + }, |
| 79 | + { |
| 80 | + 'type': 'paragraph', |
| 81 | + '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.' } |
18 | 82 | } |
19 | 83 | ] |
20 | 84 | }, |
Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.es.Surface.js |
— | — | @@ -37,27 +37,25 @@ |
38 | 38 | _this.paste[key] = ve.copyArray( _this.documentView.model.getData( _this.getSelection() ) ); |
39 | 39 | |
40 | 40 | if (event.type == 'cut') { |
41 | | - //not supported yet |
42 | | - return; |
43 | | - |
44 | | - var range = _this.getSelection(); |
45 | | - if ( range.start != range.end ) { |
46 | | - event.preventDefault(); |
47 | | - var tx = _this.model.getDocument().prepareRemoval( range ); |
48 | | - _this.model.transact( tx ); |
49 | | - } |
| 41 | + var selection = _this.getSelection(); |
50 | 42 | |
| 43 | + setTimeout(function() { |
| 44 | + var tx = _this.model.getDocument().prepareRemoval( selection ); |
| 45 | + _this.model.transact( tx ); |
| 46 | + _this.showCursorAt(selection.start); |
| 47 | + }, 1); |
51 | 48 | } |
| 49 | + |
52 | 50 | }) |
53 | 51 | .on('beforepaste paste', function(event) { |
54 | | - var insertionPoint = _this.getSelection().to; |
| 52 | + var insertionPoint = _this.getSelection().start; |
55 | 53 | |
56 | 54 | $('#paste').html(''); |
57 | 55 | $('#paste').focus(); |
58 | 56 | |
59 | 57 | setTimeout(function() { |
60 | 58 | var key = $('#paste').text().replace(/( |\r\n|\n|\r|\t)/gm,""); |
61 | | - |
| 59 | + |
62 | 60 | if (_this.paste[key]) { |
63 | 61 | var tx = _this.documentView.model.prepareInsertion( insertionPoint, _this.paste[key]); |
64 | 62 | _this.documentView.model.commit(tx); |