Ticket #7193: 7193_2.patch
File 7193_2.patch, 6.6 KB (added by , 14 years ago) |
---|
-
_source/plugins/fakeobjects/plugin.js
1 /* 1 /* 2 2 Copyright (c) 2003-2011, 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 function rebuildStyleSheets() 9 { 10 var map = this._.fakeClassMap, 11 fakeNamesRegex = []; 12 13 for ( var name in map ) 14 fakeNamesRegex.push( name ) 15 if ( fakeNamesRegex.length ) 16 { 17 fakeNamesRegex= new RegExp( '(?:^|\\b)('+fakeNamesRegex.join( '|' ) + ')(?:$|\\b)','g' ); 18 19 20 var sheets = this.document.$.styleSheets, 21 sheet, rules, count,rule, selector, style; 22 23 // Walk through all the rules to refactor corresponding selectors. 24 for ( var i = 0; i < sheets.length; i++ ) 25 { 26 sheet = sheets[ i ]; 27 rules = sheet.cssRules || sheet.rules; 28 count = rules.length; 29 for ( var j = 0; j < count; j++ ) 30 { 31 rule = rules[ j ]; 32 selector = rule.selectorText; 33 selector && ( selector = selector.toLowerCase().replace( fakeNamesRegex, 34 function( match, name ) { return map[ name ]; } )); 35 36 // Replace existing rule with new selector. 37 if ( selector != rule.selectorText ) 38 { 39 style = rule.cssText.match( /\{([\s\S]*?)\}/ )[ 1 ]; 40 sheet[ sheet.deleteRule ? 'deleteRule' : 'removeRule' ].call( sheet, j ); 41 sheet.insertRule ? sheet.insertRule( selector + '{' + style + '}', j ) : sheet.addRule( selector, style, j ); 42 console.log(selector, style ); 43 } 44 } 45 } 46 } 47 } 48 8 49 var htmlFilterRules = 9 50 { 10 51 elements : … … 56 97 57 98 if ( htmlFilter ) 58 99 htmlFilter.addRules( htmlFilterRules ); 100 101 // Mapping from real element name to fake element selector, e.g. hr -> img.cke_hr 102 editor._.fakeClassMap = {}; 103 104 // Rebuild the content styles on any new added content to 105 // allow fake elements to receive styles assigned to their real type. 106 editor.on( 'contentDom', rebuildStyleSheets ); 107 editor.on( 'insertHtml', rebuildStyleSheets, null, null, 1000 ); 108 editor.on( 'insertElement', rebuildStyleSheets, null, null, 1000 ); 59 109 } 60 110 }); 61 111 })(); … … 67 117 68 118 var attributes = 69 119 { 70 'class' : className,120 'class' : [ className, realElement.getAttribute( 'class' ) ].join( ' ' ), 71 121 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 72 122 'data-cke-realelement' : encodeURIComponent( realElement.getOuterHtml() ), 73 123 'data-cke-real-node-type' : realElement.type, … … 82 132 if ( isResizable ) 83 133 attributes[ 'data-cke-resizable' ] = isResizable; 84 134 135 this._.fakeClassMap[ realElementType ] = 'img.' + className; 85 136 return this.document.createElement( 'img', { attributes : attributes } ); 86 137 }; 87 138 … … 97 148 98 149 var attributes = 99 150 { 100 'class' : className,151 'class' : [ className, realElement.attributes[ 'class' ] ].join( ' ' ), 101 152 src : CKEDITOR.getUrl( 'images/spacer.gif' ), 102 153 'data-cke-realelement' : encodeURIComponent( html ), 103 154 'data-cke-real-node-type' : realElement.type, … … 112 163 if ( isResizable ) 113 164 attributes[ 'data-cke-resizable' ] = isResizable; 114 165 166 this._.fakeClassMap[ realElementType ] = 'img.' + className; 115 167 return new CKEDITOR.htmlParser.element( 'img', attributes ); 116 168 }; 117 169 -
_source/plugins/wysiwygarea/plugin.js
941 941 // Build the additional stuff to be included into <head>. 942 942 var headExtra = 943 943 '<style type="text/css" data-cke-temp="1">' + 944 editor._. styles.join( '\n' ) +944 editor._.internalStyles.concat( editor._.styles ).join( '\n' ) + 945 945 '</style>'; 946 946 947 947 !fullPage && ( headExtra = -
_source/core/editor.js
423 423 424 424 this._.commands = {}; 425 425 this._.styles = []; 426 this._.internalStyles = []; 426 427 427 428 /** 428 429 * The DOM element that has been replaced by this editor instance. This … … 531 532 this._.styles.push( css ); 532 533 }, 533 534 535 addInternalCss : function( css ) 536 { 537 this._.internalStyles.push( css ); 538 }, 539 534 540 /** 535 541 * Destroys the editor instance, releasing all resources used by it. 536 542 * If the editor replaced an element, the element will be recovered. -
_source/plugins/horizontalrule/plugin.js
9 9 10 10 (function() 11 11 { 12 // IE9 buggy on horizontal line that allows adding text into it, use fake instead. (#7193) 13 var useFake = document.documentMode == 9; 14 12 15 var horizontalruleCmd = 13 16 { 14 17 canUndo : false, // The undo snapshot will be handled by 'insertElement'. 15 18 exec : function( editor ) 16 19 { 17 editor.insertElement( editor.document.createElement( 'hr' ) ); 20 var element = editor.document.createElement( 'hr' ); 21 useFake && ( element = editor.createFakeElement( element, 'cke_hr', 'hr' ) ); 22 editor.insertElement( element ); 18 23 } 19 24 }; 20 25 … … 31 36 label : editor.lang.horizontalrule, 32 37 command : pluginName 33 38 }); 34 } 35 }); 39 40 }, 41 afterInit : useFake ? function( editor ) 42 { 43 // Direct fake objects lang entry to plugin. 44 editor.lang.fakeobjects.hr = editor.lang.horizontalrule; 45 46 // Add the style that renders the horizontal line. 47 editor.addInternalCss( 48 'img.cke_hr' + 49 '{' + 50 'background-image: url(' + ( CKEDITOR.basePath + 'images/spacer.gif' ) + ');' + 51 'clear: both;' + 52 'display: block;' + 53 'float: none;' + 54 'width:100% !important; _width:99.9% !important;' + 55 'height: 0px !important;' + 56 'border-top: #808080 1px solid;' + 57 'border-bottom: #808080 1px solid;' + 58 '}' ); 59 60 // Register a filter to transform placeholders on data input. 61 var dataProcessor = editor.dataProcessor, 62 dataFilter = dataProcessor && dataProcessor.dataFilter; 63 dataFilter && dataFilter.addRules( { elements : { hr : function( element ) { return editor.createFakeParserElement( element, 'cke_hr', 'hr' ); } } } ); 64 } : null 65 } ); 36 66 })();