Index: yui_editor.module
===================================================================
--- yui_editor.module
+++ yui_editor.module
@@ -190,6 +190,17 @@
   drupal_add_css(drupal_get_path("module", "yui_editor")."/yui_editor.css");
   drupal_add_js(drupal_get_path("module", "yui_editor")."/yui_editor.js");
   drupal_add_js(drupal_get_path("module", "yui_editor")."/toolbars/".variable_get('yui_editor_button_profile', 'yui_editor_toolbar_default.js'));
+  
+   // This is the hook which calls all modules to add their js file
+   // so the editor can be enhanced by external modules
+   module_invoke_all('yui_editor');
+
+   // We also pass an array of function names to our yui editor
+   // so these can be called on the js side of things
+   foreach (module_implements('yui_editor') as $name) {
+   $function = $name .'_yui_editor';
+      drupal_add_js(array('yui_editor_addons'=>array($function)),'setting');
+   }
 
   $ids = variable_get('yui_editor_ids', '');
 
@@ -241,6 +252,7 @@
     print drupal_to_js($response);
     exit;
   }
+  file_set_status($file, FILE_STATUS_PERMANENT);
   
   $response->status = 'UPLOADED';
   $response->image_url = $file->filepath;
Index: yui_editor.js
===================================================================
--- yui_editor.js
+++ yui_editor.js
@@ -33,10 +33,32 @@
     myEditor.render();
 
     // JCD: Eventually we probably should just move all of the config functionality into separate functions/files
+    // TODO: now we can do that with JS hooks
 
     if (config.imgUpload == 1) {
       yui_img_uploader(myEditor, '?q=/yui_editor/image_upload', 'files[upload]', config.base_path);
-     }
+     }
+     
+     //
+     // Call a Javascript Hook
+     // 
+     // This gets the array of modules which implement the 'yui_editor' hook
+     // I expect each module to add their own js file via drupal_add_js
+     // AND I expect each js file to implement the hook_yui_editor as a JS function
+     // 
+     // Example:
+     // The module cool_button implements the PHP function cool_button_yui_editor()
+     // That function adds a coolbutton.js which has a js function also called
+     // yui_editor_cool_button implemented but this one gets as an argument the editor
+     
+     allAddOns = Drupal.settings.yui_editor_addons
+     for (x in allAddOns) {
+          eval(allAddOns[x] + '(myEditor)');
+     }
+     
+     // 
+     // End of hook calling
+     //
 
     if (config.resize == 1) {
       myEditor.on('editorContentLoaded', function() {
