--- editors/bueditor.inc
+++ editors/bueditor.inc
@@ -0,0 +1,83 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Editor integration functions for BUEditor.
+ */
+
+/**
+ * Plugin implementation of hook_editor().
+ */
+function wysiwyg_bueditor_editor() {
+  if (!module_exists('bueditor')) {
+    return;
+  }
+
+  $editors = array();
+  $path = drupal_get_path('module', 'bueditor');
+  $url = 'http://drupal.org/project/bueditor';
+  $settings = array(
+    'vendor url' => $url,
+    'download url' => $url,
+    'library path' => $path,
+    'editor path' => $path,
+    'versions' => array(
+      '6.0' => array(
+        'js files' => array('bueditor.js'),
+      ),
+    ),
+    'libraries' => array(
+      '' => array(
+        'title' => 'Source',
+        'files' => array('bueditor.js'),
+      ),
+    ),
+    'settings callback' => 'wysiwyg_bueditor_settings',
+    'version callback' => 'wysiwyg_bueditor_version',
+  );
+
+  foreach (bueditor_editors('all') as $id => $editor) {
+    $editors['bueditor' . $id] = $settings + array(
+      'title' => 'BUEditor: ' . $editor->name,
+      'eid' => $id,
+    );
+  }
+
+  return empty($editors) ? NULL : $editors;
+}
+
+/**
+ * Detect editor version.
+ *
+ * @param $editor
+ *   An array containing editor properties as returned from hook_editor().
+ *
+ * @return
+ *   The installed editor version.
+ */
+function wysiwyg_bueditor_version($editor) {
+  return '6.0';
+}
+
+/**
+ * Return runtime editor settings for a given wysiwyg profile.
+ *
+ * @param $editor
+ *   A processed hook_editor() array of editor properties.
+ * @param $config
+ *   An array containing wysiwyg editor profile settings.
+ * @param $theme
+ *   The name of a theme/GUI/skin to use.
+ *
+ * @return
+ *   A settings array to be populated in
+ *   Drupal.settings.wysiwyg.configs.{editor}
+ */
+function wysiwyg_bueditor_settings($editor, $config, $theme) {
+  if (isset($editor['eid']) && bueditor_settle($editor['eid'])) {
+    $setting['wysiwyg']['configs']['bueditor'][0] = $editor['name'];
+    drupal_add_js($setting, 'setting');
+    return array('tplid' => 'e' . $editor['eid']);
+  }
+}

--- editors/js/bueditor.js
+++ editors/js/bueditor.js
@@ -0,0 +1,53 @@
+// $Id$
+(function($) {
+
+var Editor = Drupal.wysiwyg.editor;
+
+/**
+ * Initialize editor instances.
+ */
+Editor.init.bueditor = function(settings) {
+  $.extend(BUE.templates, Drupal.settings.BUE.templates);
+  for (var i in settings) {
+    Editor.attach[settings[i]] = Attach;
+    Editor.detach[settings[i]] = Detach;
+  }
+};
+
+/**
+ * Attach this editor to a target element.
+ */
+var Attach = function(context, params, settings) {
+  Editor.attach.none.apply(this, arguments);
+  BUE.processTextarea($('#' + params.field, context)[0], settings.tplid);
+};
+
+/**
+ * Detach a single or all editors.
+ */
+var Detach = function(context, params) {
+  if (params === undefined) {
+    for (var i in BUE.instances) {
+      Remove(BUE.instances[i]);
+    }
+  }
+  else {
+    var T = $('#' + params.field, context)[0];
+    var E = T && (T.bue || T.editor);
+    Remove(E);
+  }
+  Editor.detach.none.apply(this, arguments);
+};
+
+/**
+ * Remove a BUEditor instance.
+ */
+var Remove = function(E) {
+  if (E && E.UI) {
+    E.UI.remove();
+    BUE.instances[E.index] = E.textArea.bue = E.textArea.editor = undefined;
+    $(E.textArea).unbind('focus');
+  }
+};
+
+})(jQuery);


