Index: editors/fckeditor.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/fckeditor.inc,v
retrieving revision 1.11
diff -u -p -r1.11 fckeditor.inc
--- editors/fckeditor.inc	13 Feb 2009 02:22:19 -0000	1.11
+++ editors/fckeditor.inc	25 Feb 2009 01:15:15 -0000
@@ -27,6 +27,14 @@ function wysiwyg_fckeditor_editor() {
     'themes callback' => 'wysiwyg_fckeditor_themes',
     'settings callback' => 'wysiwyg_fckeditor_settings',
     'plugin callback' => 'wysiwyg_fckeditor_plugins',
+    'plugin settings callback' => 'wysiwyg_fckeditor_plugin_settings',
+    'proxy plugin' => array(
+      'drupal' => array(
+        'load' => TRUE,
+        'proxy' => TRUE,
+      ),
+    ),
+    'proxy plugin settings callback' => 'wysiwyg_fckeditor_proxy_plugin_settings',
     'versions' => array(
       2.6 => array(
         'js files' => array('fckeditor-2.6.js'),
@@ -157,6 +165,35 @@ function wysiwyg_fckeditor_themes($edito
 }
 
 /**
+ * Build a JS settings array of native external plugins that need to be loaded separately.
+ *
+ * @todo Required for FCKeditor?  If not, wysiwyg_add_plugin_settings() needs
+ *   an overhaul.
+ */
+function wysiwyg_fckeditor_plugin_settings($editor, $profile, $plugins) {
+  $settings = array();
+  return $settings;
+}
+
+/**
+ * Build a JS settings array for Drupal plugins loaded via the proxy plugin.
+ */
+function wysiwyg_fckeditor_proxy_plugin_settings($editor, $profile, $plugins) {
+  $settings = array();
+  foreach ($plugins as $name => $plugin) {
+    // Populate required plugin settings.
+    $settings[$name] = $plugin['dialog settings'] + array(
+      'title' => $plugin['title'],
+      'icon' => base_path() . $plugin['icon path'] .'/'. $plugin['icon file'],
+      'iconTitle' => $plugin['icon title'],
+      // @todo These should only be set if the plugin defined them.
+      'css' => base_path() . $plugin['css path'] .'/'. $plugin['css file'],
+    );
+  }
+  return $settings;
+}
+
+/**
  * Return internal plugins for FCKeditor; semi-implementation of hook_wysiwyg_plugin().
  */
 function wysiwyg_fckeditor_plugins($editor) {
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.13
diff -u -p -r1.13 fckeditor-2.6.js
--- editors/js/fckeditor-2.6.js	5 Feb 2009 01:34:35 -0000	1.13
+++ editors/js/fckeditor-2.6.js	25 Feb 2009 05:00:58 -0000
@@ -11,13 +11,17 @@ Drupal.wysiwyg.editor.attach.fckeditor =
   if (settings.buttons) {
     FCKinstance.ToolbarSet = settings.ToolbarSet;
   }
+  delete settings.buttons;
 
   // Apply input format configuration.
   FCKinstance.Config.format = params.format;
-  delete settings.buttons;
   for (var setting in settings) {
     FCKinstance.Config[setting] = settings[setting];
   }
+
+  // Load Drupal plugins.
+  // @see fckeditor.config.js
+
   // Attach editor.
   FCKinstance.ReplaceTextarea();
 };
@@ -45,3 +49,107 @@ Drupal.wysiwyg.editor.detach.fckeditor =
   }
 };
 
+Drupal.wysiwyg.editor.instance.fckeditor = {
+  addPlugin: function(instance, plugin, settings, pluginSettings) {
+    if (typeof Drupal.wysiwyg.plugins[plugin] != 'object') {
+      return;
+    }
+    // DEBUG.
+    console.log(instance);
+    this.ed = instance;
+
+    // @see fckcommands.js, fck_othercommands.js, fckpastewordcommand.js
+    instance.FCKCommands.RegisterCommand(plugin, {
+      // Invoke the plugin's button.
+      Execute: function () {
+        if (typeof Drupal.wysiwyg.plugins[plugin].invoke == 'function') {
+          var data = { format: 'html', node: instance.FCKSelection.GetParentElement() };
+          // @todo This is NOT the same as data.node.
+          data.content = data.node.innerHTML;
+          Drupal.wysiwyg.plugins[plugin].invoke(data, pluginSettings, instance.FCK.Name);
+        }
+      },
+
+      // isNode: Return whether the plugin button should be enabled for the
+      // current selection.
+      // @see FCKUnlinkCommand.prototype.GetState()
+      GetState: function () {
+        // Disabled if not in WYSIWYG mode.
+        if (instance.FCK.EditMode != FCK_EDITMODE_WYSIWYG) {
+          return FCK_TRISTATE_DISABLED;
+        }
+
+        var state = instance.FCK.GetNamedCommandState(this.Name);
+        if (state == FCK_TRISTATE_OFF && instance.FCK.EditMode == FCK_EDITMODE_WYSIWYG) {
+          if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
+            var node = instance.FCKSelection.GetSelection();
+            state = Drupal.wysiwyg.plugins[plugin].isNode(node);
+          }
+        }
+        return state;
+      },
+
+      /**
+       * Return information about the plugin as a name/value array.
+       */
+      Name: plugin
+    });
+
+    // Register the plugin button.
+    // var FCKToolbarButton = function(commandName, label, tooltip, style, sourceView, contextSensitive, icon)
+    instance.FCKToolbarItems.RegisterItem(plugin, new instance.FCKToolbarButton(plugin, settings.iconTitle, settings.iconTitle, null, false, true, settings.icon));
+
+    return;
+
+    // @todo Functionality from TinyMCE that needs to be covered in here as well.
+    tinymce.create('tinymce.plugins.' + plugin, {
+      init: function(ed, url) {
+        // Load custom CSS for editor contents on startup.
+        ed.onInit.add(function() {
+          if (settings.css) {
+            ed.dom.loadCSS(settings.css);
+          }
+        });
+
+        // Attach: Replace plain text with HTML representations.
+        ed.onBeforeSetContent.add(function(ed, data) {
+          if (typeof Drupal.wysiwyg.plugins[plugin].attach == 'function') {
+            data.content = Drupal.wysiwyg.plugins[plugin].attach(data.content, pluginSettings, ed.id);
+            data.content = Drupal.wysiwyg.editor.instance.tinymce.prepareContent(data.content);
+          }
+        });
+
+        // Detach: Replace HTML representations with plain text.
+        ed.onGetContent.add(function(ed, data) {
+          if (typeof Drupal.wysiwyg.plugins[plugin].detach == 'function') {
+            data.content = Drupal.wysiwyg.plugins[plugin].detach(data.content, pluginSettings, ed.id);
+          }
+        });
+
+        // isNode: Return whether the plugin button should be enabled for the
+        // current selection.
+        ed.onNodeChange.add(function(ed, command, node) {
+          if (typeof Drupal.wysiwyg.plugins[plugin].isNode == 'function') {
+            command.setActive(plugin, Drupal.wysiwyg.plugins[plugin].isNode(node));
+          }
+        });
+      },
+    });
+  },
+
+  openDialog: function(dialog, params) {
+  },
+
+  closeDialog: function(dialog) {
+  },
+
+  prepareContent: function(content) {
+  },
+
+  insert: function(content) {
+    var instance = FCKeditorAPI.GetInstance(this.field);
+    // @see FCK.InsertHtml(), FCK.InsertElement()
+    instance.InsertHtml(content);
+  }
+};
+
Index: editors/js/fckeditor.config.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/editors/js/fckeditor.config.js,v
retrieving revision 1.2
diff -u -p -r1.2 fckeditor.config.js
--- editors/js/fckeditor.config.js	1 Feb 2009 05:58:10 -0000	1.2
+++ editors/js/fckeditor.config.js	25 Feb 2009 03:35:36 -0000
@@ -1,5 +1,7 @@
 // $Id: fckeditor.config.js,v 1.2 2009/02/01 05:58:10 sun Exp $
 
+Drupal = window.parent.Drupal;
+
 /**
  * Fetch and provide original editor settings as local variable.
  *
@@ -8,7 +10,14 @@
  * For whatever reason, our custom 'format' property is not available in
  * FCKConfig.format, but in FCKConfig.PageConfig.format instead.
  */
-var wysiwygSettings = window.parent.Drupal.settings.wysiwyg.configs.fckeditor[FCKConfig.PageConfig.format];
+var wysiwygSettings = Drupal.settings.wysiwyg.configs.fckeditor[FCKConfig.PageConfig.format];
+
+/**
+ * Register Drupal plugins for this input format.
+ */
+for (var plugin in Drupal.settings.wysiwyg.plugins.fckeditor.drupal) {
+  Drupal.wysiwyg.editor.instance.fckeditor.addPlugin(window, plugin, Drupal.settings.wysiwyg.plugins.fckeditor.drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin]);
+}
 
 /**
  * Apply custom Wysiwyg API toolbar for input format.
