? LICENSE.txt
? current.patch
? wysiwyg-DRUPAL-6--1.fckeditor.toolbar.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-4.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-5-alternative.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-5-dataprocessor.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-5.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-alternative.patch
? wysiwyg-HEAD.fckeditor-drupal-plugins-dataprocessor.patch
Index: editors/js/fckeditor-2.6.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor-2.6.js,v
retrieving revision 1.14
diff -u -p -r1.14 fckeditor-2.6.js
--- editors/js/fckeditor-2.6.js	21 Mar 2009 23:16:15 -0000	1.14
+++ editors/js/fckeditor-2.6.js	23 Mar 2009 19:35:00 -0000
@@ -36,17 +36,17 @@ Drupal.wysiwyg.editor.detach.fckeditor =
   }
 
   for (var instanceName in instances) {
-    // Shut down the instance and give plugins a chance to detach by changing status first.
-    instances[instanceName].SetStatus(FCK_STATUS_NOTLOADED);
-    instances[instanceName].UpdateLinkedField();
-    $('#' + instanceName).show();
-    $('#' + instanceName + '___Config').remove();
-    $('#' + instanceName + '___Frame').remove();
-    delete FCKeditorAPI.__Instances[instanceName];
+    // Hide the editor now becuase Wysiwyg will unhide the original textare after this function returns.
+
+    // $('#' + instanceName + '___Frame').hide(); // Caused problems when the area was focused...
+    // Switch to our custom shutdown status, will be caught by the OnStatusChange handler.
+    instances[instanceName].SetStatus(Drupal.wysiwyg.editor.instance.fckeditor.FCK_STATUS_WYSIWYG_SHUTDOWN);
   }
 };
 
 Drupal.wysiwyg.editor.instance.fckeditor = {
+  FCK_STATUS_WYSIWYG_SHUTDOWN : 42, // Custom shutdown status
+  catchingEvents : {},
   addPlugin: function(plugin, settings, pluginSettings, instance) {
     if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
       return;
@@ -56,6 +56,60 @@ Drupal.wysiwyg.editor.instance.fckeditor
       instance.FCKConfig.EditorAreaCSS += ',' + Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal[plugin].css;
     }
 
+    /**
+     * Register event listerner for attaching/detaching all the plugins "as one".
+     * Only do this once!
+     */
+    if (!this.catchingEvents[instance.FCK.Name]) {
+      instance.FCK.Events.AttachEvent('OnStatusChange', function(editorInstance, newStatus) {
+        switch (newStatus) {
+          case FCK_STATUS_COMPLETE:
+            var currentContent = editorInstance.GetData();
+            var oldContent = currentContent;
+            for (var plugin in Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
+              if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
+                currentContent = Drupal.wysiwyg.plugins[plugin].attach(currentContent, pluginSettings, editorInstance.Name);
+                currentContent = Drupal.wysiwyg.editor.instance.fckeditor.prepareContent(currentContent);
+              }
+            }
+            if(currentContent != oldContent) {
+              // Asynchronous call!
+              editorInstance.SetData(currentContent);
+            }
+            break;
+          case Drupal.wysiwyg.editor.instance.fckeditor.FCK_STATUS_WYSIWYG_SHUTDOWN:
+            // Parse all placeholders back to wysiwyg tags before shutdown
+            var currentContent = editorInstance.GetData();
+            var oldContent = currentContent;
+            for (var plugin in Drupal.settings.wysiwyg.plugins[instance.wysiwygFormat].drupal) {
+              if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
+                currentContent = Drupal.wysiwyg.plugins[plugin].detach(currentContent, pluginSettings, editorInstance.Name);
+              }
+            }
+            if (currentContent != oldContent) {
+              // Asynchronous call! Wait until editor area is rebuilt, OnAfterSetHTML, then begin killing the editor.
+              editorInstance.SetData(currentContent);
+            }
+            else {
+              Drupal.wysiwyg.editor.instance.fckeditor._killInstance(editorInstance);
+            }
+            break;
+        }
+      });
+
+      /**
+       * Register event listener for killing the editor.
+       */
+      instance.FCK.Events.AttachEvent('OnAfterSetHTML', function(editorInstance) {
+        if (editorInstance.Status == Drupal.wysiwyg.editor.instance.fckeditor.FCK_STATUS_WYSIWYG_SHUTDOWN) {
+          // All tags are processed, now put the final contents in the textarea
+          editorInstance.UpdateLinkedField();
+          Drupal.wysiwyg.editor.instance.fckeditor._killInstance(editorInstance);
+        }
+      });
+      this.catchingEvents[instance.FCK.Name]  = true;
+    }
+
     // @see fckcommands.js, fck_othercommands.js, fckpastewordcommand.js
     instance.FCKCommands.RegisterCommand(plugin, {
       // Invoke the plugin's button.
@@ -98,6 +152,17 @@ Drupal.wysiwyg.editor.instance.fckeditor
     instance.FCKToolbarItems.RegisterItem(plugin, new instance.FCKToolbarButton(plugin, settings.iconTitle, settings.iconTitle, null, false, true, settings.icon));
   },
 
+  _killInstance : function(editorInstance) {
+    setTimeout(function () {
+      var instanceName = editorInstance.Name;
+      $('#' + instanceName + '___Config').remove();
+      delete editorInstance;
+      $('#' + instanceName + '___Frame').remove();
+      $('#' + instanceName).show();
+      Drupal.wysiwyg.editor.instance.fckeditor.catchingEvents[editorInstance.Name] = false;
+    }, 1);
+  },
+
   openDialog: function(dialog, params) {
     // @todo Implement open dialog.
   },
