I've just found an odd and disturbing bug with TinyMCE - or two maybe, depending on how you look at it.

I just posted a number of embedded YouTube videos to a site I'm working on, and problem #1 happened when I found that, while I could click on the HTML button in TinyMCE's toolbar and paste the embed code from YouTube in, once I closed the HTML pop-up, the video did not show up. Clicking on HTML again brought up the code window completely blank -- it had apparently not saved the code I put in at all.

I was eventually able to post the videos by clicking "Disable rich text" on each page and putting in the text that way (using Full HTML as my input mode), but then when I had to go back to one of the pages to edit it, I found the second, presumably related problem: the embed code disappeared as soon as the edit page with TinyMCE came up! Even if I clicked "Disable rich text" again, there was nothing there. Just going to the edit page deleted the content completely.

The only way I was able to continue working on those pages at all was to disable TinyMCE in my account settings, but that's really not a great solution, especially when I'd like to be able to allow members of the site to post videos. Not all of them are going to be comfortable with disabling the editor permanently, or remembering to go into their account settings and disable it any time they want to post a video.

Is there some reason TinyMCE is doing this? Is it set to delete anything involving embed tags automatically, or is this just a weird glitch? If it's actually something deliberate, is there any way to change it, or do I need to switch to a different WYSIWYG editor for the site if I want people to be able to post videos?

Comments

jbyron’s picture

Yes the same error is explained in this issue ticket as well, http://drupal.org/node/236201

Are you using IE7? If so using Firefox should resolve the issue as a temporary fix.

jbyron’s picture

Status: Active » Closed (duplicate)

Duplicate issue.

spidersilk’s picture

Title: TinyMCE deletes video code when editing! » TinyMCE deletes video code when editing! (in FF, not just IE)
Status: Closed (duplicate) » Active

No, I'm using Firefox 2. So this is not just an IE issue.

Wired2’s picture

Is it possible that you have "Filter HTML" enabled?

Look at admin/settings/filters.

You can either add the option of allowing video and img tags in your HTML or provide the option of using full HTML for your user.

g011um’s picture

This thread on the TinyMCE forums suggest it's a bug in TinyMCE itself, and may be fixed in version 3.01 (and later). See: http://tinymce.moxiecode.com/punbb/viewtopic.php?id=10219

I can confirm this behaviour in FireFox 3.x, IE7.x and Google Chrome 1.x

adixon’s picture

Status: Active » Needs review

I just had this problem, and found the following useful post for a non-drupal site:

http://syedgakbar.wordpress.com/2008/01/28/adding-flash-embed-support-in...

I solved my issue by editing my theme_tinymce_theme function, adding:

  /* extend to allow youtube videos */
  $init['extended_valid_elements'] = array('object[type|data|width|height|classid|codebase]','param[name|value]','embed[src|type|width|height|flashvars|wmode]');

You can do this in your theme, or just hack the tinymce.module if you're that kind of person.

If you've already added extended valid elements then you'll want to do an array merge instead, but you probably already know that if you've done so.

Note that I had to allow the "type" and "data" attributes for my implementation - check how you're embedding your code and you may need to add other tags (yes, I don't really understand this either ..).

I would suggest that my two lines above get incorporated into the module as example code (since there's already some there).

jbyron’s picture

Hm, that's an interesting patch, I tried it and couldn't get it to work, I applied to directly to the module, also tried to override in template.php with the theme_tinymce_theme.. no dice.

Anyways, I've gotten it to work somewhat with HTML tag ordering.. then I had to compensate for any white space added by TinyMCE, "Clean up source" under TinyMCE profile settings.. this is set to true, so it adds line breaks, whitespace in the source code.. which broke YouTube embeds.

Basically I disabled TinyMCE temporary in node/edit forms, deleted the whitespace, then submitted with my input filter at full html.

Displays properly now.

So:

- Compensated for tags being stripped with html input filters exception list
- Compensated for TinyMCE white space addition with disable it and removing whitespace

Now displays in IE6 and IE7, no problems with FF3.

explorerstart0’s picture

nicoloye’s picture

Status: Needs review » Closed (outdated)