Ticket #4548: 4548_4.patch
File 4548_4.patch, 12.9 KB (added by , 15 years ago) |
---|
-
_source/plugins/drupalpagebreak/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file Insert a Drupal page breakl(fake comment) into the body, split up contents when necessary. 8 */ 9 10 CKEDITOR.plugins.add( 'drupalpagebreak', 11 { 12 init : function( editor ) 13 { 14 editor.addCommand( 'insertDrupalPageBreak', 15 { 16 exec : function( editor ) 17 { 18 var placeholder = CKEDITOR.dom.element.createFromHtml( '<cke:comment></cke:comment>' ), 19 range = new CKEDITOR.dom.range( editor.document ); 20 editor.insertElement( placeholder ); 21 range.selectNodeContents( placeholder ); 22 range.select( true ); 23 editor.insertHtml( '<!--break-->' ); 24 25 } 26 } ); 27 28 editor.ui.addButton( 'DrupalPageBreak', 29 { 30 label : editor.lang.drupalPageBreak, 31 command : 'insertDrupalPageBreak' 32 }); 33 }, 34 35 requires : [ 'fakecomment' ] 36 }); -
_source/plugins/fakecomment/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * @file Comment place holder plugin which create a fake object to represent HTML 8 * comments in certain patterns. 9 */ 10 11 CKEDITOR.plugins.add( 'fakecomment', 12 { 13 requires : [ 'htmldataprocessor','fakeobjects' ], 14 init : function( editor ) 15 { 16 // Add the style that renders our placeholder. 17 editor.addCss( 18 'img.cke_comment' + 19 '{' + 20 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.gif' ) + ');' + 21 '-webkit-background-size: 20px 20px;' + 22 '-o-background-size: 20px 20px;' + 23 'background-position: center center;' + 24 'background-repeat: no-repeat;' + 25 'display: inline;' + 26 'width: 20px;' + 27 'vertical-align: middle;' + 28 'border: #999999 1px dotted;' + 29 '}' ); 30 }, 31 32 // There's currently no gurantee on registration order, this make sure 33 // the registration will come after the default ones in 'htmldataprocessor'. 34 afterInit : function( editor ) 35 { 36 var dataProcessor = editor.dataProcessor, 37 dataFilter = dataProcessor.dataFilter, 38 htmlFilter = dataProcessor.htmlFilter, 39 // Borrow the comment output filters to restore them. 40 commentFilters = htmlFilter._.comment, 41 filter = commentFilters && ( commentFilters.filter || commentFilters[ 0 ] ), 42 config = editor.config, 43 fakeComments = config.fakeComments || [] ; 44 45 if( ! ( fakeComments && fakeComments.length ) ) 46 return; 47 48 var fakeComment, 49 // Used when 'displayName' is not presented in comment definition. 50 defaultDisplayName = 'cke:comment', 51 allFakeWrapperTagNames = {}, 52 allFakeCommentPatterns = []; 53 54 for ( var i = 0; i < fakeComments.length; i++ ) 55 { 56 fakeComment = fakeComments[ i ]; 57 if( fakeComment.displayName ) 58 allFakeWrapperTagNames[ fakeComment.displayName ] = 1; 59 else if( !( defaultDisplayName in allFakeWrapperTagNames ) ) 60 allFakeWrapperTagNames[ defaultDisplayName ] = 1; 61 62 fakeComment.pattern && allFakeCommentPatterns.push( 63 [ fakeComment.pattern, 64 fakeComment.displayName || defaultDisplayName ] ); 65 } 66 67 // Create fake objects for all fake comments. 68 dataFilter.addRules( 69 { 70 comment : function( value ) 71 { 72 var data = filter ? filter( value ) : value, 73 fakeWrapper, fakeElement, 74 pattern, 75 fakeCommentName; 76 77 // Instance of CKEDITOR.htmlParser.cdata is expected. 78 if ( data.value ) 79 { 80 for ( var i = 0; i < allFakeCommentPatterns.length; i++ ) 81 { 82 pattern = allFakeCommentPatterns[ i ]; 83 // Is it actually a comment and match the desired pattern? 84 data.value.replace( /<!--([\s\S]*?)-->/, function( match, content ) 85 { 86 if( content.match( pattern[ 0 ] ) ) 87 { 88 fakeCommentName = pattern[ 1 ]; 89 fakeWrapper = new CKEDITOR.htmlParser.element( fakeCommentName, {} ); 90 fakeWrapper.add( data ); 91 fakeElement = editor.createFakeParserElement( 92 fakeWrapper, 93 'cke_comment cke_fc_' + CKEDITOR.tools.escapeCssSelector( fakeCommentName ), 94 fakeCommentName, 95 false ); 96 97 // Comment content specific style. 98 fakeElement.attributes.style = CKEDITOR.tools.clone( pattern.styles ); 99 allFakeWrapperTagNames[ fakeCommentName ] = 1; 100 } 101 } ); 102 103 if ( fakeElement ) 104 return fakeElement; 105 } 106 } 107 return value; 108 } 109 } ); 110 111 // Reveal the real comments under cover on output. 112 htmlFilter.addRules( 113 { 114 elements : 115 { 116 '$' : function( element ) 117 { 118 // Drop the wrapper element. 119 if ( element.name in allFakeWrapperTagNames ) 120 { 121 delete element.name; 122 } 123 } 124 } 125 } ); 126 127 } 128 } ); 129 130 /** 131 * A list of comment definition which will be converted to fake element in wysiwyg mode. 132 * @name CKEDITOR.config.fakeComments 133 * @type Array 134 * @default [] 135 * @example 136 * CKEDITOR.config.fakeComments = 137 * [ 138 * { 139 * pattern : /^break$/, 140 * styles : 141 * { 142 * display : 'block' 143 * }, 144 * displayName : 'page-break' 145 * } 146 * ]; 147 */ -
_source/plugins/wysiwygarea/plugin.js
58 58 59 59 var element = evt.data, 60 60 elementName = element.getName(), 61 isBlock = CKEDITOR.dtd.$block[ elementName ]; 61 dtd = CKEDITOR.dtd, 62 isBlock = dtd.$block[ elementName ] || !dtd[ elementName ]; 62 63 63 64 var selection = this.getSelection(), 64 65 ranges = selection.getRanges(); … … 84 85 var current, dtd; 85 86 if ( isBlock ) 86 87 { 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 88 while( ( current = range.getCommonAncestor( false, true ) ) 89 && ( dtd = CKEDITOR.dtd[ current.getName() ] ) 90 && !( dtd && dtd [ elementName ] ) ) 91 { 92 // If we're in an empty block which indicate a new paragraph, 93 // simply replace it with the inserting block.(#3664) 94 if ( range.checkStartOfBlock() 95 && range.checkEndOfBlock() ) 96 { 97 range.setStartBefore( current ); 98 range.collapse( true ); 99 current.remove(); 100 } 101 else 102 range.splitBlock(); 103 } 103 104 } 104 105 105 106 // Insert the new node. -
_source/core/dom/elementpath.js
1 /* 1 /* 2 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 4 */ 5 5 6 6 (function() 7 7 { 8 // Elements that may be considered the "Block boundary" in an element path.9 var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,de:1 };10 8 11 9 // Elements that may be considered the "Block limit" in an element path. 12 10 var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1 }; … … 48 46 49 47 if ( !blockLimit ) 50 48 { 51 if ( !block && pathBlockElements[ elementName ])49 if ( !block && e.isBlockBoundary() ) 52 50 block = e; 53 51 54 52 if ( pathBlockLimitElements[ elementName ] ) -
_source/lang/en.js
55 55 unlink : 'Unlink', 56 56 undo : 'Undo', 57 57 redo : 'Redo', 58 drupalPageBreak : 'Drupal Page Break', 58 59 60 59 61 // Common messages and labels. 60 62 common : 61 63 { -
_source/plugins/fakeobjects/plugin.js
5 5 6 6 (function() 7 7 { 8 var htmlFilterRules =9 {10 elements :11 {12 $ : function( element )13 {14 var realHtml = element.attributes._cke_realelement,15 realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ),16 realElement = realFragment && realFragment.children[ 0 ];17 18 if ( realElement )19 {20 // If we have width/height in the element, we must move it into21 // the real element.22 23 var style = element.attributes.style;24 25 if ( style )26 {27 // Get the width from the style.28 var match = /(?:^|\s)width\s*:\s*(\d+)/.exec( style ),29 width = match && match[1];30 31 // Get the height from the style.32 match = /(?:^|\s)height\s*:\s*(\d+)/.exec( style );33 var height = match && match[1];34 35 if ( width )36 realElement.attributes.width = width;37 38 if ( height )39 realElement.attributes.height = height;40 }41 }42 43 return realElement;44 }45 }46 };47 48 8 CKEDITOR.plugins.add( 'fakeobjects', 49 9 { 50 10 requires : [ 'htmlwriter' ], … … 55 15 htmlFilter = dataProcessor && dataProcessor.htmlFilter; 56 16 57 17 if ( htmlFilter ) 58 htmlFilter.addRules( htmlFilterRules ); 59 } 60 }); 18 htmlFilter.addRules( 19 { 20 elements : 21 { 22 $ : CKEDITOR.editor.restoreParserElement 23 } 24 } ); 25 } 26 }); 61 27 })(); 62 28 63 29 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable ) … … 109 75 var html = decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ); 110 76 return CKEDITOR.dom.element.createFromHtml( html, this.document ); 111 77 }; 78 79 CKEDITOR.editor.restoreParserElement = function( fakeElement ) 80 { 81 var realHtml = fakeElement.attributes._cke_realelement, 82 realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ), 83 realElement = realFragment && realFragment.children[ 0 ]; 84 85 if ( realElement ) 86 { 87 // If we have width/height in the fakeElement, we must move it into 88 // the real fakeElement. 89 90 var style = fakeElement.attributes.style; 91 92 if ( style ) 93 { 94 // Get the width from the style. 95 var match = /(?:^|\s)width\s*:\s*(\d+)/.exec( style ), 96 width = match && match[1]; 97 98 // Get the height from the style. 99 match = /(?:^|\s)height\s*:\s*(\d+)/.exec( style ); 100 var height = match && match[1]; 101 102 if ( width ) 103 realElement.attributes.width = width; 104 105 if ( height ) 106 realElement.attributes.height = height; 107 } 108 } 109 110 return realElement; 111 } -
_source/core/htmlparser/fragment.js
107 107 // body (if fixForBody). 108 108 if ( fixForBody && !target.type ) 109 109 { 110 var elementName, realElement Name;110 var elementName, realElement; 111 111 if ( element.attributes 112 && ( realElementName = 113 element.attributes[ '_cke_real_element_type' ] ) ) 114 elementName = realElementName; 115 else 116 elementName = element.name; 117 if ( !( elementName in CKEDITOR.dtd.$body ) ) 112 && element.attributes[ '_cke_real_element_type' ] ) 113 realElement = CKEDITOR.editor.restoreParserElement( element ); 114 115 elementName = realElement ? 116 ( realElement.isUnknown ? // Don't fix for unknown elements. 117 '' : realElement.name ) : element.name; 118 119 if ( elementName && !( elementName in CKEDITOR.dtd.$body ) ) 118 120 { 119 121 var savedCurrent = currentNode; 120 122