Browse Source

[svn r22423] FS#2867 - The online editor: Implementing 2.6.5 SVN patch, ticket #2156 - http://dev.fckeditor.net/ticket/2156 .

Ivan Tcholakov 15 years ago
parent
commit
01a567f12d

+ 1 - 1
documentation/changelog.html

@@ -34,7 +34,7 @@
   <li>The installation sript: The page about system requilements has been updated. Also, at the very beginning, a check has been added whether the <a href="http://php.net/manual/en/book.mbstring.php" target="_blank">mbstring</a> php-extension is installed - see <a href="http://dokeos.com/forum/viewtopic.php?t=29548" target="_blank">the related forum topic</a>. (FS#306)</li>
   <li>A new php-based configuration for the online editor has been implemented, see <i>dokeos/main/inc/lib/fckeditor/myconfig.php</i>. Also, toolbar definitions have been split in separate php-files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . Customization of the editor is more convenient and flexible now. (FS#2867)</li>
   <li>Online editor: A upgrade from FCKEditor 2.6.4 to <b>FCKEditor 2.6.4.1</b> has been implemented. (FS#4383)</li>
-  <li>Online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets <a href="http://dev.fckeditor.net/ticket/1537" target="_blank">#1537</a>, <a href="http://dev.fckeditor.net/ticket/2821" target="_blank">#2821</a>, <a href="http://dev.fckeditor.net/ticket/2856" target="_blank">#2856</a>, <a href="http://dev.fckeditor.net/ticket/2915" target="_blank">#2915</a>, <a href="http://dev.fckeditor.net/ticket/3120" target="_blank">#3120</a>, <a href="http://dev.fckeditor.net/ticket/3181" target="_blank">#3181</a>, <a href="http://dev.fckeditor.net/ticket/3429" target="_blank">#3429</a>, <a href="http://dev.fckeditor.net/ticket/3439" target="_blank">#3439</a>, <a href="http://dev.fckeditor.net/ticket/3880" target="_blank">#3880</a>. (FS#2867)</li>
+  <li>Online editor: Several known bug-fixes from FCKEditor 2.6.5 SVN have been implemented, tickets <a href="http://dev.fckeditor.net/ticket/1537" target="_blank">#1537</a>, <a href="http://dev.fckeditor.net/ticket/2156" target="_blank">#2156</a>, <a href="http://dev.fckeditor.net/ticket/2821" target="_blank">#2821</a>, <a href="http://dev.fckeditor.net/ticket/2856" target="_blank">#2856</a>, <a href="http://dev.fckeditor.net/ticket/2915" target="_blank">#2915</a>, <a href="http://dev.fckeditor.net/ticket/3120" target="_blank">#3120</a>, <a href="http://dev.fckeditor.net/ticket/3181" target="_blank">#3181</a>, <a href="http://dev.fckeditor.net/ticket/3429" target="_blank">#3429</a>, <a href="http://dev.fckeditor.net/ticket/3439" target="_blank">#3439</a>, <a href="http://dev.fckeditor.net/ticket/3880" target="_blank">#3880</a>. (FS#2867)</li>
   <li>Online editor: The simple file manager, the advanced file manager and the image manager have been integrated by default with the editor's dialog system. Thus, they work faster and in a more secure way. (FS#2867)</li>
   <li>Online editor: Blocking copy/paste for trainees has been added. The feature is configurable through editing the toolbar definition files within the directory <i>dokeos/main/inc/lib/fckeditor/toolbars/</i> . (FS#2867)</li>
   <li>Online editor: Preview tabs have been added to the dialogs for inserting video, flv-video, and YouTube video. (FS#2867)</li>

+ 38 - 10
main/inc/lib/fckeditor/editor/_source/internals/fckdomtools.js

@@ -488,18 +488,46 @@ var FCKDomTools =
 
 		for ( var i = 0 ; i < attributes.length ; i++ )
 		{
-			if ( FCKBrowserInfo.IsIE && attributes[i].nodeName == 'class' )
+			if ( FCKBrowserInfo.IsIE ) 
 			{
-				// IE has a strange bug. If calling removeAttribute('className'),
-				// the attributes collection will still contain the "class"
-				// attribute, which will be marked as "specified", even if the
-				// outerHTML of the element is not displaying the class attribute.
-				// Note : I was not able to reproduce it outside the editor,
-				// but I've faced it while working on the TC of #1391.
-				if ( element.className.length > 0 )
-					return true ;
+				var attributeNodeName = attributes[i].nodeName ;
+
+				if ( attributeNodeName.StartsWith( '_fck' ) ) 
+				{
+					/**
+					 * There are places in the FCKeditor code where HTML element objects
+					 * get values stored as properties (e.g. _fckxhtmljob).  In Internet 
+					 * Explorer, these are interpreted as attempts to set attributes on
+					 * the element.  
+					 *
+					 * http://msdn.microsoft.com/en-us/library/ms533026(VS.85).aspx#Accessing_Element_Pr
+					 *
+					 * Counting these as HTML attributes cripples 
+					 * FCK.Style.RemoveFromRange() once FCK.GetData() has been called.
+					 *
+					 * The above conditional prevents these internal properties being 
+					 * counted as attributes.
+					 *
+					 * refs #2156 and #2834
+					 */
+
+					continue ;
+				}
+
+				if ( attributeNodeName == 'class' ) 
+				{
+					// IE has a strange bug. If calling removeAttribute('className'),
+					// the attributes collection will still contain the "class"
+					// attribute, which will be marked as "specified", even if the
+					// outerHTML of the element is not displaying the class attribute.
+					// Note : I was not able to reproduce it outside the editor,
+					// but I've faced it while working on the TC of #1391.
+					if ( element.className.length > 0 )
+						return true ;
+					continue ;
+				}
 			}
-			else if ( attributes[i].specified )
+			if ( attributes[i].specified )
 				return true ;
 		}
 

+ 17 - 0
main/inc/lib/fckeditor/editor/_source/internals/fckxhtml.js

@@ -56,6 +56,23 @@ FCKXHtml.GetXHTML = function( node, includeNode, format )
 	else
 		this._AppendChildNodes( this.MainNode, node, false ) ;
 
+	/**
+	 * FCKXHtml._AppendNode() marks DOM element objects it has 
+	 * processed by adding a property called _fckxhtmljob, 
+	 * setting it equal to the value of FCKXHtml.CurrentJobNum.  
+	 * On Internet Explorer, if an element object has such a 
+	 * property,  it will show up in the object's attributes 
+	 * NamedNodeMap, and the corresponding Attr object in 
+	 * that collection  will have is specified property set 
+	 * to true.  This trips up code elsewhere that checks to 
+	 * see if an element is free of attributes before proceeding 
+	 * with an edit operation (c.f. FCK.Style.RemoveFromRange())
+	 *	
+	 * refs #2156 and #2834
+	 */
+	if ( FCKBrowserInfo.IsIE )
+		FCKXHtml._RemoveXHtmlJobProperties( node ) ;
+
 	// Get the resulting XHTML as a string.
 	var sXHTML = this._GetMainXmlString() ;
 

+ 36 - 0
main/inc/lib/fckeditor/editor/_source/internals/fckxhtml_ie.js

@@ -92,6 +92,42 @@ FCKXHtml._AppendAttributes = function( xmlNode, htmlNode, node, nodeName )
 	}
 }
 
+/**
+ * Used to clean up HTML that has been processed FCKXHtml._AppendNode().
+ *
+ * For objects corresponding to HTML elements, Internet Explorer will 
+ * treat a property as if it were an attribute set on that element.
+ *
+ * http://msdn.microsoft.com/en-us/library/ms533026(VS.85).aspx#Accessing_Element_Pr
+ *
+ * FCKXHtml._AppendNode() sets the property _fckxhtmljob on node objects
+ * corresponding HTML elements to mark them as having been processed.
+ * Counting these properties as attributes will cripple style removal
+ * because FCK.Styles.RemoveFromSelection() will not remove an element
+ * as long as it still has attributes.
+ *
+ * refs #2156 and #2834
+ */
+
+FCKXHtml._RemoveXHtmlJobProperties = function ( node ) 
+{
+	// Select only nodes of type ELEMENT_NODE
+	if (!node || !node.nodeType || node.nodeType != 1)
+		return ;
+
+	// Clear the _fckhtmljob attribute.
+	if ( typeof node._fckxhtmljob !== 'undefined' )
+		node.removeAttribute('_fckxhtmljob') ;
+
+	// Recurse upon child nodes.
+	if ( node.hasChildNodes() ) 
+	{
+		var childNodes = node.childNodes ;
+		for ( var i = childNodes.length - 1 ; i >= 0 ; i-- ) 
+			FCKXHtml._RemoveXHtmlJobProperties( childNodes.item(i) ) ;
+	}
+}
+
 // On very rare cases, IE is loosing the "align" attribute for DIV. (right align and apply bulleted list)
 FCKXHtml.TagProcessors['div'] = function( node, htmlNode )
 {

File diff suppressed because it is too large
+ 0 - 0
main/inc/lib/fckeditor/editor/js/fckeditorcode_gecko.js


File diff suppressed because it is too large
+ 0 - 0
main/inc/lib/fckeditor/editor/js/fckeditorcode_ie.js


Some files were not shown because too many files changed in this diff