| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <title>Plugin: toolbar</title> |
| 5 | <link rel="stylesheet" type="text/css" href="../../test.css" /> |
| 6 | <script type="text/javascript" src="../../../../ckeditor_source.js"></script> |
| 7 | <script type="text/javascript" src="../../test.js"></script> |
| 8 | <script type="text/javascript"> |
| 9 | //<![CDATA[ |
| 10 | /** |
| 11 | * Load the editor and wait for fully interactable. |
| 12 | * @param {Object} elementId |
| 13 | * @parma {Object} mode |
| 14 | * @param {Object} config |
| 15 | * @param {Object} callback Continuation with {@param editor}. |
| 16 | * @param {Object} context |
| 17 | */ |
| 18 | function prepareEditor( elementId, mode, config, callback, context ) |
| 19 | { |
| 20 | CKEDITOR.on( 'instanceReady', |
| 21 | function( evt ) |
| 22 | { |
| 23 | var isMe = mode == CKEDITOR.ELEMENT_MODE_REPLACE ? |
| 24 | evt.editor.name == elementId |
| 25 | : evt.editor.element.$ == |
| 26 | document.getElementById( elementId ); |
| 27 | if ( isMe ) |
| 28 | { |
| 29 | callback.call( context, evt.editor ); |
| 30 | } |
| 31 | }, this ); |
| 32 | |
| 33 | mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE; |
| 34 | switch( mode ) |
| 35 | { |
| 36 | case CKEDITOR.ELEMENT_MODE_REPLACE : |
| 37 | CKEDITOR.replace( elementId, config ); |
| 38 | break; |
| 39 | case CKEDITOR.ELEMENT_MODE_APPENDTO : |
| 40 | CKEDITOR.appendTo( elementId, config ); |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * IE always returning CRLF for line-feed, so remove it when retrieving |
| 47 | * pre-formated text from text area. |
| 48 | */ |
| 49 | function getTextAreaValue( id ) |
| 50 | { |
| 51 | return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' ); |
| 52 | } |
| 53 | |
| 54 | CKEDITOR.test.addTestCase( ( function() |
| 55 | { |
| 56 | |
| 57 | // Local references. |
| 58 | var assert = CKEDITOR.test.assert, |
| 59 | doc = CKEDITOR.document, |
| 60 | action = YAHOO.util.UserAction, |
| 61 | selector = YAHOO.util.Selector; |
| 62 | |
| 63 | /** |
| 64 | * Set the range with the start/end position specified by the locator, which in form of bookmark2. |
| 65 | * @param {Object} range |
| 66 | * @param {Array} startPosition range start path including offset |
| 67 | * @param {Array|Boolean} endPositoin range end path including offset or is collapsed |
| 68 | */ |
| 69 | function setRange( range, startPosition, endPositoin ) |
| 70 | { |
| 71 | var bm = { |
| 72 | end : null, |
| 73 | start : null, |
| 74 | is2: true, |
| 75 | startOffset : 0, |
| 76 | endoffset : 0 |
| 77 | }; |
| 78 | bm.start = startPosition.slice( 0, startPosition.length - 1 ); |
| 79 | bm.startOffset = startPosition[ startPosition.length -1]; |
| 80 | if( endPositoin === true ) |
| 81 | { |
| 82 | bm.end = bm.start.slice(); |
| 83 | bm.endOffset = bm.startOffset; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | bm.end = endPositoin.slice( 0, endPositoin.length - 1 ); |
| 88 | bm.endOffset = endPositoin[ endPositoin.length -1 ]; |
| 89 | } |
| 90 | range.moveToBookmark( bm ); |
| 91 | } |
| 92 | |
| 93 | return { |
| 94 | |
| 95 | /** |
| 96 | * Test remove numbered list with 'enterMode = BR'. |
| 97 | */ |
| 98 | test_ticket_3151 : function() |
| 99 | { |
| 100 | prepareEditor( 'test_ticket_3151_editor', null, |
| 101 | { enterMode : CKEDITOR.ENTER_BR }, |
| 102 | function( editor ) |
| 103 | { |
| 104 | this.resume( function() |
| 105 | { |
| 106 | editor.focus(); |
| 107 | |
| 108 | // Force result data unformatted. |
| 109 | editor.dataProcessor.writer._.rules = {}; |
| 110 | |
| 111 | var doc = editor.document, |
| 112 | range = new CKEDITOR.dom.range( doc ); |
| 113 | |
| 114 | setRange( range, [ 1, 0, 0, 0, 0 ], true ); |
| 115 | var sel = editor.getSelection(); |
| 116 | sel.selectRanges( [ range ] ); |
| 117 | |
| 118 | // Waiting for 'comand state' effected. |
| 119 | this.wait( function(){ |
| 120 | // Remove list. |
| 121 | editor.execCommand( 'numberedlist' ); |
| 122 | assert.areSame( getTextAreaValue( 'test_ticket_3151_resultContent' ), |
| 123 | editor.getData(), |
| 124 | 'Remove list result not correct.' ); |
| 125 | }, 1000); |
| 126 | |
| 127 | } ); |
| 128 | }, this ); |
| 129 | this.wait(); |
| 130 | }, |
| 131 | |
| 132 | name :document.title |
| 133 | }; |
| 134 | } )() ); |
| 135 | //]]> |
| 136 | </script> |
| 137 | </head> |
| 138 | <body> |
| 139 | <textarea id="test_ticket_3151_editor"><ol><li>text</li></ol></textarea> |
| 140 | <textarea id="test_ticket_3151_resultContent">text</textarea> |
| 141 | </body> |
| 142 | </html> |