Changeset 3194
- Timestamp:
- 03/13/09 13:23:49 (4 years ago)
- Location:
- CKEditor/trunk
- Files:
-
- 3 added
- 9 edited
-
_samples/enterkey.html (added)
-
_source/core/config.js (modified) (3 diffs)
-
_source/core/dom/element.js (modified) (4 diffs)
-
_source/core/dom/node.js (modified) (1 diff)
-
_source/core/dom/range.js (modified) (7 diffs)
-
_source/core/dtd.js (modified) (1 diff)
-
_source/core/plugins.js (modified) (1 diff)
-
_source/plugins/enterkey (added)
-
_source/plugins/enterkey/plugin.js (added)
-
_source/plugins/keystrokes/plugin.js (modified) (4 diffs)
-
_source/plugins/selection/plugin.js (modified) (3 diffs)
-
ckeditor.pack (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/_source/core/config.js
r3173 r3194 8 8 * default configuration settings. 9 9 */ 10 11 CKEDITOR.ENTER_P = 1; 12 CKEDITOR.ENTER_BR = 2; 13 CKEDITOR.ENTER_DIV = 3; 10 14 11 15 /** … … 96 100 defaultLanguage : 'en', 97 101 98 enterMode : 'p',99 shiftEnterMode : 'br',102 enterMode : CKEDITOR.ENTER_P, 103 shiftEnterMode : CKEDITOR.ENTER_BR, 100 104 101 105 /** … … 148 152 */ 149 153 150 plugins : 'basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,ent ities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,smiley,showblocks,sourcearea,stylescombo,table,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',154 plugins : 'basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,smiley,showblocks,sourcearea,stylescombo,table,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc', 151 155 152 156 /** -
CKEditor/trunk/_source/core/dom/element.js
r3170 r3194 194 194 { 195 195 if ( typeof node == 'string' ) 196 node = new CKEDITOR.dom.element( node );196 node = this.getDocument().createElement( node ); 197 197 198 198 if ( toStart ) … … 206 206 appendHtml : function( html ) 207 207 { 208 var temp = new CKEDITOR.dom.element( 'div', this.getDocument() ); 209 temp.setHtml( html ); 210 temp.moveChildren( this ); 208 if ( !this.$.childNodes.length ) 209 this.setHtml( html ); 210 else 211 { 212 var temp = new CKEDITOR.dom.element( 'div', this.getDocument() ); 213 temp.setHtml( html ); 214 temp.moveChildren( this ); 215 } 211 216 }, 212 217 … … 228 233 else 229 234 this.append( new CKEDITOR.dom.text( text ) ); 235 }, 236 237 appendBogus : function() 238 { 239 var lastChild = this.getLast() ; 240 241 // Ignore empty/spaces text. 242 while ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT && CKEDITOR.tools.rtrim( lastChild.getText() ).length == 0 ) 243 lastChild = lastChild.getPrevious(); 244 245 if ( !lastChild || ( lastChild.is && ( !lastChild.is( 'br' ) || !lastChild.getAttribute( '_cke_bogus' ) ) ) ) 246 { 247 this.append( 248 CKEDITOR.env.opera ? 249 this.getDocument().createText('') : 250 this.getDocument().createElement( 'br', { attributes : { _cke_bogus : 1 } } ) ); 251 } 230 252 }, 231 253 … … 657 679 } 658 680 return false; 681 }, 682 683 isEditable : function() 684 { 685 // Get the element name. 686 var name = this.getName(); 687 688 // Get the element DTD (defaults to span for unknown elements). 689 var dtd = !CKEDITOR.dtd.$nonEditable[ name ] 690 && ( CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span ); 691 692 // In the DTD # == text node. 693 return ( dtd && dtd['#'] ); 659 694 }, 660 695 -
CKEditor/trunk/_source/core/dom/node.js
r3170 r3194 95 95 clone : function( includeChildren ) 96 96 { 97 return new CKEDITOR.dom.node( this.$.cloneNode( includeChildren ) ); 97 var $clone = this.$.cloneNode( includeChildren ); 98 99 if ( this.type == CKEDITOR.NODE_ELEMENT ) 100 { 101 // The "id" attribute should never be cloned to avoid duplication. 102 $clone.removeAttribute( 'id', false ) ; 103 $clone.removeAttribute( '_cke_expando', false ) ; 104 } 105 106 return new CKEDITOR.dom.node( $clone ); 98 107 }, 99 108 -
CKEditor/trunk/_source/core/dom/range.js
r3092 r3194 1096 1096 case CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS: 1097 1097 // DFS backward to get the block/list item boundary at or before the start. 1098 var boundaryNodes = this.getBoundaryNodes(), 1099 startNode = boundaryNodes.startNode, 1100 endNode = boundaryNodes.endNode, 1101 guardFunction = ( unit == CKEDITOR.ENLARGE_BLOCK_CONTENTS ? 1102 CKEDITOR.dom.domWalker.blockBoundary() : 1103 CKEDITOR.dom.domWalker.listItemBoundary() ), 1104 walker = new CKEDITOR.dom.domWalker( startNode ), 1105 data = walker.reverse( guardFunction ), 1098 1099 // Get the boundaries nodes. 1100 var startNode = this.getTouchedStartNode(), 1101 endNode = this.getTouchedEndNode(); 1102 1103 if ( startNode.isBlockBoundary() ) 1104 { 1105 this.setStartAt( startNode, 1106 CKEDITOR.dtd.$empty[ startNode.getName() ] ? 1107 CKEDITOR.POSITION_AFTER_END : 1108 CKEDITOR.POSITION_AFTER_START ); 1109 } 1110 else 1111 { 1112 // Get the function used to check the enlaarging limits. 1113 var guardFunction = ( unit == CKEDITOR.ENLARGE_BLOCK_CONTENTS ? 1114 CKEDITOR.dom.domWalker.blockBoundary() : 1115 CKEDITOR.dom.domWalker.listItemBoundary() ); 1116 1117 // Create the DOM walker, which will traverse the DOM. 1118 var walker = new CKEDITOR.dom.domWalker( startNode ); 1119 1120 // Go walk in reverse sense. 1121 var data = walker.reverse( guardFunction ); 1122 1123 var boundaryEvent = data.events.shift(); 1124 1125 this.setStartBefore( boundaryEvent.from ); 1126 } 1127 1128 if ( endNode.isBlockBoundary() ) 1129 { 1130 this.setEndAt( endNode, 1131 CKEDITOR.dtd.$empty[ startNode.getName() ] ? 1132 CKEDITOR.POSITION_BEFORE_START : 1133 CKEDITOR.POSITION_BEFORE_END ); 1134 } 1135 else 1136 { 1137 // DFS forward to get the block/list item boundary at or before the end. 1138 walker.setNode( endNode ); 1139 data = walker.forward( guardFunction ); 1106 1140 boundaryEvent = data.events.shift(); 1107 1141 1108 this.setStartBefore( boundaryEvent.from ); 1109 1110 // DFS forward to get the block/list item boundary at or before the end. 1111 walker.setNode( endNode ); 1112 data = walker.forward( guardFunction ); 1113 boundaryEvent = data.events.shift(); 1114 1115 this.setEndAfter( boundaryEvent.from ); 1116 break; 1117 1118 default: 1142 this.setEndAfter( boundaryEvent.from ); 1143 } 1119 1144 } 1120 1145 }, … … 1282 1307 }, 1283 1308 1284 // TODO: Does not add bogus <br> to empty fixed blocks.1285 1309 fixBlock : function( isStart, blockTag ) 1286 1310 { 1287 1311 var bookmark = this.createBookmark(), 1288 fixedBlock = new CKEDITOR.dom.element( blockTag, this.document ); 1312 fixedBlock = this.document.createElement( blockTag ); 1313 1289 1314 this.collapse( isStart ); 1315 1290 1316 this.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS ); 1317 1291 1318 this.extractContents().appendTo( fixedBlock ); 1292 1319 fixedBlock.trim(); 1320 1321 if ( !CKEDITOR.env.ie ) 1322 fixedBlock.appendBogus(); 1323 1293 1324 this.insertNode( fixedBlock ); 1325 1294 1326 this.moveToBookmark( bookmark ); 1327 1295 1328 return fixedBlock; 1296 1329 }, … … 1298 1331 splitBlock : function( blockTag ) 1299 1332 { 1300 var startPath = new CKEDITOR.dom.elementPath( this.startContainer ), 1301 endPath = new CKEDITOR.dom.elementPath( this.endContainer ), 1302 startBlockLimit = startPath.blockLimit, 1303 endBlockLimit = endPath.blockLimit, 1304 startBlock = startPath.block, 1305 endBlock = endPath.block, 1306 elementPath = null; 1307 1333 var startPath = new CKEDITOR.dom.elementPath( this.startContainer ), 1334 endPath = new CKEDITOR.dom.elementPath( this.endContainer ); 1335 1336 var startBlockLimit = startPath.blockLimit, 1337 endBlockLimit = endPath.blockLimit; 1338 1339 var startBlock = startPath.block, 1340 endBlock = endPath.block; 1341 1342 var elementPath = null; 1343 1344 // Do nothing if the boundaries are in different block limits. 1308 1345 if ( !startBlockLimit.equals( endBlockLimit ) ) 1309 1346 return null; … … 1315 1352 { 1316 1353 startBlock = this.fixBlock( true, blockTag ); 1317 endBlock = new CKEDITOR.dom.elementPath( this.endContainer ) ;1354 endBlock = new CKEDITOR.dom.elementPath( this.endContainer ).block; 1318 1355 } 1319 1356 … … 1353 1390 // Duplicate the block element after it. 1354 1391 endBlock = startBlock.clone( false ); 1355 endBlock.removeAttribute( 'id' );1356 1392 1357 1393 // Place the extracted contents into the duplicated block. … … 1360 1396 this.moveToPosition( startBlock, CKEDITOR.POSITION_AFTER_END ); 1361 1397 1362 // TODO: Append bogus br to startBlock for Gecko 1398 // In Gecko, the last child node must be a bogus <br>. 1399 // Note: bogus <br> added under <ul> or <ol> would cause 1400 // lists to be incorrectly rendered. 1401 if ( !CKEDITOR.env.ie && !startBlock.is( 'ul', 'ol') ) 1402 startBlock.appendBogus() ; 1363 1403 } 1364 1404 } … … 1419 1459 1420 1460 return !walker.checkFailed; 1461 }, 1462 1463 /** 1464 * Moves the range boundaries to the first editing point inside an 1465 * element. For example, in an element tree like 1466 * "<p><b><i></i></b> Text</p>", the start editing point is 1467 * "<p><b><i>^</i></b> Text</p>" (inside <i>). 1468 * @param {CKEDITOR.dom.element} targetElement The element into which 1469 * look for the editing spot. 1470 */ 1471 moveToElementEditStart : function( targetElement ) 1472 { 1473 var editableElement; 1474 1475 while ( targetElement && targetElement.type == CKEDITOR.NODE_ELEMENT ) 1476 { 1477 if ( targetElement.isEditable() ) 1478 editableElement = targetElement; 1479 else if ( editableElement ) 1480 break ; // If we already found an editable element, stop the loop. 1481 1482 targetElement = targetElement.getFirst(); 1483 } 1484 1485 if ( editableElement ) 1486 this.moveToPosition( editableElement, CKEDITOR.POSITION_AFTER_START ); 1487 }, 1488 1489 getTouchedStartNode : function() 1490 { 1491 var container = this.startContainer ; 1492 1493 if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT ) 1494 return container ; 1495 1496 return container.getChild( this.startOffset ) || container ; 1497 }, 1498 1499 getTouchedEndNode : function() 1500 { 1501 var container = this.endContainer ; 1502 1503 if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT ) 1504 return container ; 1505 1506 return container.getChild[ this.endOffset - 1 ] || container ; 1421 1507 } 1422 1508 }; -
CKEditor/trunk/_source/core/dtd.js
r2948 r3194 80 80 81 81 /** 82 * Elements that accept text nodes, but are not possible to edit into 83 * the browser. 84 * @type Object 85 * @example 86 */ 87 $nonEditable : {applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1}, 88 89 /** 82 90 * List of elements that can be ignored if empty, like "b" or "span". 83 91 * @type Object 84 92 * @example 85 93 */ 86 $removeEmpty : {abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,d fn:1,em:1,font:1,i:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1},94 $removeEmpty : {abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1}, 87 95 88 96 /** -
CKEditor/trunk/_source/core/plugins.js
r3113 r3194 18 18 '_source/' + // %REMOVE_LINE% 19 19 'plugins/', 'plugin' ); 20 21 // PACKAGER_RENAME( CKEDITOR.plugins ) 20 22 21 23 CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function( originalLoad ) -
CKEditor/trunk/_source/plugins/keystrokes/plugin.js
r3085 r3194 16 16 */ 17 17 editor.keystrokeHandler = new CKEDITOR.keystrokeHandler( editor ); 18 19 editor.specialKeys = {}; 18 20 }, 19 21 … … 85 87 var keyCombination = event.getKeystroke(); 86 88 var command = this.keystrokes[ keyCombination ]; 89 var editor = this._.editor; 87 90 88 cancel = ( this._.editor.fire( 'key', { keyCode : keyCombination } ) === true );91 cancel = ( editor.fire( 'key', { keyCode : keyCombination } ) === true ); 89 92 90 93 if ( !cancel ) … … 93 96 { 94 97 var data = { from : 'keystrokeHandler' }; 95 cancel = ( this._.editor.execCommand( command, data ) !== false );98 cancel = ( editor.execCommand( command, data ) !== false ); 96 99 } 97 100 98 if ( !cancel ) 99 cancel = !!this.blockedKeystrokes[ keyCombination ]; 101 if ( !cancel ) 102 { 103 var handler = editor.specialKeys[ keyCombination ], 104 cancel = ( handler && handler( editor ) === true ); 105 106 if ( !cancel ) 107 cancel = !!this.blockedKeystrokes[ keyCombination ]; 108 } 100 109 } 101 110 … … 167 176 [ CKEDITOR.CTRL + 89 /*Y*/, 'redo' ], 168 177 [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/, 'redo' ], 178 169 179 [ CKEDITOR.CTRL + 76 /*L*/, 'link' ], 180 170 181 [ CKEDITOR.CTRL + 66 /*B*/, 'bold' ], 171 182 [ CKEDITOR.CTRL + 73 /*I*/, 'italic' ], 172 [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ], 173 [ CKEDITOR.CTRL + CKEDITOR.ALT + 13 /*ENTER*/, 'fitWindow' ], 174 [ CKEDITOR.SHIFT + 32 /*SPACE*/, 'nbsp' ] 183 [ CKEDITOR.CTRL + 85 /*U*/, 'underline' ] 175 184 ]; -
CKEditor/trunk/_source/plugins/selection/plugin.js
r3174 r3194 699 699 else 700 700 { 701 isStartMakerAlone = ( !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) 702 && !startNode.hasNext(); 701 // The isStartMakerAlone logic comes from V2. It guarantees that the lines 702 // will expand and that the cursor will be blinking on the right place. 703 // Actually, we are using this flag just to avoid using this hack in all 704 // situations, but just on those needed. 705 706 // But, in V3, somehow it is not interested on working whe hitting SHIFT+ENTER 707 // inside text. So, let's jsut leave the hack happen always. 708 709 // I'm still leaving the code here just in case. We may find some other IE 710 // weirdness and uncommenting this stuff may be useful. 711 712 // isStartMakerAlone = ( !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) 713 // && !startNode.hasNext(); 703 714 704 715 // Append a temporary <span></span> before the selection. … … 711 722 dummySpan.insertBefore( startNode ); 712 723 713 if ( isStartMakerAlone )714 {724 // if ( isStartMakerAlone ) 725 // { 715 726 // To expand empty blocks or line spaces after <br>, we need 716 727 // instead to have any char, which will be later deleted using the 717 728 // selection. 718 // \ufeff = Zero Width No-Break Space (U+FEFF). See #1359.729 // \ufeff = Zero Width No-Break Space (U+FEFF). (#1359) 719 730 this.document.createText( '\ufeff' ).insertBefore( startNode ); 720 }731 // } 721 732 } 722 733 … … 727 738 if ( collapsed ) 728 739 { 729 if ( isStartMakerAlone )730 {731 // Move the selection start to include the temporary .732 //ieRange.moveStart( 'character', -1 );740 // if ( isStartMakerAlone ) 741 // { 742 // Move the selection start to include the temporary \ufeff. 743 ieRange.moveStart( 'character', -1 ); 733 744 734 745 ieRange.select(); 735 746 736 747 // Remove our temporary stuff. 737 //this.document.$.selection.clear();738 }739 else740 ieRange.select();748 this.document.$.selection.clear(); 749 // } 750 // else 751 // ieRange.select(); 741 752 742 753 dummySpan.remove(); -
CKEditor/trunk/ckeditor.pack
r3172 r3194 30 30 'CKEDITOR.POSITION_IS_CONTAINED' : 8, 31 31 'CKEDITOR.POSITION_CONTAINS' : 16, 32 'CKEDITOR.ENTER_P' : 1, 33 'CKEDITOR.ENTER_BR' : 2, 34 'CKEDITOR.ENTER_DIV' : 3, 32 35 'CKEDITOR.TRISTATE_ON' : 1, 33 36 'CKEDITOR.TRISTATE_OFF' : 2, … … 127 130 '_source/plugins/contextmenu/plugin.js', 128 131 '_source/plugins/elementspath/plugin.js', 132 '_source/plugins/enterkey/plugin.js', 133 '_source/plugins/entities/plugin.js', 129 134 '_source/plugins/find/plugin.js', 130 135 '_source/plugins/flash/plugin.js',
Note: See TracChangeset
for help on using the changeset viewer.
