| | 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 | * Find the specific UI item by row and column index. |
| | 47 | * @param {Object} editor |
| | 48 | * @param {Object} rowIndex |
| | 49 | * @param {Object} colIndex |
| | 50 | */ |
| | 51 | function getToolbarUIItem( editor, rowIndex, colIndex){ |
| | 52 | return editor.toolbox.toolbars[ rowIndex -1].items[ colIndex-1]; |
| | 53 | } |
| | 54 | |
| | 55 | /** |
| | 56 | * IE always returning CRLF for line-feed, so remove it when retrieving |
| | 57 | * pre-formated text from text area. |
| | 58 | */ |
| | 59 | function getTextAreaValue( id ) |
| | 60 | { |
| | 61 | return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' ); |
| | 62 | } |
| | 63 | |
| | 64 | CKEDITOR.test.addTestCase( ( function() |
| | 65 | { |
| | 66 | |
| | 67 | // Local references. |
| | 68 | var assert = CKEDITOR.test.assert, |
| | 69 | doc = CKEDITOR.document, |
| | 70 | action = YAHOO.util.UserAction, |
| | 71 | selector = YAHOO.util.Selector; |
| | 72 | |
| | 73 | return { |
| | 74 | |
| | 75 | /** |
| | 76 | * Test apply numbered list in table cell. |
| | 77 | */ |
| | 78 | test_applyNumberedList1 : function() |
| | 79 | { |
| | 80 | prepareEditor( 'editor1', null, null, function( editor ) |
| | 81 | { |
| | 82 | this.resume( function() |
| | 83 | { |
| | 84 | editor.focus(); |
| | 85 | var sel = editor.getSelection(); |
| | 86 | sel.selectElement( editor.document.getById( 'listTarget1' ) ); |
| | 87 | |
| | 88 | editor.execCommand( 'numberedlist' ); |
| | 89 | assert.areSame( getTextAreaValue( 'htmlResult1a' ), editor.getData(), |
| | 90 | 'Content after apply list format doesn\'t match.' ); |
| | 91 | |
| | 92 | editor.execCommand( 'numberedlist' ); |
| | 93 | assert.areSame(getTextAreaValue( 'htmlResult1b' ), editor.getData(), |
| | 94 | 'Content after cancel list format doesn\'t match.' ); |
| | 95 | } ); |
| | 96 | }, this ); |
| | 97 | this.wait(); |
| | 98 | }, |
| | 99 | |
| | 100 | name :document.title |
| | 101 | }; |
| | 102 | } )() ); |
| | 103 | //]]> |
| | 104 | </script> |
| | 105 | </head> |
| | 106 | <body> |
| | 107 | <textarea id="editor1" name="editor1"><table><tr><td><div id="listTarget1">text</div></td></tr></table></textarea> |
| | 108 | <textarea id="htmlResult1a"><table> |
| | 109 | <tbody> |
| | 110 | <tr> |
| | 111 | <td> |
| | 112 | <ol> |
| | 113 | <li> |
| | 114 | text</li> |
| | 115 | </ol> |
| | 116 | </td> |
| | 117 | </tr> |
| | 118 | </tbody> |
| | 119 | </table> |
| | 120 | </textarea> |
| | 121 | <textarea id="htmlResult1b"><table> |
| | 122 | <tbody> |
| | 123 | <tr> |
| | 124 | <td> |
| | 125 | <div id="listTarget1"> |
| | 126 | text</div> |
| | 127 | </td> |
| | 128 | </tr> |
| | 129 | </tbody> |
| | 130 | </table> |
| | 131 | </textarea> |
| | 132 | |
| | 133 | </body> |
| | 134 | </html> |