Changeset 961
- Timestamp:
- 02/02/08 18:30:42 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 removed
- 7 modified
-
XinhaCore.js (modified) (12 diffs)
-
XinhaLoader.js (modified) (3 diffs)
-
modules/FullScreen/full-screen.js (modified) (1 diff)
-
modules/Gecko/lang (deleted)
-
modules/GetHtml/DOMwalk.js (modified) (2 diffs)
-
modules/GetHtml/TransformInnerHTML.js (modified) (1 diff)
-
modules/WebKit (added)
-
modules/WebKit/WebKit.js (added)
-
plugins/SmartReplace/smart-replace.js (modified) (5 diffs)
-
skins/silva/skin.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/XinhaCore.js
r957 r961 139 139 */ 140 140 Xinha.is_khtml = (Xinha.agt.indexOf("khtml") != -1); 141 /** Browser is WebKit 142 @type string 143 */ 144 Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); 141 145 /** Browser is Safari 142 146 @type string … … 155 159 */ 156 160 Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); 157 /** Browserengine is Gecko (Mozilla) 161 /** Browserengine is Gecko (Mozilla), applies also to Safari 158 162 @type string 159 163 */ 160 Xinha.is_gecko = (navigator.product == "Gecko" && !Xinha.is_safari); // Safari lies! 164 Xinha.is_gecko = (navigator.product == "Gecko"); 165 Xinha.is_real_gecko = (navigator.product == "Gecko" && !Xinha.is_webkit); 161 166 /** File is opened locally opened ("file://" protocol) 162 167 * @type string … … 2037 2042 editor._browserSpecificPlugin = editor.registerPlugin('InternetExplorer'); 2038 2043 } 2039 else 2044 else if (Xinha.is_webkit) 2045 { 2046 url = _editor_url + 'modules/WebKit/WebKit.js'; 2047 if ( !Xinha.loadPlugins(["WebKit"], function() { editor.generate(); }, url ) ) 2048 { 2049 2050 return false; 2051 } 2052 editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); 2053 } 2054 else if (Xinha.is_gecko) 2040 2055 { 2041 2056 url = _editor_url + 'modules/Gecko/Gecko.js'; … … 2856 2871 } catch (ex) {} 2857 2872 } 2858 else if ( !Xinha.is_ gecko&& this._doc.body.contentEditable !== false )2873 else if ( !Xinha.is_designMode && this._doc.body.contentEditable !== false ) 2859 2874 { 2860 2875 this._doc.body.contentEditable = false; … … 4427 4442 editor._doc.execCommand('useCSS', false, false); // useCSS deprecated & replaced by styleWithCSS 4428 4443 editor._doc.execCommand('styleWithCSS', false, true); 4429 4444 4430 4445 } catch (ex) {} 4431 }4446 } 4432 4447 4433 4448 var btn = editor._toolbarObjects[cmdID].element; … … 4580 4595 case 'justifyleft' : 4581 4596 case 'justifyright' : 4582 {4583 4597 cmdID.match(/^justify(.*)$/); 4584 4598 var ae = this.activeElement(this.getSelection()); … … 4591 4605 this._doc.execCommand(cmdID, UI, param); 4592 4606 } 4593 }4594 4607 break; 4595 4608 … … 5089 5102 Xinha._object = null; 5090 5103 5104 /** Arrays are identified as "object" in typeof calls. Adding this tag to the Array prototype allows to distinguish between the two 5105 */ 5106 Array.prototype.isArray = true; 5107 /** RegExps are identified as "object" in typeof calls. Adding this tag to the RegExp prototype allows to distinguish between the two 5108 */ 5109 RegExp.prototype.isRegExp = true; 5091 5110 /** function that returns a clone of the given object 5092 5111 * … … 5101 5120 return null; 5102 5121 } 5103 5104 var newObj = {}; 5105 5106 // check for array objects 5107 if ( obj.constructor.toString().match( /\s*function Array\(/ ) ) 5108 { 5109 newObj = obj.constructor(); 5110 } 5122 var newObj = (obj.isArray ) ? [] : {}; 5111 5123 5112 5124 // check for function and RegExp objects (as usual, IE is fucked up) 5113 if ( obj.constructor.toString().match( /\s*function Function\(/ ) )5125 if ( obj.constructor.toString().match( /\s*function Function\(/ ) || typeof obj == 'function' ) 5114 5126 { 5115 5127 newObj = obj; // just copy reference to it 5116 5128 } 5117 else if ( obj. constructor.toString().match( /\s*function RegExp\(/ ))5129 else if ( obj.isRegExp ) 5118 5130 { 5119 5131 newObj = eval( obj.toString() ); //see no way without eval … … 5791 5803 + ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\n" 5792 5804 + "html, body { border: 0px; } \n" 5793 + "body { background-color: #ffffff; } \n" 5805 + "body { background-color: #ffffff; } \n" 5806 + "img, hr { cursor: default } \n" 5794 5807 +"</style>\n"; 5795 5808 … … 6090 6103 // Unless somebody already has, make a little function to debug things 6091 6104 6092 if ( typeof dump == 'undefined' )6093 { 6094 function dump (o)6105 if (typeof dumpValues == 'undefined') 6106 { 6107 function dumpValues(o) 6095 6108 { 6096 6109 var s = ''; 6097 for ( var prop in o ) 6098 { 6099 s += prop + ' = ' + o[prop] + '\n'; 6100 } 6101 var x = window.open("", "debugger"); 6102 x.document.write('<pre>' + s + '</pre>'); 6103 } 6104 } 6110 for (var prop in o) 6111 { 6112 if (window.console && typeof window.console.log == 'function') 6113 { 6114 if (typeof console.firebug != 'undefined') 6115 console.log(o); 6116 else 6117 console.log(prop + ' = ' + o[prop] + '\n'); 6118 } 6119 else 6120 s += prop + ' = ' + o[prop] + '\n'; 6121 } 6122 if (s) 6123 { 6124 var x = window.open("", "debugger"); 6125 x.document.write('<pre>' + s + '</pre>'); 6126 } 6127 } 6128 } 6105 6129 if ( !Array.prototype.contains ) 6106 6130 { … … 7057 7081 try 7058 7082 { 7059 if (typeof XMLHttpRequest == "function")7083 if (typeof XMLHttpRequest != "undefined" && typeof XMLHttpRequest.constructor == 'function' ) // Safari's XMLHttpRequest is typeof object 7060 7084 { 7061 7085 return new XMLHttpRequest(); -
trunk/XinhaLoader.js
r957 r961 8 8 Xinha.is_opera = (Xinha.agt.indexOf("opera") != -1); 9 9 Xinha.is_khtml = (Xinha.agt.indexOf("khtml") != -1); 10 Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); 10 11 Xinha.is_safari = (Xinha.agt.indexOf("safari") != -1); 11 12 Xinha.opera_version = navigator.appVersion.substring(0, navigator.appVersion.indexOf(" "))*1; … … 16 17 Xinha.isRunLocally = document.URL.toLowerCase().search(/^file:/) != -1; 17 18 Xinha.is_designMode = (typeof document.designMode != 'undefined' && !Xinha.is_ie); // IE has designMode, but we're not using it 18 Xinha.isSupportedBrowser = Xinha.is_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5 ;19 Xinha.isSupportedBrowser = Xinha.is_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5 || Xinha.is_safari; 19 20 20 21 Xinha.loadPlugins = function(plugins, callbackIfNotReady) … … 189 190 arguments.callee.done = true; 190 191 // kill the timer 192 191 193 if (Xinha.onloadTimer) clearInterval(Xinha.onloadTimer); 192 194 -
trunk/modules/FullScreen/full-screen.js
r738 r961 186 186 this._htmlArea.style.left = e.config.fullScreenMargins[3] + 'px'; 187 187 this._htmlArea.style.top = e.config.fullScreenMargins[0] + 'px'; 188 if ( !Xinha.is_ie ) this._htmlArea.style.border = 'none';188 if ( !Xinha.is_ie && !Xinha.is_webkit ) this._htmlArea.style.border = 'none'; 189 189 this._isFullScreen = true; 190 190 resetScroll(); -
trunk/modules/GetHtml/DOMwalk.js
r943 r961 147 147 } 148 148 var name = a.nodeName.toLowerCase(); 149 if ( /_moz_editor_bogus_node/.test(name) )149 if ( /_moz_editor_bogus_node/.test(name) || ( name == 'class' && a.nodeValue == 'webkit-block-placeholder') ) 150 150 { 151 151 html = ""; … … 181 181 { 182 182 value = a.nodeValue; 183 if (name == 'class') 184 { 185 value = value.replace(/Apple-style-span/,''); 186 if (!value) continue; 187 } 183 188 // IE seems not willing to return the original values - it converts to absolute 184 189 // links using a.nodeValue, a.value, a.stringValue, root.getAttribute("href") -
trunk/modules/GetHtml/TransformInnerHTML.js
r919 r961 34 34 35 35 Xinha.RegExpCache = [ 36 /*00*/ new RegExp().compile(/<\s*\/?([^\s\/>]+)[\s*\/>]/gi),//lowercase tags37 /*01*/ new RegExp().compile(/(\s+)_moz[^=>]*=[^\s>]*/gi),//strip _moz attributes38 /*02*/ new RegExp().compile(/\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g),// find attributes39 /*03*/ new RegExp().compile(/\/>/g),//strip singlet terminators40 /*04*/ new RegExp().compile(/<(br|hr|img|input|link|meta|param|embed|area)((\s*\S*="[^"]*")*)>/g),//terminate singlet tags41 /*05*/ new RegExp().compile(/(<\w+\s+(\w*="[^"]*"\s+)*)(checked|compact|declare|defer|disabled|ismap|multiple|no(href|resize|shade|wrap)|readonly|selected)([\s>])/gi),//expand singlet attributes42 /*06*/ new RegExp().compile(/(="[^']*)'([^'"]*")/),//check quote nesting43 /*07*/ new RegExp().compile(/&(?=(?!(#[0-9]{2,5};|[a-zA-Z0-9]{2,6};|#x[0-9a-fA-F]{2,4};))[^<]*>)/g),//expand query ampersands not in html entities44 /*08*/ new RegExp().compile(/<\s+/g),//strip tagstart whitespace45 /*09*/ new RegExp().compile(/\s+(\/)?>/g),//trim whitespace46 /*10*/ new RegExp().compile(/\s{2,}/g),//trim extra whitespace47 /*11*/ new RegExp().compile(/\s+([^=\s]+)((="[^"]+")|([\s>]))/g),// lowercase attribute names48 /*12*/ new RegExp().compile(/\s+contenteditable(=[^>\s\/]*)?/gi),//strip contenteditable49 /*13*/ new RegExp().compile(/((href|src)=")([^\s]*)"/g), //find href and src for stripBaseHref()50 /*14*/ new RegExp().compile(/<\/?(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|br|hr|img|embed|param|pre|script|html|head|body|meta|link|title|area|input|form|textarea|select|option)[^>]*>/g),51 /*15*/ new RegExp().compile(/<\/(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g),//blocklevel closing tag52 /*16*/ new RegExp().compile(/<(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g),//blocklevel opening tag53 /*17*/ new RegExp().compile(/<(td|th|li|option|br|hr|embed|param|pre|meta|link|title|area|input|textarea)[^>]*>/g),//singlet tag or output on 1 line54 /*18*/ new RegExp().compile(/(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g),//find content NOT inside pre and script tags55 /*19*/ new RegExp().compile(/(<pre[^>]*>)([\s\S])*?(<\/pre>)/g),//find content inside pre tags56 /*20*/ new RegExp().compile(/(^|<!--[\s\S]*?-->)([\s\S]*?)(?=<!--[\s\S]*?-->|$)/g),//find content NOT inside comments57 /*21*/ new RegExp().compile(/\S*=""/g), //find empty attributes58 /*22*/ new RegExp().compile(/<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<\/?\w[^>]*>/g), //find all tags, including comments and php59 /*23*/ new RegExp().compile(/(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g)//find content NOT inside script tags36 /*00*/ /<\s*\/?([^\s\/>]+)[\s*\/>]/gi,//lowercase tags 37 /*01*/ /(\s+)_moz[^=>]*=[^\s>]*/gi,//strip _moz attributes 38 /*02*/ /\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g,// find attributes 39 /*03*/ /\/>/g,//strip singlet terminators 40 /*04*/ /<(br|hr|img|input|link|meta|param|embed|area)((\s*\S*="[^"]*")*)>/g,//terminate singlet tags 41 /*05*/ /(<\w+\s+(\w*="[^"]*"\s+)*)(checked|compact|declare|defer|disabled|ismap|multiple|no(href|resize|shade|wrap)|readonly|selected)([\s>])/gi,//expand singlet attributes 42 /*06*/ /(="[^']*)'([^'"]*")/,//check quote nesting 43 /*07*/ /&(?=(?!(#[0-9]{2,5};|[a-zA-Z0-9]{2,6};|#x[0-9a-fA-F]{2,4};))[^<]*>)/g,//expand query ampersands not in html entities 44 /*08*/ /<\s+/g,//strip tagstart whitespace 45 /*09*/ /\s+(\/)?>/g,//trim whitespace 46 /*10*/ /\s{2,}/g,//trim extra whitespace 47 /*11*/ /\s+([^=\s]+)((="[^"]+")|([\s>]))/g,// lowercase attribute names 48 /*12*/ /\s+contenteditable(=[^>\s\/]*)?/gi,//strip contenteditable 49 /*13*/ /((href|src)=")([^\s]*)"/g, //find href and src for stripBaseHref() 50 /*14*/ /<\/?(div|p|h[1-6]|table|tr|td|th|ul|ol|li|blockquote|object|br|hr|img|embed|param|pre|script|html|head|body|meta|link|title|area|input|form|textarea|select|option)[^>]*>/g, 51 /*15*/ /<\/(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g,//blocklevel closing tag 52 /*16*/ /<(div|p|h[1-6]|table|tr|ul|ol|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g,//blocklevel opening tag 53 /*17*/ /<(td|th|li|option|br|hr|embed|param|pre|meta|link|title|area|input|textarea)[^>]*>/g,//singlet tag or output on 1 line 54 /*18*/ /(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g,//find content NOT inside pre and script tags 55 /*19*/ /(<pre[^>]*>)([\s\S])*?(<\/pre>)/g,//find content inside pre tags 56 /*20*/ /(^|<!--[\s\S]*?-->)([\s\S]*?)(?=<!--[\s\S]*?-->|$)/g,//find content NOT inside comments 57 /*21*/ /\S*=""/g, //find empty attributes 58 /*22*/ /<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<\/?\w[^>]*>/g, //find all tags, including comments and php 59 /*23*/ /(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g //find content NOT inside script tags 60 60 ]; 61 61 // compile for performance; WebKit doesn't support this 62 if (typeof RegExp.prototype.compile == 'function') { 63 for (var i=0; i<Xinha.RegExpCache.length;i++ ) { 64 Xinha.RegExpCache[i] = new RegExp().compile(Xinha.RegExpCache[i]); 65 } 66 } 62 67 /** 63 68 * Cleans HTML into wellformed xhtml -
trunk/plugins/SmartReplace/smart-replace.js
r752 r961 107 107 var editor = this.editor; 108 108 var charCode = Xinha.is_ie ? ev.keyCode : ev.charCode; 109 109 110 110 var key = String.fromCharCode(charCode); 111 111 … … 138 138 139 139 var sel = editor.getSelection(); 140 140 141 141 if (Xinha.is_ie) 142 142 { … … 161 161 else 162 162 { 163 if (!sel.isCollapsed) 163 var r = editor.createRange(sel); 164 165 if (!r.collapsed) 164 166 { 165 167 editor.insertNodeAtSelection(document.createTextNode('')); 166 168 } 167 if (sel.anchorOffset > 0) sel.extend(sel.anchorNode,sel.anchorOffset-1); 169 if (r.startOffset > 0) r.setStart(r.startContainer, r.startOffset -1); 170 168 171 169 if( sel.toString().match(/\S/))170 { 171 sel.collapse(sel.anchorNode,sel.anchorOffset);172 if(r.toString().match(/[^\s\xA0]/)) 173 { 174 r.collapse(false); 172 175 editor.insertNodeAtSelection(document.createTextNode(closing)); 173 176 } 174 177 else 175 178 { 176 sel.collapse(sel.anchorNode,sel.anchorOffset); 177 editor.insertNodeAtSelection(document.createTextNode(opening)); 178 } 179 r.deleteContents(); 180 editor.insertNodeAtSelection(document.createTextNode(' '+opening)); 181 } 182 editor.getSelection().collapseToEnd(); 179 183 } 180 184 } … … 184 188 var editor = this.editor; 185 189 var sel = this.editor.getSelection(); 190 var r = this.editor.createRange(sel); 191 186 192 if (Xinha.is_ie) 187 193 { 188 var r = this.editor.createRange(sel);189 194 r.moveStart('character', -2); 190 195 … … 196 201 else 197 202 { 198 sel.extend(sel.anchorNode,sel.anchorOffset-2); 199 if(sel.toString().match(/^-/)) 200 { 203 if (r.startOffset > 1) r.setStart(r.startContainer, r.startOffset -2); 204 205 if(r.toString().match(/^ -/)) 206 { 207 r.deleteContents(); 201 208 this.editor.insertNodeAtSelection(document.createTextNode(' '+String.fromCharCode(8211))); 202 209 } 203 sel.collapse(sel.anchorNode,sel.anchorOffset);210 editor.getSelection().collapseToEnd(); 204 211 } 205 212 } -
trunk/skins/silva/skin.css
r880 r961 76 76 border-right: none; 77 77 width: 1px; 78 height: 1 8px;78 height: 11px; 79 79 padding: 0px; 80 80 }
