Changeset 2185 for FCKeditor/branches
- Timestamp:
- 2008-07-07 05:21:57 (5 months ago)
- Location:
- FCKeditor/branches/features/div_container
- Files:
-
- 1 added
- 1 removed
- 4 modified
-
editor/dialog/fck_div.html (modified) (3 diffs)
-
editor/fckeditor.html (modified) (1 diff)
-
editor/_source/commandclasses/fckblockcontainercommand.js (deleted)
-
editor/_source/commandclasses/fckblockquotecommand.js (added)
-
editor/_source/internals/fckcommands.js (modified) (1 diff)
-
fckpackager.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/branches/features/div_container/editor/dialog/fck_div.html
r2173 r2185 31 31 var dialog = window.parent ; 32 32 var oEditor = dialog.InnerDialogLoaded() ; 33 var FCK = oEditor.FCK ; 33 34 var FCKLang = oEditor.FCKLang ; 34 35 var FCKBrowserInfo = oEditor.FCKBrowserInfo ; 35 36 var FCKStyles = oEditor.FCKStyles ; 36 37 var FCKElementPath = oEditor.FCKElementPath ; 37 var FCKBlockContainerCommand = oEditor.FCKBlockContainerCommand ; 38 var FCKDomRange = oEditor.FCKDomRange ; 39 var FCKDomTools = oEditor.FCKDomTools ; 40 var FCKDomRangeIterator = oEditor.FCKDomRangeIterator ; 38 41 var AlwaysCreate = dialog.Args().CustomValue ; 42 43 String.prototype.IEquals = function() 44 { 45 var thisUpper = this.toUpperCase() ; 46 47 var aArgs = arguments ; 48 49 // The arguments could also be a single array. 50 if ( aArgs.length == 1 && aArgs[0].pop ) 51 aArgs = aArgs[0] ; 52 53 for ( var i = 0 ; i < aArgs.length ; i++ ) 54 { 55 if ( thisUpper == aArgs[i].toUpperCase() ) 56 return true ; 57 } 58 return false ; 59 } 39 60 40 61 var ActiveEl = null ; … … 121 142 } 122 143 144 function CreateDiv() 145 { 146 var bqBlock ; 147 var range = new FCKDomRange( FCK.EditorWindow ) ; 148 range.MoveToSelection() ; 149 150 var bookmark = range.CreateBookmark() ; 151 152 // Kludge for #1592: if the bookmark nodes are in the beginning of 153 // $tagName, then move them to the nearest block element in the 154 // $tagName. 155 if ( FCKBrowserInfo.IsIE ) 156 { 157 var bStart = range.GetBookmarkNode( bookmark, true ) ; 158 var bEnd = range.GetBookmarkNode( bookmark, false ) ; 159 160 var cursor ; 161 162 if ( bStart 163 && bStart.parentNode.nodeName.IEquals( 'div' ) 164 && !bStart.previousSibling ) 165 { 166 cursor = bStart ; 167 while ( ( cursor = cursor.nextSibling ) ) 168 { 169 if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] ) 170 FCKDomTools.MoveNode( bStart, cursor, true ) ; 171 } 172 } 173 174 if ( bEnd 175 && bEnd.parentNode.nodeName.IEquals( 'div' ) 176 && !bEnd.previousSibling ) 177 { 178 cursor = bEnd ; 179 while ( ( cursor = cursor.nextSibling ) ) 180 { 181 if ( FCKListsLib.BlockElements[ cursor.nodeName.toLowerCase() ] ) 182 { 183 if ( cursor.firstChild == bStart ) 184 FCKDomTools.InsertAfterNode( bStart, bEnd ) ; 185 else 186 FCKDomTools.MoveNode( bEnd, cursor, true ) ; 187 } 188 } 189 } 190 } 191 192 var iterator = new FCKDomRangeIterator( range ) ; 193 var block ; 194 195 if ( true ) 196 { 197 iterator.EnforceRealBlocks = true ; 198 var paragraphs = [] ; 199 while ( ( block = iterator.GetNextParagraph() ) ) 200 paragraphs.push( block ) ; 201 202 // If no paragraphs, create one from the current selection position. 203 if ( paragraphs.length < 1 ) 204 { 205 para = range.Window.document.createElement( FCKConfig.EnterMode.IEquals( 'p' ) ? 'p' : 'div' ) ; 206 range.InsertNode( para ) ; 207 para.appendChild( range.Window.document.createTextNode( '\ufeff' ) ) ; 208 range.MoveToBookmark( bookmark ) ; 209 range.MoveToNodeContents( para ) ; 210 range.Collapse( true ) ; 211 bookmark = range.CreateBookmark() ; 212 paragraphs.push( para ) ; 213 } 214 215 // Make sure all paragraphs have the same parent. 216 var commonParent = paragraphs[0].parentNode ; 217 var tmp = [] ; 218 for ( var i = 0 ; i < paragraphs.length ; i++ ) 219 { 220 block = paragraphs[i] ; 221 commonParent = FCKDomTools.GetCommonParents( block.parentNode, commonParent ).pop() ; 222 } 223 var lastBlock = null ; 224 while ( paragraphs.length > 0 ) 225 { 226 block = paragraphs.shift() ; 227 while ( block.parentNode != commonParent ) 228 block = block.parentNode ; 229 if ( block != lastBlock ) 230 tmp.push( block ) ; 231 lastBlock = block ; 232 } 233 234 // If any of the selected blocks is a $tagName, remove it to prevent nested $tagNames. 235 while ( tmp.length > 0 ) 236 { 237 block = tmp.shift() ; 238 if ( block.nodeName.IEquals( 'div' ) ) 239 { 240 var docFrag = FCKTools.GetElementDocument( block ).createDocumentFragment() ; 241 while ( block.firstChild ) 242 { 243 docFrag.appendChild( block.removeChild( block.firstChild ) ) ; 244 paragraphs.push( docFrag.lastChild ) ; 245 } 246 block.parentNode.replaceChild( docFrag, block ) ; 247 } 248 else 249 paragraphs.push( block ) ; 250 } 251 252 // Now we have all the blocks to be included in a new $tagName node. 253 bqBlock = range.Window.document.createElement( 'div' ) ; 254 commonParent.insertBefore( bqBlock, paragraphs[0] ) ; 255 while ( paragraphs.length > 0 ) 256 { 257 block = paragraphs.shift() ; 258 bqBlock.appendChild( block ) ; 259 } 260 } 261 262 range.MoveToBookmark( bookmark ) ; 263 range.Select() ; 264 265 FCK.Focus() ; 266 FCK.Events.FireEvent( 'OnSelectionChange' ) ; 267 268 return bqBlock ; 269 } 270 123 271 function Ok() 124 272 { … … 126 274 127 275 if ( !ActiveEl ) 128 { 129 var cmd = new FCKBlockContainerCommand( 'div', AlwaysCreate ) ; 130 cmd.Execute() ; 131 ActiveEl = cmd.createdBlock ; 132 } 276 ActiveEl = CreateDiv(); 133 277 134 278 var setValue = function( attrName, inputName ) -
FCKeditor/branches/features/div_container/editor/fckeditor.html
r2102 r2185 156 156 LoadScript( '_source/commandclasses/fckjustifycommands.js' ) ; 157 157 LoadScript( '_source/commandclasses/fckindentcommands.js' ) ; 158 LoadScript( '_source/commandclasses/fckblock containercommand.js' ) ;158 LoadScript( '_source/commandclasses/fckblockquotecommand.js' ) ; 159 159 LoadScript( '_source/commandclasses/fckcorestylecommand.js' ) ; 160 160 LoadScript( '_source/commandclasses/fckremoveformatcommand.js' ) ; -
FCKeditor/branches/features/div_container/editor/_source/internals/fckcommands.js
r2118 r2185 94 94 case 'Indent' : oCommand = new FCKIndentCommand( 'indent', FCKConfig.IndentLength ) ; break ; 95 95 case 'Outdent' : oCommand = new FCKIndentCommand( 'outdent', FCKConfig.IndentLength * -1 ) ; break ; 96 case 'Blockquote' : oCommand = new FCKBlock ContainerCommand( 'blockquote') ; break ;96 case 'Blockquote' : oCommand = new FCKBlockQuoteCommand() ; break ; 97 97 case 'CreateDiv' : oCommand = new FCKDialogCommand( 'CreateDiv', FCKLang.CreateDiv, 'dialog/fck_div.html', 380, 210, null, null, true ) ; break ; 98 98 case 'EditDiv' : oCommand = new FCKDialogCommand( 'EditDiv', FCKLang.EditDiv, 'dialog/fck_div.html', 380, 210, null, null, false ) ; break ; -
FCKeditor/branches/features/div_container/fckpackager.xml
r2102 r2185 131 131 <File path="editor/_source/commandclasses/fckjustifycommands.js" /> 132 132 <File path="editor/_source/commandclasses/fckindentcommands.js" /> 133 <File path="editor/_source/commandclasses/fckblock containercommand.js" />133 <File path="editor/_source/commandclasses/fckblockquotecommand.js" /> 134 134 <File path="editor/_source/commandclasses/fckcorestylecommand.js" /> 135 135 <File path="editor/_source/commandclasses/fckremoveformatcommand.js" /> … … 227 227 <File path="editor/_source/commandclasses/fckjustifycommands.js" /> 228 228 <File path="editor/_source/commandclasses/fckindentcommands.js" /> 229 <File path="editor/_source/commandclasses/fckblock containercommand.js" />229 <File path="editor/_source/commandclasses/fckblockquotecommand.js" /> 230 230 <File path="editor/_source/commandclasses/fckcorestylecommand.js" /> 231 231 <File path="editor/_source/commandclasses/fckremoveformatcommand.js" />