Index: asset.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/asset/asset.module,v
retrieving revision 1.1.2.37
diff -u -p -r1.1.2.37 asset.module
--- asset.module	28 Oct 2008 11:16:04 -0000	1.1.2.37
+++ asset.module	25 Mar 2009 21:26:05 -0000
@@ -568,6 +568,7 @@ function asset_wizard() {
   require_once(drupal_get_path('module', 'asset') .'/asset_wizard.inc');
   drupal_add_js(array('asset' => array('basePath' => base_path())), 'setting');
   drupal_add_js(drupal_get_path('module', 'asset') .'/asset.js');
+  drupal_add_js(drupal_get_path('module', 'asset') .'/asset_more.js');
   drupal_add_css(drupal_get_path('module', 'asset') .'/asset_wizard.css');
   list($sites, $site, $lost) = split("/", drupal_get_path('module', 'asset'), 3);
   $theme = variable_get('asset_wizard_theme', drupal_get_path('module', 'asset') .'/themes/default/asset_wizard.css');
@@ -583,6 +584,10 @@ function asset_wizard() {
       drupal_add_js(drupal_get_path('module', 'tinymce') .'/tinymce/jscripts/tiny_mce/tiny_mce_popup.js');
       drupal_add_js(drupal_get_path('module', 'asset') .'/tinymce/asset_tinymce.js');
       break;
+    case 'wysiwyg' :
+      drupal_add_js(drupal_get_path('module', 'tinymce') .'/tinymce/jscripts/tiny_mce/tiny_mce_popup.js');
+      drupal_add_js(drupal_get_path('module', 'asset') .'/plugins/drupalasset/drupalasset.js');
+      break;
   }
   $output = drupal_get_form('asset_wizard_form');
   ob_end_clean();
@@ -1099,3 +1104,13 @@ function theme_asset_textarea_link($elem
   $output .='<div>'. $link .'</div>';
   return $output;
 }
+
+/**
+ * Implementation of hook_wysiwyg_include_directory().
+ */
+function asset_wysiwyg_include_directory($type) {
+  switch ($type) {
+    case 'plugins':
+      return $type;
+  }
+}
\ No newline at end of file
Index: asset_more.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/asset/asset_more.js,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 asset_more.js
--- asset_more.js	19 Dec 2007 18:50:23 -0000	1.1.2.2
+++ asset_more.js	25 Mar 2009 21:26:05 -0000
@@ -72,3 +72,47 @@ Drupal.jslink.prototype.onerror = functi
 if (Drupal.jsEnabled) {
   $(document).ready(Drupal.linkAutoAttach);
 }
+
+function _assetInlineToTag(content) {
+  content = content.replace(/\[asset\|([^\[\]]+)\]/g, function(orig, match) {
+    var asset = {}, chunks = match.split('|');
+    for (var i in chunks) {
+      chunks[i].replace(/([^=]+)=(.*)/g, function(o, property, value) {
+        asset[property] = value;
+      });
+    }
+    asset.name = 'mceItemDrupalAsset';
+    asset.class = 'mceItemDrupalAsset';
+    asset.src = _assetPreviewSrc(asset);
+    asset.alt = 'aid=' + asset.aid + '|title=' + asset.title + '|desc=' + asset.desc;
+    if (asset.link && asset.link.indexOf(',') != -1) {
+      var link = asset.link.split(',', 2);
+      asset.alt += '|link=' + link[0] + '|url=' + link[1];
+    }
+    else {
+      asset.alt += '|link=' + asset.link;
+    }
+    if (typeof asset.url != 'undefined') {
+      asset.alt += '|url=' + asset.url;
+    }
+    asset.alt = encodeURIComponent(asset.alt);
+    var element = '<img ';
+    for (var property in asset) {
+      element += property + '="' + asset[property] + '" ';
+    }
+    element += '/>';
+    return element;
+  });
+  return content;
+}
+
+function _assetPreviewSrc(asset) {
+  var src = 'asset/img/' + asset.aid;
+  if(asset.formatter){
+    src += '/' + asset.formatter;
+    if(asset.format){
+      src += '/' + asset.format;
+    }
+  }
+  return src;
+}
\ No newline at end of file
Index: asset_textarea.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/asset/Attic/asset_textarea.js,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 asset_textarea.js
--- asset_textarea.js	24 Jan 2008 22:04:55 -0000	1.1.2.1
+++ asset_textarea.js	25 Mar 2009 21:26:05 -0000
@@ -31,24 +31,28 @@ function insertToEditor() {
   if(!content){
     return false;
   }
-  // Insert the image
-  /* IE */
-  if (myDoc.selection) {
-    myTextarea.focus();
-    cursor = myDoc.selection.createRange();
-    cursor.text = content;
-    //myForm.insert.focus();
-    
-  } else if (myTextarea.selectionStart || myTextarea.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
-    var startPos  = myTextarea.selectionStart;
-    var endPos    = myTextarea.selectionEnd;
-    var body      = myTextarea.value;  
-    myTextarea.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
-    
-  } else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
-    myTextarea.value += content;
-  }
+  instanceId = window.opener.Drupal.wysiwyg.activeId;
+  instance = window.opener.Drupal.wysiwyg.instances[instanceId];
+  instance.insert(_assetInlineToTag(content));
   
+//  // Insert the image
+//  /* IE */
+//  if (myDoc.selection) {
+//    myTextarea.focus();
+//    cursor = myDoc.selection.createRange();
+//    cursor.text = content;
+//    //myForm.insert.focus();
+//    
+//  } else if (myTextarea.selectionStart || myTextarea.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
+//    var startPos  = myTextarea.selectionStart;
+//    var endPos    = myTextarea.selectionEnd;
+//    var body      = myTextarea.value;  
+//    myTextarea.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
+//    
+//  } else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
+//    myTextarea.value += content;
+//  }
+//  
   // Close the dialog
   cancelAction();
   return false;
Index: asset_wizard.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/asset/Attic/asset_wizard.inc,v
retrieving revision 1.1.2.20
diff -u -p -r1.1.2.20 asset_wizard.inc
--- asset_wizard.inc	15 Sep 2008 07:04:40 -0000	1.1.2.20
+++ asset_wizard.inc	25 Mar 2009 21:26:05 -0000
@@ -29,7 +29,7 @@ function asset_wizard_form($form_values 
     $_SESSION['asset_fieldname'] = $fieldname;
     // drupal_set_message("op2: ". $_SESSION['asset_op']);
   }
-  elseif (isset($_GET['textarea']) || $_GET['q']=="asset/wizard/tinymce") {
+  elseif (isset($_GET['textarea']) || arg(2) == 'tinymce' || arg(2) == 'wysiwyg') {
     unset($_SESSION['asset_fieldname']);
     $_SESSION['asset_op'] = "tinymce";
   }
@@ -358,7 +358,7 @@ function asset_wizard_form($form_values 
     );
   }
   if ($step == 1 && $_SESSION['asset_op']!="Upload" && $_SESSION['asset_op']!="New Folder") {
-  	if ($_SESSION['asset_op']!="tinymce") {
+  	if (!in_array($_SESSION['asset_op'], array("tinymce", "wysiwyg"))) {
       $form['footer']['select'] = array(
         '#type' => 'button',
         '#value' => t('Select'),

