| 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: list</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 | var editor = evt.editor; |
| 30 | // Force result data unformatted. |
| 31 | editor.dataProcessor.writer._.rules = {}; |
| 32 | // Force remove tail br. |
| 33 | editor.dataProcessor.htmlFilter.addRules( { |
| 34 | elements : { |
| 35 | 'br' : function( br ){ |
| 36 | var parent = br.parent, |
| 37 | length = parent.children.length, |
| 38 | lastChild = parent.children[ length - 1 ]; |
| 39 | if( lastChild == br ) |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | } ); |
| 44 | callback.call( context, editor ); |
| 45 | } |
| 46 | }, this ); |
| 47 | |
| 48 | mode = mode || CKEDITOR.ELEMENT_MODE_REPLACE; |
| 49 | switch( mode ) |
| 50 | { |
| 51 | case CKEDITOR.ELEMENT_MODE_REPLACE : |
| 52 | CKEDITOR.replace( elementId, config ); |
| 53 | break; |
| 54 | case CKEDITOR.ELEMENT_MODE_APPENDTO : |
| 55 | CKEDITOR.appendTo( elementId, config ); |
| 56 | break; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * IE always returning CRLF for line-feed, so remove it when retrieving |
| 62 | * pre-formated text from text area. |
| 63 | */ |
| 64 | function getTextAreaValue( id ) |
| 65 | { |
| 66 | return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' ); |
| 67 | } |
| 68 | |
| 69 | CKEDITOR.test.addTestCase( ( function() |
| 70 | { |
| 71 | |
| 72 | // Local references. |
| 73 | var assert = CKEDITOR.test.assert, |
| 74 | doc = CKEDITOR.document, |
| 75 | action = YAHOO.util.UserAction, |
| 76 | selector = YAHOO.util.Selector; |
| 77 | |
| 78 | return { |
| 79 | |
| 80 | /** |
| 81 | * Test remove numbered list with 'enterMode = BR'. |
| 82 | */ |
| 83 | test_create_link : function() |
| 84 | { |
| 85 | prepareEditor( 'test_create_link_editor', null, |
| 86 | null, |
| 87 | function( editor ) |
| 88 | { |
| 89 | this.resume( function() |
| 90 | { |
| 91 | editor.focus(); |
| 92 | editor.execCommand( 'link' ); |
| 93 | // waiting for dialog to open. |
| 94 | this.wait( function() |
| 95 | { |
| 96 | var dialog = editor._.storedDialogs[ 'link' ]; |
| 97 | var urlField = dialog.getContentElement( 'info', 'url' ); |
| 98 | urlField.setValue( 'http://svn.fckeditor.net' ); |
| 99 | |
| 100 | dialog.fire( 'ok' ); |
| 101 | dialog.hide(); |
| 102 | |
| 103 | var result = editor.getData(); |
| 104 | assert.areEqual( |
| 105 | '<p><a href="http://svn.fckeditor.net">http://svn.fckeditor.net</a></p>', |
| 106 | result, 'Created link element doesn\'t match.' ); |
| 107 | |
| 108 | }, 1000 ); |
| 109 | } ); |
| 110 | }, this ); |
| 111 | this.wait(); |
| 112 | }, |
| 113 | |
| 114 | name :document.title |
| 115 | }; |
| 116 | } )() ); |
| 117 | //]]> |
| 118 | </script> |
| 119 | </head> |
| 120 | <body> |
| 121 | <textarea id="test_create_link_editor"></textarea> |
| 122 | </body> |
| 123 | </html> |